Converting DMG to PKG For Deployments

Neil ChavezPro Tip

If you have ever deployed applications to a macOS fleet with a .dmg disk image, you know how tricky (and annoying) this can be. A .dmg file must be mounted by the macOS system before the installation files can be read/executed. Whereas a .pkg can be installed directly without the need for being mounted. This isn’t to say that it can’t be done, but we like to make things easy and efficient wherever possible.

This quick pro tip will go over the steps to convert those .dmg files to .pkg files so you can deploy your apps easier via your favorite RMM or MDM platform.

In the steps below, we will be using a .dmg file for “Keeper Password Manager” as this was one of our latest app deployments, but the steps apply to any .dmg file.

Steps

  1. Go to the folder where your .dmg file is located and double-click on it to get it mounted.
  2. Copy (drag) the .app file to the Applications folder. This will install the application and allow us to convert those installations files to a .pkg file


    • Once this is done you can eject the mounted .dmg by right-clicking it and selecting “eject”


    • Search and launch the Terminal app on the macOS device.
    • Use the following command to build the PKG file:

      sudo productbuild –component /filepathtotheinstalledapp/appname.app /savelocationdesired/packagename.pkg

      Replace the “/filepathtotheinstalledapp/appname.app” to the location path of the app you installed. And change the “savelocationdesired/packagename.pkg” to the name/location to the desired location you would like the pkg file saved to.

      In my example the location path of the app is “/Applications/Keeper Password Manager.app” and the name/destination save location is the following, “/Users/USERNAME/Desktop/KeeperPassword.pkg”

      *Note* if your source or destination paths/file names contain any spaces (e.g. Keeper Password Manager), be sure it contains the argument in quotations. As an example, here is the command I will be using:

      sudo productbuild –component “/Applications/Keeper Password Manager.app” /Users/USERNAME/Desktop/KeeperPassword.pkg


    • The time it will take for the package to be built depends on the application, however, you should see a similar terminal message once it has completed:


    • Check the location you specified as the destination, and you should see your newly created app package file.

      From here you can use the .pkg file and deploy via your preferred method.