Page 1 of 1
Create dmg using terminal?
Posted: Sat Aug 31, 2019 8:01 am
by collectordave
Is it possible to create a dmg for an app from PB maybe using terminal commands?
CD
Re: Create dmg using terminal?
Posted: Sat Aug 31, 2019 9:39 am
by Wolfram
You can use disk utility. In the first menu / new image from folder.
Re: Create dmg using terminal?
Posted: Sat Aug 31, 2019 11:34 am
by mk-soft
Re: Create dmg using terminal?
Posted: Sat Aug 31, 2019 11:48 am
by collectordave
Yes Thanks
I think my question should have been is it possible to run a terminal command from within a PB programme?
CD
Re: Create dmg using terminal?
Posted: Sat Aug 31, 2019 4:32 pm
by Wolfram
Code: Select all
source.s ="/Users/yourName/test"
target.s = "myNewImage"
parameter.s = "create -fs HFS+ -srcfolder " +#DQUOTE$ +source +#DQUOTE$ +" -volname " +#DQUOTE$ +target +#DQUOTE$ +" " +target +".dmg"
RunProgram("hdiutil", parameter, GetPathPart(source) )
Re: Create dmg using terminal?
Posted: Sun Sep 01, 2019 8:13 am
by collectordave
Hi All
Thanks for the replies gave me some food for thought.
My answer to it is to use AppleScript as well:
First I created this script
Code: Select all
tell application "Finder"
set myFolder to container of (path to me) as text
end tell
set srcFile to myFolder & "TrCmd.txt"
set lns to paragraphs of (read file srcFile as «class utf8»)
repeat with ln in lns
tell application "Terminal"
activate
do script ln
end tell
end repeat
and saved it as an application.
I then simply create a text file of the commands for terminal to do called "TrCmd.txt"
and run the script application. Both script and app in same folder.
The script then reads the text file line by line and tells terminal to do each line.
CD
Re: Create dmg using terminal?
Posted: Sun Sep 01, 2019 11:39 am
by wilbert
collectordave wrote:The script then reads the text file line by line and tells terminal to do each line.
You can use AppleScript from within PB as well.
viewtopic.php?p=393553#p393553
Re: Create dmg using terminal?
Posted: Sun Sep 01, 2019 2:57 pm
by collectordave
Hi All
Stuck a bit again.
I want to copy a .app to a dmg with terminal or AppleScript.
Found hundreds of examples on web none work.
PB copy file does not work with aliases or .app files neither does copy directory.
Any help appreciated
CD
Re: Create dmg using terminal?
Posted: Sun Sep 01, 2019 3:10 pm
by wilbert
collectordave wrote:PB copy file does not work with aliases or .app files neither does copy directory.
You can use
copyItemAtPath:toPath:error: from the NSFileManager class. See this post
viewtopic.php?f=19&t=59105
NSFileManager also has a method to move instead of copy.
Re: Create dmg using terminal?
Posted: Sun Sep 01, 2019 3:29 pm
by collectordave
You can use copyItemAtPath:toPath:error: from the NSFileManager class. See this post
viewtopic.php?f=19&t=59105
NSFileManager also has a method to move instead of copy.
Works first time.
Headache going away.
Thank you
CD
Re: Create dmg using terminal?
Posted: Mon Sep 02, 2019 4:35 am
by collectordave
Using the call apple script can the procedure run an AppleScript file?
CD
Re: Create dmg using terminal?
Posted: Mon Sep 02, 2019 5:01 am
by wilbert
collectordave wrote:Using the call apple script can the procedure run an AppleScript file?
That should be possible.
One way would be to use PB commands to load the file and pass the entire file as a string.
The other way to use
initWithContentsOfURL:error: together with
fileURLWithPath: instead of
initWithSource: .
That way you can let the OS do the loading of the file.
Re: Create dmg using terminal?
Posted: Tue Sep 03, 2019 7:56 am
by collectordave
Hi All
Managed to get it working with filberts AppleScript with one exception.
Code: Select all
Unmount = "do shell script " + #DQUOTE$ + "hdiutil unmount Volumes/Tester" + #DQUOTE$
; do shell script "hdiutil unmount Volumes/Tester"
Debug UnMount
Applescript(Unmount)
I am building the script as above and supplying it to AppleScript and it does not work.
If I use script editor with the output as the comment in the code it works.
Any ideas?
Regards
CD
Re: Create dmg using terminal?
Posted: Tue Sep 03, 2019 8:23 am
by collectordave
Changed my UnMount to
diskutil instead of hdiutil and it works?
CD
Re: Create dmg using terminal?
Posted: Wed Sep 04, 2019 5:12 am
by collectordave
Hi All
Just been putting it all together the fruits of this are here
viewtopic.php?f=19&t=73543
A simple app to create a fancy DMG for your app.
Thanks to all.
CD