Create dmg using terminal?

Mac OSX specific forum
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Create dmg using terminal?

Post by collectordave »

Is it possible to create a dmg for an app from PB maybe using terminal commands?

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Wolfram
Enthusiast
Enthusiast
Posts: 606
Joined: Thu May 30, 2013 4:39 pm

Re: Create dmg using terminal?

Post by Wolfram »

You can use disk utility. In the first menu / new image from folder.
macOS Catalina 10.15.7
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Create dmg using terminal?

Post by mk-soft »

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Wolfram
Enthusiast
Enthusiast
Posts: 606
Joined: Thu May 30, 2013 4:39 pm

Re: Create dmg using terminal?

Post 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) )
macOS Catalina 10.15.7
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Create dmg using terminal?

Post 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
Windows (x64)
Raspberry Pi OS (Arm64)
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Create dmg using terminal?

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post by collectordave »

Using the call apple script can the procedure run an AppleScript file?

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Create dmg using terminal?

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post by collectordave »

Changed my UnMount to

diskutil instead of hdiutil and it works?

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Create dmg using terminal?

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply