Make A Pkg From Dmg

Scroll down to “Update and Solution” to see how to get this to work.

A DMG file, like ISO, can be used to install macOS operating system or Mac apps. If the Mac computer was broken or crashed and couln't get into the system, but you only have access to a Windows PC, there's still a way to make a bootable macOS install USB on Windows. Converting a.dmg File to a.pkg File Before Deployment Jamf Now only supports.pkg files for package deployment. If you have an app that is not available in the.pkg file type, you will need to repackage the.dmg file as a signed.pkg file before distributing with Jamf Now. Composer allows you to rebuild an existing package (PKG, DMG, or MPKG) by converting it to a package source. After converting it to a package source, you can make changes to its contents and save a new copy of the package. Open Composer and authenticate locally. Drag the package you want to convert from the Finder to the sidebar in Composer.

Apple recently released new installers for Mac OS X/OS X/mac OS to deal with expired certificates:

Three of the six are links to the Mac App Store:

The other three are URLs to download DMGs:

  • macOS Sierra – InstallOS.dmg
  • OS X El Capitan – InstallMacOSX.dmg
  • OS X Yosemite – InstallMacOSX.dmg

Today I tried (and failed) to create a new Virtual Machine in either Parallels or VMware Fusion using one of these DMGs, specifically, the El Capitan one.

I will explain what I did, and where I got stuck, in the hopes that someone else might figure out what I did wrong and point me in the right direction.

Download the DMG

Apple has created three DMGs for Yosemite, El Capitan, and Sierra, but couldn’t be bothered to give them useful names, so Yosemite and El Capitan are called ‘InstallMacOSX.dmg’ and Sierra is ‘InstallOS.dmg’.

Likewise the DMGs aren’t named usefully when you mount them either, so make sure you name the DMGs well when you download them to avoid confusion. Here’s how to download it and rename it at the same time

Mount the DMG

Open the ‘~/Downloads/InstallElCapitan.dmg’

That will leave you with

“/Volumes/Install OS X/InstallMacOSX.pkg”

Extract the App

Don’t try to install from that .pkg file, it probably won’t work unless the Mac you’re using is capable of running El Capitan:

Instead, open it with Suspicious Package which will let you examine the contents of the .pkg file, as shown here:

Note the area in the red box. Obviously that’s not the full installer, despite the .dmg being over 6 GB. But let’s export it anyway:

Save it to /Applications/ (or wherever you prefer, but that’s where I’ll assume it is for the rest of these instructions).

Don’t eject “/Volumes/Install OS X/InstallMacOSX.pkg” yet, we still need to get the actual .dmg from it.

Get the other DMG

Download The Archive Browser if you don’t already have it (it’s free!) and use it to open “/Volumes/Install OS X/InstallMacOSX.pkg”.

It will look like this:

Click on the triangle to the left of “InstallMaxOSX.pkg” to reveal its contents, and select the “InstallESD.dmg” file from it.

Once it is selected, choose “Extract Selected” from the bottom-left. Save it to ~/Downloads/ (it won’t be staying there long).

From

Ok, this part could be confusing…

When The Archive Browser exports the file, it will not just export the “InstallESD.dmg” file. First it creates a folder “InstallMacOSX” and then it created “InstallMacOSX.pkg” inside that folder, and the “InstallESD.dmg” file is put inside the .pkg… but you can’t see it, because the .pkg file won’t let you open it.

That’s OK, because we’re going to use Terminal.app to move the file into place anyway.

First we need to create a directory inside the ‘Install OS X El Capitan.app’ which we previously saved to /Applications/. We’re going to use the same folder for two commands and we want to make sure we get it exactly right both times, so we’ll make it a variable:

Then use the variable with mkdir to create the folder:

and then we need to move the “InstallESD.dmg” file into that folder

Note: you probably want to trash the ‘~/Downloads/InstallMacOSX/InstallMacOSX.pkg’ (and its parent folder) now that it is empty, to avoid confusion later

Now if you look at the ‘Install OS X El Capitan.app’ in the Finder, it should show itself as 6.21 GB:

So close, and yet…

Make

VMWare was willing to start trying to make a virtual machine using the app, but it failed when it came to the actual installation part:

I don’t know what to try next. Parallels would not use either the ‘Install OS X El Capitan.app’ or the ‘InstallESD.dmg’ to try to create a new virtual machine.

Update and Solution

I posted a question on the VMware Fusion support forum asking how to do this, and someone came up with a very clever solution, which I will replicate here in case others are interested. The idea is simple, but I never would have thought of it.

  1. Create a virtual machine of any version of macOS, even the current version that you are using on your Mac.
  2. Inside the VM, download the .dmg (see below) and mount it.

  3. Launch the .pkg inside the .dmg.

  4. The .pkg seems to understand that it is inside a VM, and will install the app, which it would not do outside of the VM. Note that the Installer.app says that it will only take a few megabytes, but that is incorrect.

  5. Find the “Install OS X El Capitan.app” (or whatever the app name is) in the /Applications/ folder inside the VM. It should be over 6 GB in size.

  6. Copy the “Install….app” from the VM out to your actual Mac.

  7. Create a new VM using the “Install….app” from the /Applications/ folder on your Mac.

Step #4 is the part that I never would have guessed. The .pkg would not install the app outside of a VM, but will install it inside of a VM.

This worked perfectly with the El Capitan .dmg file, and I’m currently doing the same with Yosemite and Sierra. Then I’ll try the older versions of Mac OS X from old installers that I have from before they disappeared from Apple’s servers.

Update 2

Turns out that Rich Trouton wrote about this technique back in early 2017:

But I wasn’t working with VMs at the time, so I must not not stored that in my long-term memory.

Update 3

I had saved the older installers for Lion, Mountain Lion, and Mavericks, which are no longer available for download.

Each of them still installed as a VM. Apparently they were not signed with the certificates that expired.

Older versions of Mac OS X (10.6.8 and before) are not available to virtualize.

A package source allows you to view and edit attributes of a package (such as files, scripts, privileges, and localizations) before it is built. Once a package source exists for a group of files, you can make modifications and build the package as many times as necessary.

There are several ways to create a package source:

  • Take snapshots—Composer takes before and after snapshots of the file system and creates a package source based on the changes. This method allows you to monitor installations in all locations on the drive. If necessary, you can also quit Composer or log out/reboot during the installation process.

  • Monitor the file system—Composer uses the File System Events (FSEvents) framework to monitor any changes that are made to the file system during the installation process. Next, Composer creates a package source based on the changes. This method does not allow you to quit Composer or log in/reboot during the installation process. In addition, an excess of file system activity can cause FSEvents to miss changes.

  • Use pre-installed software—You can use software that is pre-installed on your computer to create a package source based on package manifests. This method allows you to create package sources without monitoring the installation process.

  • Use user environment settings—Package manifests can also be used to capture settings configured on your computer, such as Dashboard, Display, and Global Preference settings.

  • Drag contents from the Finder—A simple drag-and-drop process allows you to create a package source from files already installed on your computer.

  • Use an existing package—Composer allows you to make modifications to an existing package or convert between the PKG and DMG package formats.

If the files you want to package are not already installed on the drive, Composer can take a snapshot of the file system before and after the files have been installed and create a package source based on the changes.

Composer can take two kinds of snapshots:

  • Normal snapshots—These snapshots capture any new files on the drive. These snapshots can take anywhere from ten seconds to several minutes depending on your hardware and the number of files on the drive.

  • New and modified snapshots—These snapshots capture any new files on the drive, as well as any files that have been modified. These snapshots can take longer than normal snapshots, since Composer records the modifications date of each file while performing the snapshot.

There are several benefits to using the snapshot approach:

  • Composer monitors installations in all locations on the drive.

  • You can quit Composer during the installation process.

  • You can log out or reboot during the installation process.

  • If you delete a file while making modifications to a package source, it may be possible to restore the deleted file. For more information about restoring deleted files, see Adding Scripts to Package Sources.

  1. Open Composer and authenticate locally.

  2. In the toolbar, click New .

  3. Under the Monitor Installation heading in the sidebar, select Snapshot.

  4. Select Normal Snapshot or New & Modified Snapshot and click Next.

  5. Enter a name for the package and click Next.

  6. Install and configure your software, and then click Create Package Source to initiate the “after” snapshot.

When creating a package source using file system monitoring, Composer uses the File System Events (FSEvents) framework that is built into macOS to monitor any changes that are made to the file system. Each time a change is made, FSEvents receives a notification. After your software is installed, Composer analyzes the changes and creates a package source based on the results.

The following limitations should be taken into consideration when monitoring the file system to create a package source:

  • You cannot quit Composer during the installation process.

  • You cannot log in or restart during the installation process.

  • It is possible for FSEvents to miss events if there is too much file system activity.

  1. Open Composer and authenticate locally.

  2. In the toolbar, click New .

  3. Under the Monitor Installation heading in the sidebar, select Snapshot.

  4. Select Monitor File System Changes and click Next.

  5. Enter a name for the package and click Next.

  6. Install and configure your software, and then click Create Package Source.

You can create a package source from software that is currently installed on your computer if Composer contains a package manifest for the software.

Note: If there is software you would like added to the package manifest options in Composer, email your recommendations to diffs@jamf.com.

  1. Open Composer and authenticate locally.

  2. In the toolbar, click New .

  3. Under the Package Manifests heading in the sidebar, select Pre-Installed Software.
    Composer scans the file system and displays icons for the software it can package.

    Note: To view package manifests for software that is not installed on the computer, click the disclosure triangle next to Pre-Installed Software and select Not Installed.

  4. Select the items you want to create a package source from and click Next.

You can create a package source that captures the look and feel of your computer’s interface, such as Dashboard, Display, and Global Preference settings. If Composer contains a package manifest for the setting you want to capture, you can create a package source from it.

To determine which of your current settings Composer can package, select User Environment under the Package Manifests heading. Composer scans the file system and displays icons for the settings that it has package manifests for.

Note: If there is a setting you would like added to the package manifest options in Composer, email your recommendations to diffs@jamfsoftware.com.

  1. Open Composer and authenticate locally.

  2. In the toolbar, click New .

  3. Under the Package Manifests heading in the sidebar, select User Environment.

  4. Select the items you want to create a package source from and click Next.

If you already know which item you want to package, you can bypass the snapshot or monitoring process by dragging items from the Finder to the Sources list in Composer.

There are a few ways Composer handles these items:

How To Turn A Dmg Into A Pkg

  • If the item is a package (DMG, PKG, or MPKG), it is listed in the sidebar under the Packages heading.

  • If the item is a folder, the root of the folder is used as the root of the package if it is one of the following directories:
    /Applications/
    /Developer/
    /Library/
    /System/
    /Users/
    /bin/
    /private/
    /sbin/
    /usr/

  • Any other items are copied to their current location.

Make A Pkg From Dmg Converter

Note: This is the equivalent of a PreBuilt package in earlier versions of Composer.

Composer allows you to rebuild an existing package (PKG, DMG, or MPKG) by converting it to a package source. After converting it to a package source, you can make changes to its contents and save a new copy of the package.

  1. Open Composer and authenticate locally.

  2. Drag the package you want to convert from the Finder to the sidebar in Composer.
    The package appears under the Packages heading.

  3. Select the package and click Convert to Source.

    When the conversion is complete, a new package source is listed in the sidebar under the Sources heading.

For related information, see the following Jamf Knowledge Base video:

Make A Pkg From Dmg Software

For related information, see the following sections in this guide:

Make A Pkg From Dmg File

  • Package Manifests
    Find out how to create package manifests, update the package manifests available, and import package manifests.

  • Building Packages from Package Sources
    Find out how to build a PKG or DMG from a package source.