mirror of
https://github.com/munki/munki.git
synced 2026-05-07 12:59:32 -05:00
Improved OS version comparisons taking into account new (Big Sur+) versioning 'style'
This commit is contained in:
@@ -95,8 +95,8 @@ DEFAULT_CATALOG_URLS = {
|
||||
'index-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-'
|
||||
'mountainlion-lion-snowleopard-leopard.merged-1.sucatalog'),
|
||||
'11': ('https://swscan.apple.com/content/catalogs/others/'
|
||||
'index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-'
|
||||
'mountainlion-lion-snowleopard-leopard.merged-1.sucatalog'),
|
||||
'index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-'
|
||||
'mountainlion-lion-snowleopard-leopard.merged-1.sucatalog'),
|
||||
}
|
||||
|
||||
# Preference domain for Apple Software Update.
|
||||
@@ -214,11 +214,6 @@ class AppleUpdateSync(object):
|
||||
# Finally, fall back to using a hard-coded url in DEFAULT_CATALOG_URLS.
|
||||
os_version = osutils.getOsVersion()
|
||||
catalog_url = DEFAULT_CATALOG_URLS.get(os_version, None)
|
||||
if catalog_url:
|
||||
return catalog_url
|
||||
# didn't find a catalog, try only major os version (as in '11'):
|
||||
os_version = os_version.split('.')[0]
|
||||
catalog_url = DEFAULT_CATALOG_URLS.get(os_version, None)
|
||||
if catalog_url:
|
||||
return catalog_url
|
||||
|
||||
|
||||
@@ -64,7 +64,12 @@ def getOsVersion(only_major_minor=True, as_tuple=False):
|
||||
except subprocess.CalledProcessError:
|
||||
os_version_tuple = platform.mac_ver()[0].split(".")
|
||||
if only_major_minor:
|
||||
os_version_tuple = os_version_tuple[0:2]
|
||||
if int(os_version_tuple[0]) > 10:
|
||||
# return something like (11,)
|
||||
os_version_tuple = (os_version_tuple[0],)
|
||||
else:
|
||||
# return something like (10,15)
|
||||
os_version_tuple = os_version_tuple[0:2]
|
||||
if as_tuple:
|
||||
return tuple(map(int, os_version_tuple))
|
||||
# default
|
||||
|
||||
@@ -84,8 +84,12 @@ def installed_state(item_pl):
|
||||
if item_pl.get('installer_type') == 'startosinstall':
|
||||
current_os_vers = osutils.getOsVersion()
|
||||
item_os_vers = item_pl.get('version')
|
||||
# need just major.minor part of the version -- 10.12 and not 10.12.4
|
||||
item_os_vers = '.'.join(item_os_vers.split('.')[0:2])
|
||||
if int(item_os_vers.split('.')[0]) > 10:
|
||||
# if we're running Big Sur+, we just want the major (11)
|
||||
item_os_vers = item_os_vers.split('.')[0]
|
||||
else:
|
||||
# need just major.minor part of the version -- 10.12 and not 10.12.4
|
||||
item_os_vers = '.'.join(item_os_vers.split('.')[0:2])
|
||||
comparison = compare.compare_versions(current_os_vers, item_os_vers)
|
||||
if comparison == compare.VERSION_IS_LOWER:
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user