kc9wwh / macOSUpgrade

Workflow for doing in-place upgrades.
Other
418 stars 103 forks source link

Catalina changes diskinfo again. Suggested fix included. #130

Open FyrbyAdditive opened 4 years ago

FyrbyAdditive commented 4 years ago
## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
## 10.15 or later changes it to 'APFSContainerFree'

os_ver=$(sw_vers -productVersion)
IFS='.' read -r -a ver <<< "$os_ver"

if [[ "${ver[1]}" -ge 15 ]]; then
        # Is 10.15 or newer
        di_check="APFSContainerFree"
elif [[ "${ver[1]}" -ge 13 ]] && [[ "${ver[2]}" -ge 4 ]]; the
        # Is 10.13.4 - 10.14.latest
        di_check="FreeSpace"
else
        # Is a blatant security risk
        di_check="AvailableSpace"
fi

diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
freeSpace=$(
        /usr/libexec/PlistBuddy -c "Print :${di_check}" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
)
kenchan0130 commented 4 years ago

@timtimellis Thank you for you feedback. I'll update our script after this weekend. Please wait for a little while longer.

ckostovny commented 4 years ago

This logic didn't seem to work for me on 10.14-- and testing the logic with 10.14.1-10.14.3 as os_ver all result in report of null Freespace, as they're falling into the else statement and checking the plist for "AvailableSpace".

if [[ "${ver[1]}" -ge 15 ]]; then
        # Is 10.15 or newer
        di_check="APFSContainerFree"
elif [[ "${ver[1]}" -eq 14 ]]; then
        # Is 10.14.x
        di_check="FreeSpace"
elif [[ "${ver[1]}" -eq 13 ]] && [[ "${ver[2]}" -ge 4 ]]; then
        # Is 10.13.4 - 10.13.6
        di_check="FreeSpace"
else
        # Is a blatant security risk
        di_check="AvailableSpace"
fi

This appears to work correctly for the above versions, perhaps this will help others.

marckerr commented 4 years ago

I'll confirm I've used the noted modifications for upgrading from Mojave to Catalina as well as erase install over Mojave and Catalina.

ckostovny commented 4 years ago

This logic didn't seem to work for me on 10.14-- and testing the logic with 10.14.1-10.14.3 as os_ver all result in report of null Freespace, as they're falling into the else statement and checking the plist for "AvailableSpace".

if [[ "${ver[1]}" -ge 15 ]]; then
      # Is 10.15 or newer
      di_check="APFSContainerFree"
elif [[ "${ver[1]}" -eq 14 ]]; then
      # Is 10.14.x
      di_check="FreeSpace"
elif [[ "${ver[1]}" -eq 13 ]] && [[ "${ver[2]}" -ge 4 ]]; then
      # Is 10.13.4 - 10.13.6
      di_check="FreeSpace"
else
      # Is a blatant security risk
      di_check="AvailableSpace"
fi

This appears to work correctly for the above versions, perhaps this will help others.

The di_check for older than 10.13.4 isn't working for me with 10.12.6-- I ended up changing the else statement to use di_check="FreeSpace" and I was able to upgrade 10.12.6 successfully. I don't have anything older to test on, nor a 10.13.3--- is the di_check="AvailableSpace" actually needed?

nc-keopraseuths commented 4 years ago
## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
## 10.15 or later changes it to 'APFSContainerFree'

os_ver=$(sw_vers -productVersion)
IFS='.' read -r -a ver <<< "$os_ver"

if [[ "${ver[1]}" -ge 15 ]]; then
        # Is 10.15 or newer
        di_check="APFSContainerFree"
elif [[ "${ver[1]}" -ge 13 ]] && [[ "${ver[2]}" -ge 4 ]]; the
        # Is 10.13.4 - 10.14.latest
        di_check="FreeSpace"
else
        # Is a blatant security risk
        di_check="AvailableSpace"
fi

diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
freeSpace=$(
        /usr/libexec/PlistBuddy -c "Print :${di_check}" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
)

This is missing the letter 'n' for the elif statement for 'then'. If anyone else is having trouble.