-
Notifications
You must be signed in to change notification settings - Fork 114
How Does AutoDMG Work
This page serves to document the inner workings of AutoDMG, and will be expanded as needed.
At the core of AutoDMG is a shell script called installesdtodmg.sh. If you strip away the sanity checks, error handling, and progress reports, you end up with the equivalent of the following commands:
# Mount the install media.
hdiutil attach -noverify -mountpoint /tmp/installesd /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg
# Create a sparse read/write disk image.
hdiutil create -size 32g -type SPARSE -fs HFS+J -volname "Macintosh HD" -uid 0 -gid 80 -mode 1775 /tmp/output.sparseimage
# Attach it.
hdiutil attach -noverify -mountpoint /tmp/os -owners on /tmp/output.sparseimage
# Install the OS.
installer -pkg /tmp/installesd/Packages/OSInstall.mpkg -target /tmp/os
# Detach the images.
hdiutil detach /tmp/os
hdiutil detach /tmp/installesd
# Convert the image to read only.
hdiutil convert -format UDZO /tmp/output.sparseimage -o output.dmg
# Scan the image for restore. (Not actually in installesdtodmg.sh!)
asr imagescan --source /tmp/output.dmg
AutoDMG is written in Python with PyObjC, and is developed in Xcode.
There are two core classes in AutoDMG:
This is the controller class for the main window, and is the root of all interaction with the user.
The workflow is the meat of the application. It's responsible for setting up and executing the steps needed to create an image.
This script performs the main steps needed to create a deployment image:
- Create a new read/write sparse disk image.
- Install a list of packages, starting with the OS install, with the sparse image as the target.
- Convert the sparse disk to a read only compressed image.
This is a python script that executes the helper processes, captures their output, and sends it back to the main user interface.
Upon startup the application creates a unix domain datagram socket, and starts listening for packets. When progresswatcher.py has a message for the UI it encapsulates it in a binary plist and writes it to the socket. The listener decodes it and acts according to the "action" key.