Skip to content

Instantly share code, notes, and snippets.

@erikng
Created September 12, 2017 15:56
Show Gist options
  • Save erikng/1084ecea1fffab712073a3b327f4b961 to your computer and use it in GitHub Desktop.
Save erikng/1084ecea1fffab712073a3b327f4b961 to your computer and use it in GitHub Desktop.
make_firmware_updater_pkg.sh
#!/bin/sh
# Based on investigations and work by Pepijn Bruienne
# Expects a single /Applications/Install macOS Sierra*.app on disk
# Adapted from https://gist.github.com/gregneagle/7c802aef636ac4295536f2e360921bb1
IDENTIFIER="com.foo.FirmwareUpdateStandalone"
VERSION=1.0
# find the Install macOS Sierra.app and mount the embedded InstallESD disk image
echo "Mounting Sierra ESD disk image..."
/usr/bin/hdiutil mount /Applications/Install\ macOS\ Sierra*.app/Contents/SharedSupport/InstallESD.dmg
# expand the FirmwareUpdate.pkg so we can copy resources from it
echo "Expanding FirmwareUpdate.pkg"
/usr/sbin/pkgutil --expand /Volumes/OS\ X\ Install\ ESD/Packages/FirmwareUpdate.pkg /tmp/FirmwareUpdate
# we don't need the disk image any more
echo "Ejecting disk image..."
/usr/bin/hdiutil eject /Volumes/OS\ X\ Install\ ESD
# make a place to stage our pkg resources
/bin/mkdir -p /tmp/FirmwareUpdateStandalone/scripts
# copy the needed resources
echo "Copying package resources..."
/bin/cp /tmp/FirmwareUpdate/Scripts/postinstall_actions/update /tmp/FirmwareUpdateStandalone/scripts/postinstall
/bin/cp -R /tmp/FirmwareUpdate/Scripts/Tools /tmp/FirmwareUpdateStandalone/scripts/
# build the package
echo "Building standalone package..."
/usr/bin/pkgbuild --nopayload --scripts /tmp/FirmwareUpdateStandalone/scripts --identifier "$IDENTIFIER" --version "$VERSION" /tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg
# clean up
/bin/rm -r /tmp/FirmwareUpdate
/bin/rm -r /tmp/FirmwareUpdateStandalone/scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment