kc9wwh / macOSUpgrade

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

macOS11.1 Version Fix #163

Closed kc9wwh closed 3 years ago

kc9wwh commented 3 years ago

Per issue #162 as well as some cases that came in today. macOS Big Sur 11.1 version breaks this workflow since $installerVersion_Full_Integer would end up with 1101 and be -lt 110000 causing the incorrect plist to be used for version checking.

Added the below atline 70

[ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00

Please review and let me know your thoughts. There are certainly better ways to do this with zsh so we may end up needing to go that direction soon.

kc9wwh commented 3 years ago

Variable Results

bash-3.2$ installerVersion="10.13.4"
bash-3.2$ installerVersion_Full_Integer=$(/bin/echo "$installerVersion" | /usr/bin/awk -F. '{for(i=1; i<=NF; i++) {printf("%02d",$i)}}')
bash-3.2$ echo $installerVersion_Full_Integer 
101304
bash-3.2$ [ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00
bash-3.2$ echo $installerVersion_Full_Integer 
101304
bash-3.2$ installerVersion="10.15.6"
bash-3.2$ installerVersion_Full_Integer=$(/bin/echo "$installerVersion" | /usr/bin/awk -F. '{for(i=1; i<=NF; i++) {printf("%02d",$i)}}')
bash-3.2$ echo $installerVersion_Full_Integer 
101506
bash-3.2$ [ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00
bash-3.2$ echo $installerVersion_Full_Integer 
101506
bash-3.2$ installerVersion="11.0.1"
bash-3.2$ installerVersion_Full_Integer=$(/bin/echo "$installerVersion" | /usr/bin/awk -F. '{for(i=1; i<=NF; i++) {printf("%02d",$i)}}')
bash-3.2$ echo $installerVersion_Full_Integer 
110001
bash-3.2$ [ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00
bash-3.2$ echo $installerVersion_Full_Integer 
110001
bash-3.2$ installerVersion="11.0"
bash-3.2$ installerVersion_Full_Integer=$(/bin/echo "$installerVersion" | /usr/bin/awk -F. '{for(i=1; i<=NF; i++) {printf("%02d",$i)}}')
bash-3.2$ echo $installerVersion_Full_Integer 
1100
bash-3.2$ [ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00
bash-3.2$ echo $installerVersion_Full_Integer 
110000
bash-3.2$ installerVersion="11.1"
bash-3.2$ installerVersion_Full_Integer=$(/bin/echo "$installerVersion" | /usr/bin/awk -F. '{for(i=1; i<=NF; i++) {printf("%02d",$i)}}')
bash-3.2$ echo $installerVersion_Full_Integer 
1101
bash-3.2$ [ "${#installerVersion_Full_Integer}" -lt 6 ] && installerVersion_Full_Integer="$installerVersion_Full_Integer"00
bash-3.2$ echo $installerVersion_Full_Integer 
110100
taniguti commented 3 years ago

How about this; installerVersion_Full_Integer="$( /bin/echo "$installerVersion" | /usr/bin/awk -F. '{ print ($1 * 10 ** 4 + $2 * 10 ** 2 + $3 )}' )"

No line increased.

hoi@hansha:git/macOSUpgrade[1894]% cat /tmp/chk
#!/bin/bash

for n in 10.14.6 10.15 11.0.1 11.1 11
do
    installerVersion="$n"
    installerVersion_Full_Integer="$( /bin/echo "$installerVersion" | /usr/bin/awk -F. '{ print ($1 * 10 ** 4 + $2 * 10 ** 2 + $3 )}' )"

    echo "installerVersion=$n"
    echo "installerVersion_Full_Integer=$installerVersion_Full_Integer"
    echo ""
done
hoi@hansha:git/macOSUpgrade[1895]% bash /tmp/chk
installerVersion=10.14.6
installerVersion_Full_Integer=101406

installerVersion=10.15
installerVersion_Full_Integer=101500

installerVersion=11.0.1
installerVersion_Full_Integer=110001

installerVersion=11.1
installerVersion_Full_Integer=110100

installerVersion=11
installerVersion_Full_Integer=110000

hoi@hansha:git/macOSUpgrade[1896]%
kc9wwh commented 3 years ago

Tests

macOS 10.14 to 11.1 Upgrade - PASSED

[STEP 1 of 5]
--
Executing Policy macOSUpgrade - Big Sur 11.1
[STEP 2 of 5]
Mounting samba.support.jamf.net (vssEAU)
Verifying package integrity...
Installing Install macOS Big Sur (11.1).dmg...
Closing package...
[STEP 3 of 5]
Running script macOSUpgrade.sh...
Script exit code: 0
Script result: installerVersion 11.1
installerVersion_Full_Integer 110100
installerVersion_Major_Integer 1101
Killing caffeinate processes.
No matching processes were found
Killing startosinstall processes.
No matching processes were found
Killing osinstallersetupd processes.
No matching processes were found
Power Check: OK - AC Power Detected
Disk Check: OK - 79371965584 Bytes Free Space Detected
Installer check: Target version is ok (11.1).
Installer check: DMG file is Valid
Installer check: PASSED
Launching jamfHelper as Utility Window.
Running a command as '"/Applications/Install macOS Big Sur.app/Contents/Resources/startosinstall" --agreetolicense --nointeraction --pidtosignal 1322 --forcequitapps >> /var/log/startosinstall.log 2>&1 &'...
[STEP 4 of 5]
[STEP 5 of 5]
Unmounting file server...

macOS 10.15 to 11.1 Upgrade - PASSED

[STEP 1 of 5]
--
Executing Policy macOSUpgrade - Big Sur 11.1
[STEP 2 of 5]
Mounting samba.support.jamf.net (vssEAU)
Verifying package integrity...
Installing Install macOS Big Sur (11.1).dmg...
Closing package...
[STEP 3 of 5]
Running script macOSUpgrade.sh...
Script exit code: 0
Script result: installerVersion 11.1
installerVersion_Full_Integer 110100
installerVersion_Major_Integer 1101
Killing caffeinate processes.
No matching processes were found
Killing startosinstall processes.
No matching processes were found
Killing osinstallersetupd processes.
No matching processes were found
Power Check: OK - AC Power Detected
Disk Check: OK - 65731724432 Bytes Free Space Detected
Installer check: Target version is ok (11.1).
Installer check: DMG file is Valid
Installer check: PASSED
Launching jamfHelper as Utility Window.
Running a command as '"/Applications/Install macOS Big Sur.app/Contents/Resources/startosinstall" --agreetolicense --nointeraction --pidtosignal 1299 --forcequitapps >> /var/log/startosinstall.log 2>&1 &'...
[STEP 4 of 5]
[STEP 5 of 5]
Unmounting file server...

macOS 11.0 to 11.1 Upgrade - PASSED

[STEP 1 of 5]
--
Executing Policy macOSUpgrade - Big Sur 11.1
[STEP 2 of 5]
Mounting samba.support.jamf.net (vssEAU)
Verifying package integrity...
Installing Install macOS Big Sur (11.1).dmg...
Closing package...
[STEP 3 of 5]
Running script macOSUpgrade.sh...
Script exit code: 0
Script result: installerVersion 11.1
installerVersion_Full_Integer 110100
installerVersion_Major_Integer 1101
Killing caffeinate processes.
No matching processes were found
Killing startosinstall processes.
No matching processes were found
Killing osinstallersetupd processes.
No matching processes were found
Power Check: OK - AC Power Detected
Disk Check: OK - 54960903312 Bytes Free Space Detected
Installer check: Target version is ok (11.1).
Installer check: DMG file is Valid
Installer check: PASSED
Launching jamfHelper as Utility Window.
Running a command as '"/Applications/Install macOS Big Sur.app/Contents/Resources/startosinstall" --agreetolicense --nointeraction --pidtosignal 2171 --forcequitapps >> /var/log/startosinstall.log 2>&1 &'...
[STEP 4 of 5]
[STEP 5 of 5]
Unmounting file server...