Convert DMG To PKG

Ahmed Musaad
Ahmed Musaad
Convert DMG To PKG

Many macOS applications come in DMG format, which is perfectly fine until you need to deploy one of these applications using your enterprise MDM solution. Most MDMs only work with PKG files so you must convert the application from DMG to PKG before you deploy it. This post will provide two simple methods I learned while doing my research on how to achieve precisely the desired task.

Apple Disk Image (.dmg, .smi, .img) is a disk image format commonly used by the macOS operating system. When opened, an Apple Disk Image is mounted as a volume within the Macintosh Finder.
A PKG file is a package of compressed installer files used to install a software program. It is commonly used for installing software in Mac OS X and may be installed individually or referenced by an installer script included with the software.

First Method

  • Go to the folder that contains the DMG file.
  • Double click the dmg file and it gets mounted as a virtual disk and reveal its contents.
  • Copy the .app file to the Applications folder in the mac
  • Eject the DMG file by clicking on eject button.
  • Open Terminal.
  • Build the PKG file using the productbuild command (might ask for your password and takes few second to finish running)
sudo productbuild --component/path1/macapp.app /path2/packagename.pkg

Parameters Explained

  • component  The path to the .app file that will be used during PKG generation.
  • path_to_savedpackage/packagename.pkg The destination path for the generated PKG file and desired name.

Second Method

  • Go to the folder that contains the DMG file.
  • Double click the dmg file and it gets mounted as a virtual disk and reveal its contents.
  • Open Terminal
  • Build a PKG with the contents of the mounted dmg as a payload using the following command:
pkgbuild --root /Volumes/DMGName --version 1.0 --identifier com.example.sample --install-location / Sample-1.0.pkg

Parameters Explained

  • /Volumes/DMGName The full path to the mounted DMG file.
  • version The application version, make sure to sync this with the version you are trying to deploy (if it’s Zoom 5.6, then this parameter is 5.6).
  • identifier The app identifier, if you don’t know the value, follow this guide (The Bundle ID is what you are looking for) to get it.
  • install-location The location where the PKG will be installed, leave it as it is.
  • Sample-1.0.pkg The full path and name of the PKG file that will be generated, adjust it as needed.

References



Great! Next, complete checkout for full access to Ahmed Musaad
Welcome back! You've successfully signed in
You've successfully subscribed to Ahmed Musaad
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated