Created
March 28, 2019 14:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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