A great deal of the macOS apps provided on the Net are DMG files, that contain a single app at the root of the volume. Then, one must drag manually the app to the Applications folder to install it. This makes the process of installing these apps cumbersome when they must be imported into a deployment system (say, Jamf Pro) as these can't import directly the DMG and work with it… The DMG must be converted first.
There are many tools that can easily convert a DMG to a PKG format that is easy to import in Jamf Pro, like AutoPkgr, but they can be a bit complex to deal with and they have their limits, i.e. downloading the DMG if it's located behind a paywall. quickpkg is another great tool, but I wanted to find a fast way to perform batch conversion of DMG files, and also be able to make conversion as easy as dropping the files in a folder. Thus, Dmg2Pkg here.
- Download and install quickpkg. Ensure that the quickpkg command is in your $PATH!
- Download the Dmg2Pkg.sh script.
- Install this script where you want, and don't forget to chmod 755 it.
- Change the variables in the script. If you don't, it will create a new Dmg2Pkg folder in _/Users/Shared.
- Move your DMG file in the Source_DMGs folder.
- Run the script.
- If everything works properly, new PKGs file should be spit in the Packages folder and the DMG should move in the Processed_DMGs folder automatically.
Let's make things a bit more automatic!
- Get the Launchagent file (net.gete.dmg2pkg.plist).
- Install it in ~/Library/LaunchAgents.
- Open the file and check the paths if you moved the file (especially, check the path to the
Dmg2Pkg.sh
script). - Launch the file with :
launchctl load ~/Library/LaunchAgents/net.gete.dmg2pkg.plist
- Move your DMG files in the Source_DMGs folder.
- Wait for a few seconds, and the new PKG files should appear in the Packages folder and the DMG should move in the Processed_DMGs folder automatically.
If something weird happens (i.e. a package not generated), check Activity.log file. All quickpkg
logs should be redirected in it.