Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit 3901ca4

Browse files
committed
add sub version support to nudge
1 parent 157687c commit 3901ca4

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The following operating system and versions have been tested.
3030
- 10.11.0, 10.11.6
3131
- 10.12.0, 10.12.6
3232
- 10.13.0 10.13.3, 10.13.6
33-
- 10.14.0
33+
- 10.14 -> 10.14.6
3434

3535
## Configuration File
3636
Essentially every component of the UI is customizable, all through a JSON configuration file. An [example file](/example_config.json) is available within the code repository.
@@ -112,6 +112,13 @@ This is the minimum OS version a machine must be on to not receive this UI.
112112
"minimum_os_version": "10.13.6"
113113
```
114114

115+
### Minimum OS Sub Version
116+
117+
This is the minimum OS version a machine must be on to not receive this UI.
118+
```json
119+
"minimum_os_sub_build_version": "18G103"
120+
```
121+
115122
### More info URL
116123
This is the URL to open when the **More Info** button is clicked.
117124
```json

payload/Library/Application Support/nudge/Resources/nudge

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ def get_console_username_info():
120120
return SCDynamicStoreCopyConsoleUser(None, None, None)
121121

122122

123+
def get_os_sub_build_version():
124+
'''Return sub build of macOS'''
125+
cmd = ['/usr/sbin/sysctl', '-n', 'kern.osversion']
126+
run = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
127+
output, err = run.communicate()
128+
return LooseVersion(output.strip())
129+
130+
123131
def get_os_version():
124132
'''Return OS version.'''
125133
return LooseVersion(platform.mac_ver()[0])
@@ -343,10 +351,6 @@ def main():
343351
print(err)
344352
shutil.rmtree(tmp_dir)
345353
exit(1)
346-
except urllib2.HTTPError, err:
347-
print(err)
348-
shutil.rmtree(tmp_dir)
349-
exit(1)
350354
else:
351355
# If the file doesn't exist, grab it and wait half a second to save.
352356
while not os.path.isfile(json_path):
@@ -380,7 +384,8 @@ def main():
380384
main_subtitle_text = nudge_prefs.get('main_subtitle_text',
381385
'A friendly reminder from your local IT team')
382386
main_title_text = nudge_prefs.get('main_title_text', 'macOS Update')
383-
minimum_os_version = nudge_prefs.get('minimum_os_version', '10.14.0')
387+
minimum_os_sub_build_version = nudge_prefs.get('minimum_os_sub_build_version', '18G84')
388+
minimum_os_version = nudge_prefs.get('minimum_os_version', '10.14.6')
384389
minimum_os_version_major = minimum_os_version.rsplit('.', 1)[0]
385390
MORE_INFO_URL = nudge_prefs.get('more_info_url', False)
386391
no_timer = nudge_prefs.get('no_timer', False)
@@ -408,6 +413,8 @@ def main():
408413

409414
# Start information
410415
print 'Target OS version: %s ' % minimum_os_version
416+
if update_minor:
417+
print 'Target OS subversion: %s' % minimum_os_sub_build_version
411418

412419
# cleanup the tmp stuff now
413420
if cleanup:
@@ -424,19 +431,31 @@ def main():
424431
if '.' not in minimum_os_version_major:
425432
minimum_os_version_major = minimum_os_version
426433

427-
if get_os_version() >= LooseVersion(minimum_os_version):
428-
print 'OS version is higher or equal to the minimum threshold: %s' % str(get_os_version())
434+
os_version = get_os_version()
435+
os_version_major = get_os_version_major()
436+
os_version_sub_build = get_os_sub_build_version()
437+
438+
# Example 10.14.6 (18G103) >= 10.14.6 (18G84)
439+
if os_version_sub_build >= LooseVersion(minimum_os_sub_build_version):
440+
print 'OS version sub build is higher or equal to the minimum threshold: %s' % str(os_version_sub_build)
441+
exit(0)
442+
# Example: 10.14.6 >= 10.14.6
443+
elif os_version >= LooseVersion(minimum_os_version) and not update_minor:
444+
print 'OS version is higher or equal to the minimum threshold: %s' % str(os_version)
429445
exit(0)
430-
elif get_os_version_major() >= LooseVersion(minimum_os_version_major) and not update_minor:
431-
print 'OS major version is higher or equal to the minimum threshold and minor updates not enabled: %s ' % str(get_os_version())
446+
# Example: 10.14/10.14.0 >= 10.14
447+
elif os_version_major >= LooseVersion(minimum_os_version_major) and not update_minor:
448+
print 'OS major version is higher or equal to the minimum threshold and minor updates not enabled: %s ' % str(os_version)
432449
exit(0)
433450
else:
434-
print 'OS version is below the minimum threshold: %s' % str(get_os_version())
451+
print 'OS version is below the minimum threshold: %s' % str(os_version)
452+
if update_minor and LooseVersion(minimum_os_sub_build_version) > os_version_sub_build:
453+
print 'OS version is below the minimum threshold subversion: %s' % str(os_version_sub_build)
435454

436455
minor_updates_required = False
437456

438457
# Start main logic on major and minor upgrades
439-
if LooseVersion(minimum_os_version_major) > get_os_version_major():
458+
if LooseVersion(minimum_os_version_major) > os_version_major:
440459
# This is a major upgrade now and needs the app. We shouldn't
441460
# perform minor updates.
442461
if LOCAL_URL_FOR_UPGRADE:

0 commit comments

Comments
 (0)