mirror of
https://github.com/munki/munki.git
synced 2026-05-04 11:29:16 -05:00
Fix for deprecation messages new in macOS 14.4 that corrupt installer output
This commit is contained in:
@@ -42,6 +42,7 @@ from .. import munkistatus
|
||||
from .. import osutils
|
||||
from .. import processes
|
||||
from .. import pkgutils
|
||||
from .. import utils
|
||||
from .. import FoundationPlist
|
||||
|
||||
|
||||
@@ -82,7 +83,7 @@ def remove_bundle_relocation_info(pkgpath):
|
||||
def pkg_needs_restart(pkgpath, options):
|
||||
'''Query a package for its RestartAction. Returns True if a restart is
|
||||
needed, False otherwise'''
|
||||
cmd = ['/usr/sbin/installer', '-query', 'RestartAction', '-pkg', pkgpath]
|
||||
cmd = ['/usr/sbin/installer', '-query', 'RestartAction', '-pkg', pkgpath, '-plist']
|
||||
if options.get('installer_choices_xml'):
|
||||
choices_xml_file = os.path.join(osutils.tmpdir(), 'choices.xml')
|
||||
FoundationPlist.writePlist(
|
||||
@@ -95,8 +96,14 @@ def pkg_needs_restart(pkgpath, options):
|
||||
proc = subprocess.Popen(cmd, shell=False, bufsize=-1,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output = proc.communicate()[0].decode('UTF-8')
|
||||
restartaction = output.rstrip('\n')
|
||||
output = proc.communicate()[0]
|
||||
# need to use getFirstPlist because in 14.4 Apple broke the output by
|
||||
# printing deprecation warnings to STDOUT
|
||||
pliststr, _ = utils.getFirstPlist(output)
|
||||
restartaction = ''
|
||||
if pliststr:
|
||||
plist = FoundationPlist.readPlistFromString(pliststr)
|
||||
restartaction = plist.get('RestartAction', '')
|
||||
return restartaction in ['RequireRestart', 'RecommendRestart']
|
||||
|
||||
|
||||
|
||||
@@ -61,21 +61,25 @@ def getPkgRestartInfo(filename):
|
||||
installerinfo = {}
|
||||
proc = subprocess.Popen(['/usr/sbin/installer',
|
||||
'-query', 'RestartAction',
|
||||
'-pkg', filename],
|
||||
'-pkg', filename,
|
||||
'-plist'],
|
||||
bufsize=-1,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate()
|
||||
out = out.decode('UTF-8')
|
||||
err = err.decode('UTF-8')
|
||||
if proc.returncode:
|
||||
display.display_error("installer -query failed: %s %s", out, err)
|
||||
display.display_error("installer -query failed: %s %s",
|
||||
out.decode("UTF-8"), err.decode("UTF-8"))
|
||||
return {}
|
||||
|
||||
if out:
|
||||
restartAction = out.rstrip('\n')
|
||||
if restartAction != 'None':
|
||||
installerinfo['RestartAction'] = restartAction
|
||||
# have to use getFirstPlist since in macOS 14.4 Apple prints
|
||||
# a deprecation warning to STDOUT before the actual plist
|
||||
pliststr, _ = utils.getFirstPlist(out)
|
||||
if pliststr:
|
||||
plist = FoundationPlist.readPlistFromString(pliststr)
|
||||
if plist.get('RestartAction') != 'None':
|
||||
installerinfo['RestartAction'] = plist['RestartAction']
|
||||
|
||||
return installerinfo
|
||||
|
||||
@@ -824,12 +828,16 @@ def getChoiceChangesXML(pkgitem):
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out = proc.communicate()[0]
|
||||
if out:
|
||||
plist = FoundationPlist.readPlistFromString(out)
|
||||
# have to use getFirstPlist now because in macOS 14.4 Apple
|
||||
# print deprecation warnings to STDOUT before the plist :-(
|
||||
pliststr, _ = utils.getFirstPlist(out)
|
||||
if pliststr:
|
||||
plist = FoundationPlist.readPlistFromString(pliststr)
|
||||
|
||||
# list comprehension to populate choices with those items
|
||||
# whose 'choiceAttribute' value is 'selected'
|
||||
choices = [item for item in plist
|
||||
if 'selected' in item['choiceAttribute']]
|
||||
# list comprehension to populate choices with those items
|
||||
# whose 'choiceAttribute' value is 'selected'
|
||||
choices = [item for item in plist
|
||||
if 'selected' in item['choiceAttribute']]
|
||||
except Exception:
|
||||
# No choices found or something went wrong
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user