When working on the macOS version of a new product, our development team was looking for a solution that would allow them to create custom DMG installers for each client. Since the product’s API is based on Microsoft Azure Service Fabric, and there are no Windows-based tools that would meet the criteria for API compatibility and scalability, our team decided to look elsewhere. And here’s where a Linux-based solution came to help.
If you’re looking for a similar tool, follow the steps below to build custom DMG installer files on Linux.
- Download the libdmg-hfsplus repository, which includes a number of portable libraries and utilities that manipulate the HFS+ file system and DMG images. Note that the code is still in its experimental stage, so it doesn’t contain any utility that allows building Apple’s DMG images from scratch.
- To build the disk image utility, run the following sequence of commands on Ubuntu version 16.04 or higher:
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install cmake
sudo apt-get install zlib1g-dev
sudo apt-get install genisoimage
git clone https://github.com/hamstergene/libdmg-hfsplus.git
cd libdmg-hfsplus
cmake .
make
mkdir bin
cp dmg/dmg ./bin - To create a request for generating a new DMG file, use the microsoft/aspnetcore:2.0 docker image and install genisoimage with the DMG utility copied onto it:
FROM microsoft/aspnetcore:2.0
COPY . /server # Contains all necessary scripts along with the DMG utility
ADD dmg /
WORKDIR /server
RUN \
apt-get update && \
apt-get -y install genisoimage - As soon as the service receives the request for generating a new DMG image, it will run the following bash script to add unique content to the client bundle, build a custom IMG image, and convert it into a DMG image with the help of the utility created in step 2:
# Adds a unique ID to the client bundle
(echo "-p $clientID" > original/AppName.app/Contents/Resources/args) && \
# Generates IMG disk image with the help of genisoimage
genisoimage -D -V "SetMeitClient" -no-pad -r -apple -file-mode 0777 -o generated.img original && \
# Converts IMG into DMG ($dmgPath is the path that points to the DMG utility)
$dmgPath dmg generated.img generated.dmg
This workaround will allow you to create custom DMG installer files containing unique information for each end-user.
Did you find this post helpful? Subscribe to our blog and join us on Facebook, Twitter, YouTube or LinkedIn for more tips and useful how-to’s.