Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script will print the build numbers of the macOS version from all installer apps
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
installerBuildVersion() { # $1 path to the installer app
installerApp=${1:?"no path for installer"}
# echo "inspecting: $installerApp"
if [[ -d "$installerApp" ]]; then
identifier=$(/usr/libexec/PlistBuddy -c "print CFBundleIdentifier" "$installerApp/Contents/Info.plist")
if [[ "$identifier" == com.apple.InstallAssistant.* ]]; then
systemdmg="$installerApp"/Contents/SharedSupport/BaseSystem.dmg
if [[ -e "$systemdmg" ]]; then
installdisk=$(hdiutil attach "$installerApp"/Contents/SharedSupport/BaseSystem.dmg -noverify -nobrowse -readonly | tail -n 1 | cut -c 54- )
installerBuild=$(/usr/libexec/PlistBuddy -c "print :ProductBuildVersion" "$installdisk"/System/Library/CoreServices/SystemVersion.plist)
installerVersion=$(/usr/libexec/PlistBuddy -c "print :ProductVersion" "$installdisk"/System/Library/CoreServices/SystemVersion.plist)
echo "$installerApp : $installerVersion $installerBuild"
hdiutil detach "$installdisk" >/dev/null
else
echo "couldn't find system.dmg in installer $installerApp"
exit 2
fi
else
echo "no installer app"
exit 3
fi
fi
}
while read -r x; do
installerBuildVersion "$x"
done < <(mdfind "kMDItemCFBundleIdentifier == 'com.apple.InstallAssistant.*'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.