Skip to content

Instantly share code, notes, and snippets.

@scriptingosx
Created March 28, 2019 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptingosx/ccef69a0ba2bae39a75494a19215afca to your computer and use it in GitHub Desktop.
Save scriptingosx/ccef69a0ba2bae39a75494a19215afca to your computer and use it in GitHub Desktop.
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