Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm simplifying making a .deb file with Automator. I currently have a shell script that does some simple actions -

  1. Ask the user for text input
  2. Do some directory parsing
  3. Execute a command with the text input as a variable
  4. run the dpkg-deb program and output to the desktop

That's all well and good, but .deb files must have a "control" text file with some fields filled out, and the file has to be in a specific path, with the control file residing in a DEBIAN subdirectory like so

AppName/DEBIAN/control

What I would like to do, is create the control file, and drop it on the Automator workflow and have it run the script with the control file as an input parameter. I would need the script to "copy this file to AppName/DEBIAN/ and create the DEBIAN folder if it doesn't exist.

Where AppName == A specific line from the control file

Can anyone help?

share|improve this question
    
This would be quite easy with a shell script (which you seem to be comfortable with) which you call from Automator which leads to the question why it needs to be an Automator workflow at all. –  patrix Aug 15 '13 at 20:55
1  
Because I want to have the workflow as an icon on the desktop and then just drag and drop the described control file on top of it to start the workflow, so i don't have to do any typing in terminal :-) –  Justin Amberson Aug 15 '13 at 21:00

1 Answer 1

up vote 1 down vote accepted

EDIT: Workflow now works with one bug: running the workflow twice results in two copies of the control file being copied

Make a new Automator SERVICE. At the beginning, for "receives selected as input" choose "documents". Add the process "set value of variable" and make a new "destination path" variable (default variable name is "destination path"). Add the process "open finder items" to the beginning to open the control file. Add the process "run applescript" to the workflow the code is the following:

on run {input, parameters}

set LineNumber to (the line in which the path is specified in the control file)
tell application "TextEdit"
    set theVariable to paragraph LineNumber of document 1
    set thePath to POSIX path of theVariable
    set thePath to text 1 thru -2 of thePath
end tell

return thePath
end run

I don't know why this couldn't have been in the same block, but you need to add a separate AppleScript process. The code is as follows:

on run {input, parameters}

tell application "Finder"
    set theFolder to POSIX path of input & "/DEBIAN"
    try
        make new folder in folder input with properties {name:"DEBIAN"}
    end try
end tell

return theFolder
end run

Add the process "set value of variable" and make a new destination path variable (default name is "destination path 1").
Add the "get value of variable" process and get the value of the variable with the path of the input file ("destination path"). Click on "options" on this process and check "ignore this action's input".
After this, Automator has a process called "copy finder items" and this can be used to copy the input (the output of "get value of variable", which is the input file). This worked for me, hope it works for you as well. Good luck :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.