mirror of
https://github.com/munki/munki.git
synced 2026-01-26 08:59:17 -06:00
Merge branch 'master' into curl-refactor
This commit is contained in:
@@ -148,7 +148,8 @@ def runScript(script, display_name, runtype):
|
||||
script file are weaker than the current executable."""
|
||||
result = 0
|
||||
if os.path.exists(script):
|
||||
munkicommon.display_status('Performing %s tasks...' % display_name)
|
||||
munkicommon.display_status_minor(
|
||||
'Performing %s tasks...' % display_name)
|
||||
else:
|
||||
return result
|
||||
|
||||
@@ -461,7 +462,7 @@ def main():
|
||||
# we'll attempt to wait up to 10 seconds for the
|
||||
# network interfaces to come up
|
||||
# before continuing
|
||||
munkicommon.display_status('Waiting for network...')
|
||||
munkicommon.display_status_minor('Waiting for network...')
|
||||
for i in range(5):
|
||||
if networkUp():
|
||||
break
|
||||
|
||||
@@ -500,11 +500,12 @@ def runAdobeInstallTool(cmd, number_of_payloads=0, killAdobeAIR=False):
|
||||
else:
|
||||
payloadinfo = ""
|
||||
if number_of_payloads:
|
||||
|
||||
munkicommon.display_status("Completed payload %s of %s%s" %
|
||||
(payload_completed_count, number_of_payloads, payloadinfo))
|
||||
munkicommon.display_status_minor(
|
||||
'Completed payload %s of %s%s' %
|
||||
(payload_completed_count, number_of_payloads,
|
||||
payloadinfo))
|
||||
else:
|
||||
munkicommon.display_status("Completed payload %s%s" %
|
||||
munkicommon.display_status_minor('Completed payload %s%s' %
|
||||
(payload_completed_count, payloadinfo))
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(getPercent(payload_completed_count,
|
||||
@@ -542,7 +543,7 @@ def runAdobeInstallTool(cmd, number_of_payloads=0, killAdobeAIR=False):
|
||||
else:
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(100)
|
||||
munkicommon.display_status("Done.")
|
||||
munkicommon.display_status_minor('Done.')
|
||||
|
||||
return retcode
|
||||
|
||||
@@ -550,8 +551,8 @@ def runAdobeInstallTool(cmd, number_of_payloads=0, killAdobeAIR=False):
|
||||
def runAdobeSetup(dmgpath, uninstalling=False):
|
||||
'''Runs the Adobe setup tool in silent mode from
|
||||
an Adobe update DMG or an Adobe CS3 install DMG'''
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = mountAdobeDmg(dmgpath)
|
||||
if mountpoints:
|
||||
setup_path = findSetupApp(mountpoints[0])
|
||||
@@ -579,7 +580,7 @@ def runAdobeSetup(dmgpath, uninstalling=False):
|
||||
# try to find and count the number of payloads
|
||||
# so we can give a rough progress indicator
|
||||
number_of_payloads = countPayloads(mountpoints[0])
|
||||
munkicommon.display_status("Running Adobe Setup")
|
||||
munkicommon.display_status_minor('Running Adobe Setup')
|
||||
adobe_setup = [ setup_path, '--mode=silent',
|
||||
'--skipProcessCheck=1' ]
|
||||
if deploymentfile:
|
||||
@@ -589,14 +590,14 @@ def runAdobeSetup(dmgpath, uninstalling=False):
|
||||
|
||||
else:
|
||||
munkicommon.display_error(
|
||||
"%s doesn't appear to contain Adobe Setup." %
|
||||
os.path.basename(dmgpath))
|
||||
'%s doesn\'t appear to contain Adobe Setup.' %
|
||||
os.path.basename(dmgpath))
|
||||
retcode = -1
|
||||
|
||||
munkicommon.unmountdmg(mountpoints[0])
|
||||
return retcode
|
||||
else:
|
||||
munkicommon.display_error("No mountable filesystems on %s" % dmgpath)
|
||||
munkicommon.display_error('No mountable filesystems on %s' % dmgpath)
|
||||
return -1
|
||||
|
||||
|
||||
@@ -635,15 +636,15 @@ def doAdobeCS5Uninstall(adobeInstallInfo):
|
||||
'--action=uninstall',
|
||||
'--skipProcessCheck=1',
|
||||
'--deploymentFile=%s' % deploymentFile ]
|
||||
munkicommon.display_status("Running Adobe Uninstall")
|
||||
munkicommon.display_status_minor('Running Adobe Uninstall')
|
||||
return runAdobeInstallTool(uninstall_cmd, payloadcount)
|
||||
|
||||
|
||||
def runAdobeCS5AAMEEInstall(dmgpath):
|
||||
'''Installs a CS5 product using an AAMEE-generated package on a
|
||||
disk image.'''
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = mountAdobeDmg(dmgpath)
|
||||
if not mountpoints:
|
||||
munkicommon.display_error("No mountable filesystems on %s" % dmgpath)
|
||||
@@ -690,7 +691,7 @@ def runAdobeCS5AAMEEInstall(dmgpath):
|
||||
'--setupBasePath=%s' % tmpdir, '--installDirPath=/',
|
||||
'--mode=install'])
|
||||
|
||||
munkicommon.display_status("Starting Adobe CS5 installer...")
|
||||
munkicommon.display_status_minor('Starting Adobe CS5 installer...')
|
||||
retcode = runAdobeInstallTool(cmd, number_of_payloads,
|
||||
killAdobeAIR=True)
|
||||
# now clean up our symlink hackfest
|
||||
@@ -709,8 +710,8 @@ def runAdobeCS5PatchInstaller(dmgpath, copylocal=False):
|
||||
'''Runs the AdobePatchInstaller for CS5.
|
||||
Optionally can copy the DMG contents to the local disk
|
||||
to work around issues with the patcher.'''
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = mountAdobeDmg(dmgpath)
|
||||
if mountpoints:
|
||||
if copylocal:
|
||||
@@ -735,7 +736,7 @@ def runAdobeCS5PatchInstaller(dmgpath, copylocal=False):
|
||||
# try to find and count the number of payloads
|
||||
# so we can give a rough progress indicator
|
||||
number_of_payloads = countPayloads(updatedir)
|
||||
munkicommon.display_status("Running Adobe Patch Installer")
|
||||
munkicommon.display_status_minor('Running Adobe Patch Installer')
|
||||
install_cmd = [ patchinstaller,
|
||||
'--mode=silent',
|
||||
'--skipProcessCheck=1' ]
|
||||
@@ -763,8 +764,8 @@ def runAdobeUberTool(dmgpath, pkgname='', uninstalling=False):
|
||||
pkgname is the name of a directory at the top level of the dmg
|
||||
containing the AdobeUber tools and their XML files.'''
|
||||
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = mountAdobeDmg(dmgpath)
|
||||
if mountpoints:
|
||||
installroot = mountpoints[0]
|
||||
@@ -781,13 +782,10 @@ def runAdobeUberTool(dmgpath, pkgname='', uninstalling=False):
|
||||
action = "Installing"
|
||||
if uninstalling:
|
||||
action = "Uninstalling"
|
||||
munkicommon.display_status_major('%s %s' % (action, packagename))
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message("%s %s..." % (action, packagename))
|
||||
munkistatus.detail("Starting %s" % os.path.basename(ubertool))
|
||||
munkistatus.percent(-1)
|
||||
else:
|
||||
munkicommon.display_status("%s %s" % (action, packagename))
|
||||
|
||||
munkistatus.detail('Starting %s' % os.path.basename(ubertool))
|
||||
|
||||
# try to find and count the number of payloads
|
||||
# so we can give a rough progress indicator
|
||||
number_of_payloads = countPayloads(installroot)
|
||||
@@ -847,8 +845,8 @@ def updateAcrobatPro(dmgpath):
|
||||
munkistatus.percent(-1)
|
||||
|
||||
#first mount the dmg
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = mountAdobeDmg(dmgpath)
|
||||
if mountpoints:
|
||||
installroot = mountpoints[0]
|
||||
@@ -887,10 +885,10 @@ def updateAcrobatPro(dmgpath):
|
||||
for line in appList:
|
||||
payloadNum = payloadNum + 1
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(getPercent(payloadNum+1, len(appList)+1))
|
||||
munkistatus.percent(getPercent(payloadNum + 1, len(appList) + 1))
|
||||
|
||||
(appname, status) = line.split("\t")
|
||||
munkicommon.display_status("Searching for %s" % appname)
|
||||
munkicommon.display_status_minor('Searching for %s' % appname)
|
||||
# first look in the obvious place
|
||||
pathname = os.path.join("/Applications/Adobe Acrobat 9 Pro", appname)
|
||||
if os.path.exists(pathname):
|
||||
@@ -920,7 +918,7 @@ def updateAcrobatPro(dmgpath):
|
||||
munkicommon.unmountdmg(installroot)
|
||||
return -1
|
||||
|
||||
munkicommon.display_status("Updating %s" % appname)
|
||||
munkicommon.display_status_minor('Updating %s' % appname)
|
||||
apppath = os.path.dirname(candidates[0]["path"])
|
||||
cmd = [ApplyOperation, apppath, appname, resourcesDir,
|
||||
callingScriptPath, str(payloadNum)]
|
||||
@@ -950,9 +948,10 @@ def updateAcrobatPro(dmgpath):
|
||||
(appname, retcode))
|
||||
break
|
||||
else:
|
||||
munkicommon.display_status("Patching %s complete." % appname)
|
||||
munkicommon.display_status_minor(
|
||||
'Patching %s complete.' % appname)
|
||||
|
||||
munkicommon.display_status("Done.")
|
||||
munkicommon.display_status_minor('Done.')
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(100)
|
||||
|
||||
|
||||
@@ -149,13 +149,7 @@ class AppleUpdates(object):
|
||||
Args:
|
||||
message: str message to display to the user and log.
|
||||
"""
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message(message)
|
||||
munkistatus.detail('')
|
||||
munkistatus.percent(-1)
|
||||
munkicommon.log(message)
|
||||
else:
|
||||
munkicommon.display_status(message)
|
||||
munkicommon.display_status_major(message)
|
||||
|
||||
def _GetURLPath(self, full_url):
|
||||
"""Returns only the URL path.
|
||||
@@ -248,7 +242,7 @@ class AppleUpdates(object):
|
||||
for product_key in catalog['Products'].keys():
|
||||
if munkicommon.stopRequested():
|
||||
break
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
'Caching metadata for product ID %s', product_key)
|
||||
product = catalog['Products'][product_key]
|
||||
if 'ServerMetadataURL' in product:
|
||||
@@ -259,7 +253,7 @@ class AppleUpdates(object):
|
||||
if munkicommon.stopRequested():
|
||||
break
|
||||
if 'MetadataURL' in package:
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
'Caching package metadata for product ID %s',
|
||||
product_key)
|
||||
self.RetrieveURLToCacheDir(
|
||||
@@ -269,7 +263,7 @@ class AppleUpdates(object):
|
||||
for dist_lang in distributions.keys():
|
||||
if munkicommon.stopRequested():
|
||||
break
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
'Caching %s distribution for product ID %s',
|
||||
dist_lang, product_key)
|
||||
dist_url = distributions[dist_lang]
|
||||
@@ -795,7 +789,7 @@ class AppleUpdates(object):
|
||||
# We can pretty it up before display.
|
||||
fields = output.rstrip().split()
|
||||
if len(fields) > 3:
|
||||
munkicommon.display_status(' '.join(fields[3:]))
|
||||
munkicommon.display_status_minor(' '.join(fields[3:]))
|
||||
|
||||
retcode = proc.poll()
|
||||
# there's always an error on Leopard
|
||||
@@ -924,7 +918,7 @@ class AppleUpdates(object):
|
||||
elif output.startswith('Installed '):
|
||||
# 10.6 / 10.7. Successful install of package name.
|
||||
if mode == 'install':
|
||||
munkicommon.display_status(output)
|
||||
munkicommon.display_status_minor(output)
|
||||
results['installed'].append(output[10:])
|
||||
else:
|
||||
pass
|
||||
@@ -933,7 +927,7 @@ class AppleUpdates(object):
|
||||
# successful download-only session is odd.
|
||||
elif output.startswith('Done '):
|
||||
# 10.5. Successful install of package name.
|
||||
munkicommon.display_status(output)
|
||||
munkicommon.display_status_minor(output)
|
||||
results['installed'].append(output[5:])
|
||||
elif output.startswith('Downloading ') and mode == 'install':
|
||||
# This is 10.5 & 10.7 behavior for a missing subpackage.
|
||||
@@ -966,7 +960,7 @@ class AppleUpdates(object):
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
munkicommon.display_status(output)
|
||||
munkicommon.display_status_minor(output)
|
||||
|
||||
retcode = job.returncode()
|
||||
if retcode == 0:
|
||||
|
||||
@@ -107,13 +107,7 @@ def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
restartaction = pkginfo.get('RestartAction','None')
|
||||
if not packagename:
|
||||
packagename = os.path.basename(pkgpath)
|
||||
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message("Installing %s..." % packagename)
|
||||
munkistatus.detail("")
|
||||
# clear indeterminate progress bar
|
||||
munkistatus.percent(0)
|
||||
|
||||
#munkicommon.display_status_major("Installing %s..." % packagename)
|
||||
munkicommon.log("Installing %s from %s" % (packagename,
|
||||
os.path.basename(pkgpath)))
|
||||
cmd = ['/usr/sbin/installer', '-query', 'RestartAction', '-pkg', pkgpath]
|
||||
@@ -126,8 +120,8 @@ def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
restartaction = str(output).decode('UTF-8').rstrip("\n")
|
||||
if restartaction == "RequireRestart" or \
|
||||
restartaction == "RecommendRestart":
|
||||
munkicommon.display_status("%s requires a restart after installation."
|
||||
% packagename)
|
||||
munkicommon.display_status_minor(
|
||||
'%s requires a restart after installation.' % packagename)
|
||||
restartneeded = True
|
||||
|
||||
# get the OS version; we need it later when processing installer's output,
|
||||
@@ -189,11 +183,11 @@ def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
if msg.startswith("PHASE:"):
|
||||
phase = msg[6:]
|
||||
if phase:
|
||||
munkicommon.display_status(phase)
|
||||
munkicommon.display_status_minor(phase)
|
||||
elif msg.startswith("STATUS:"):
|
||||
status = msg[7:]
|
||||
if status:
|
||||
munkicommon.display_status(status)
|
||||
munkicommon.display_status_minor(status)
|
||||
elif msg.startswith("%"):
|
||||
percent = float(msg[1:])
|
||||
if os_version == '10.5':
|
||||
@@ -202,7 +196,7 @@ def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(percent)
|
||||
else:
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
"%s percent complete" % percent)
|
||||
elif msg.startswith(" Error"):
|
||||
munkicommon.display_error(msg)
|
||||
@@ -224,9 +218,8 @@ def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
retcode = proc.poll()
|
||||
|
||||
if retcode != 0: # this could be <0, >0, or even None (never returned)
|
||||
munkicommon.display_status(
|
||||
"Install of %s failed with return code %s" % (
|
||||
packagename, retcode))
|
||||
munkicommon.display_status_minor(
|
||||
"Install of %s failed with return code %s" % (packagename, retcode))
|
||||
munkicommon.display_error("-"*78)
|
||||
for line in installeroutput:
|
||||
munkicommon.display_error(line.rstrip("\n"))
|
||||
@@ -295,8 +288,8 @@ def installall(dirpath, choicesXMLpath=None, suppressBundleRelocation=False,
|
||||
|
||||
def copyAppFromDMG(dmgpath):
|
||||
'''copies application from DMG to /Applications'''
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = munkicommon.mountdmg(dmgpath)
|
||||
if mountpoints:
|
||||
retcode = 0
|
||||
@@ -317,8 +310,8 @@ def copyAppFromDMG(dmgpath):
|
||||
munkicommon.display_error("Error removing existing "
|
||||
"%s" % destpath)
|
||||
if retcode == 0:
|
||||
munkicommon.display_status(
|
||||
"Copying %s to Applications folder" % appname)
|
||||
munkicommon.display_status_minor(
|
||||
'Copying %s to Applications folder' % appname)
|
||||
retcode = subprocess.call(["/bin/cp", "-R",
|
||||
itempath, destpath])
|
||||
if retcode:
|
||||
@@ -340,8 +333,8 @@ def copyAppFromDMG(dmgpath):
|
||||
"com.apple.quarantine",
|
||||
destpath])
|
||||
# let the user know we completed successfully
|
||||
munkicommon.display_status(
|
||||
"The software was successfully installed.")
|
||||
munkicommon.display_status_minor(
|
||||
'The software was successfully installed.')
|
||||
munkicommon.unmountdmg(mountpoint)
|
||||
if not appname:
|
||||
munkicommon.display_error("No application found on %s" %
|
||||
@@ -361,8 +354,8 @@ def copyFromDMG(dmgpath, itemlist):
|
||||
munkicommon.display_error("No items to copy!")
|
||||
return -1
|
||||
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
os.path.basename(dmgpath))
|
||||
munkicommon.display_status_minor(
|
||||
'Mounting disk image %s' % os.path.basename(dmgpath))
|
||||
mountpoints = munkicommon.mountdmg(dmgpath)
|
||||
if mountpoints:
|
||||
mountpoint = mountpoints[0]
|
||||
@@ -397,7 +390,7 @@ def copyFromDMG(dmgpath, itemlist):
|
||||
retcode = -1
|
||||
|
||||
if retcode == 0:
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
"Copying %s to %s" % (itemname, destpath))
|
||||
retcode = subprocess.call(["/bin/cp", "-pR",
|
||||
itempath, destpath])
|
||||
@@ -467,7 +460,7 @@ def copyFromDMG(dmgpath, itemlist):
|
||||
|
||||
if retcode == 0:
|
||||
# let the user know we completed successfully
|
||||
munkicommon.display_status(
|
||||
munkicommon.display_status_minor(
|
||||
"The software was successfully installed.")
|
||||
munkicommon.unmountdmg(mountpoint)
|
||||
return retcode
|
||||
@@ -498,7 +491,7 @@ def removeCopiedItems(itemlist):
|
||||
break
|
||||
path_to_remove = os.path.join(destpath, os.path.basename(itemname))
|
||||
if os.path.exists(path_to_remove):
|
||||
munkicommon.display_status('Removing %s' % path_to_remove)
|
||||
munkicommon.display_status_minor('Removing %s' % path_to_remove)
|
||||
retcode = subprocess.call(['/bin/rm', '-rf', path_to_remove])
|
||||
if retcode:
|
||||
munkicommon.display_error('Removal error for %s' %
|
||||
@@ -605,16 +598,10 @@ def installWithInfo(
|
||||
if retcode == 0 and 'installer_item' in item:
|
||||
display_name = item.get('display_name') or item.get('name')
|
||||
version_to_install = item.get('version_to_install','')
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message("Installing %s (%s of %s)..." %
|
||||
(display_name, itemindex,
|
||||
len(installlist)))
|
||||
munkistatus.detail('')
|
||||
munkistatus.percent(-1)
|
||||
else:
|
||||
munkicommon.display_status("Installing %s (%s of %s)" %
|
||||
(display_name, itemindex,
|
||||
len(installlist)))
|
||||
munkicommon.display_status_major(
|
||||
"Installing %s (%s of %s)"
|
||||
% (display_name, itemindex, len(installlist)))
|
||||
|
||||
itempath = os.path.join(dirpath, item["installer_item"])
|
||||
if not os.path.exists(itempath):
|
||||
# can't install, so we should stop. Since later items might
|
||||
@@ -663,8 +650,8 @@ def installWithInfo(
|
||||
choicesXMLfile = ''
|
||||
installer_environment = item.get('installer_environment')
|
||||
if itempath.endswith(".dmg"):
|
||||
munkicommon.display_status("Mounting disk image %s" %
|
||||
item["installer_item"])
|
||||
munkicommon.display_status_minor(
|
||||
"Mounting disk image %s" % item["installer_item"])
|
||||
mountWithShadow = suppressBundleRelocation
|
||||
# we need to mount the diskimage as read/write to
|
||||
# be able to modify the package to suppress bundle
|
||||
@@ -872,15 +859,11 @@ def runEmbeddedScript(scriptname, pkginfo_item):
|
||||
|
||||
def runScript(itemname, path, scriptname):
|
||||
'''Runs a script, Returns return code.'''
|
||||
munkicommon.display_status_minor(
|
||||
'Running %s for %s ' % (scriptname, itemname))
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message('Running %s for %s '
|
||||
% (scriptname, itemname))
|
||||
munkistatus.detail("")
|
||||
# set indeterminate progress bar
|
||||
munkistatus.percent(-1)
|
||||
else:
|
||||
munkicommon.display_status('Running %s for %s '
|
||||
% (scriptname, itemname))
|
||||
|
||||
scriptoutput = []
|
||||
try:
|
||||
@@ -981,14 +964,8 @@ def processRemovals(removallist, only_unattended=False):
|
||||
|
||||
index += 1
|
||||
name = item.get('display_name') or item.get('name')
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.message("Removing %s (%s of %s)..." %
|
||||
(name, index, len(removallist)))
|
||||
munkistatus.detail("")
|
||||
munkistatus.percent(-1)
|
||||
else:
|
||||
munkicommon.display_status("Removing %s (%s of %s)..." %
|
||||
(name, index, len(removallist)))
|
||||
munkicommon.display_status_major(
|
||||
"Removing %s (%s of %s)..." % (name, index, len(removallist)))
|
||||
|
||||
retcode = 0
|
||||
# run preuninstall_script if it exists
|
||||
@@ -1024,8 +1001,8 @@ def processRemovals(removallist, only_unattended=False):
|
||||
remove_app_info = item.get('remove_app_info', None)
|
||||
if remove_app_info:
|
||||
path_to_remove = remove_app_info['path']
|
||||
munkicommon.display_status("Removing %s" %
|
||||
path_to_remove)
|
||||
munkicommon.display_status_minor(
|
||||
'Removing %s' % path_to_remove)
|
||||
retcode = subprocess.call(["/bin/rm", "-rf",
|
||||
path_to_remove])
|
||||
if retcode:
|
||||
|
||||
@@ -303,20 +303,39 @@ def concat_log_message(msg, *args):
|
||||
return msg
|
||||
|
||||
|
||||
def display_status(msg, *args):
|
||||
def display_status_major(msg, *args):
|
||||
"""
|
||||
Displays major status messages, formatting as needed
|
||||
for verbose/non-verbose and munkistatus-style output.
|
||||
"""
|
||||
msg = concat_log_message(msg, *args)
|
||||
log(msg)
|
||||
if munkistatusoutput:
|
||||
munkistatus.message(msg)
|
||||
munkistatus.detail('')
|
||||
munkistatus.percent(-1)
|
||||
elif verbose > 0:
|
||||
if msg.endswith('.') or msg.endswith(u'…'):
|
||||
print '%s' % msg.encode('UTF-8')
|
||||
else:
|
||||
print '%s...' % msg.encode('UTF-8')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def display_status_minor(msg, *args):
|
||||
"""
|
||||
Displays minor status messages, formatting as needed
|
||||
for verbose/non-verbose and munkistatus-style output.
|
||||
"""
|
||||
msg = concat_log_message(msg, *args)
|
||||
log(msg)
|
||||
if munkistatusoutput:
|
||||
munkistatus.detail(msg)
|
||||
elif verbose > 0:
|
||||
if msg.endswith('.') or msg.endswith(u'…'):
|
||||
print '%s' % msg.encode('UTF-8')
|
||||
print ' %s' % msg.encode('UTF-8')
|
||||
else:
|
||||
print '%s...' % msg.encode('UTF-8')
|
||||
print ' %s...' % msg.encode('UTF-8')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
@@ -336,10 +355,10 @@ def display_info(msg, *args):
|
||||
|
||||
def display_detail(msg, *args):
|
||||
"""
|
||||
Displays minor info messages, formatting as needed
|
||||
for verbose/non-verbose and munkistatus-style output.
|
||||
Displays minor info messages.
|
||||
Not displayed in MunkiStatus.
|
||||
These are usually logged only, but can be printed to
|
||||
stdout if verbose is set to 2 or higher
|
||||
stdout if verbose is set greater than 1
|
||||
"""
|
||||
msg = concat_log_message(msg, *args)
|
||||
if munkistatusoutput:
|
||||
|
||||
@@ -527,7 +527,8 @@ def initDatabase(forcerebuild=False):
|
||||
if not shouldRebuildDB(packagedb) and not forcerebuild:
|
||||
return True
|
||||
|
||||
munkicommon.display_status('Gathering information on installed packages')
|
||||
munkicommon.display_status_minor(
|
||||
'Gathering information on installed packages')
|
||||
|
||||
if os.path.exists(packagedb):
|
||||
try:
|
||||
@@ -713,7 +714,8 @@ def getpathstoremove(pkgkeylist):
|
||||
"(path_key in (%s) and path_key not in (%s))" % \
|
||||
(in_selected_packages, not_in_other_packages)
|
||||
|
||||
munkicommon.display_status('Determining which filesystem items to remove')
|
||||
munkicommon.display_status_minor(
|
||||
'Determining which filesystem items to remove')
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.percent(-1)
|
||||
|
||||
@@ -735,7 +737,7 @@ def removeReceipts(pkgkeylist, noupdateapplepkgdb):
|
||||
/Library/Receipts/boms, our internal package database,
|
||||
and optionally Apple's package database.
|
||||
"""
|
||||
munkicommon.display_status('Removing receipt info')
|
||||
munkicommon.display_status_minor('Removing receipt info')
|
||||
local_display_percent_done(0, 4)
|
||||
|
||||
conn = sqlite3.connect(packagedb)
|
||||
@@ -914,7 +916,8 @@ def removeFilesystemItems(removalpaths, forcedeletebundles):
|
||||
removalpaths.sort(reverse=True)
|
||||
removalerrors = ""
|
||||
removalcount = len(removalpaths)
|
||||
munkicommon.display_status("Removing %s filesystem items" % removalcount)
|
||||
munkicommon.display_status_minor(
|
||||
'Removing %s filesystem items' % removalcount)
|
||||
|
||||
itemcount = len(removalpaths)
|
||||
itemindex = 0
|
||||
@@ -1042,7 +1045,7 @@ def removepackages(pkgnames, forcedeletebundles=False, listfiles=False,
|
||||
munkistatus.disableStopButton()
|
||||
removeFilesystemItems(removalpaths, forcedeletebundles)
|
||||
else:
|
||||
munkicommon.display_status('Nothing to remove.')
|
||||
munkicommon.display_status_minor('Nothing to remove.')
|
||||
if munkicommon.munkistatusoutput:
|
||||
time.sleep(2)
|
||||
|
||||
@@ -1051,7 +1054,7 @@ def removepackages(pkgnames, forcedeletebundles=False, listfiles=False,
|
||||
removeReceipts(pkgkeyslist, noupdateapplepkgdb)
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.enableStopButton()
|
||||
munkicommon.display_status('Package removal complete.')
|
||||
munkicommon.display_status_minor('Package removal complete.')
|
||||
time.sleep(2)
|
||||
|
||||
return 0
|
||||
|
||||
@@ -1234,7 +1234,7 @@ def verifySoftwarePackageIntegrity(file_path, item_hash, always_hash=False):
|
||||
return (True, chash)
|
||||
elif mode.lower() == 'hash' or mode.lower() == 'hash_strict':
|
||||
if item_hash:
|
||||
munkicommon.display_status('Verifying package integrity...')
|
||||
munkicommon.display_status_minor('Verifying package integrity...')
|
||||
if not chash:
|
||||
chash = munkicommon.getsha256hash(file_path)
|
||||
if item_hash == chash:
|
||||
@@ -2489,7 +2489,7 @@ def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False,
|
||||
if message:
|
||||
# log always, display if verbose is 1 or more
|
||||
# also display in MunkiStatus detail field
|
||||
munkicommon.display_status(message)
|
||||
munkicommon.display_status_minor(message)
|
||||
|
||||
elif targetsize and header.get('http_result_code').startswith('2'):
|
||||
# display progress if we get a 2xx result code
|
||||
@@ -2918,14 +2918,11 @@ def check(client_id='', localmanifestpath=None):
|
||||
munkicommon.report['MachineInfo'] = MACHINE
|
||||
|
||||
ManagedInstallDir = munkicommon.pref('ManagedInstallDir')
|
||||
|
||||
if munkicommon.munkistatusoutput:
|
||||
munkistatus.activate()
|
||||
munkistatus.message('Checking for available updates...')
|
||||
munkistatus.detail('')
|
||||
munkistatus.percent('-1')
|
||||
|
||||
munkicommon.log('### Beginning managed software check ###')
|
||||
munkicommon.display_status_major('Checking for available updates...')
|
||||
|
||||
if localmanifestpath:
|
||||
mainmanifestpath = localmanifestpath
|
||||
@@ -3178,7 +3175,7 @@ def check(client_id='', localmanifestpath=None):
|
||||
munkicommon.log('')
|
||||
if installcount:
|
||||
munkicommon.display_info(
|
||||
'The following items will be installed or upgraded:')
|
||||
'\nThe following items will be installed or upgraded:')
|
||||
for item in installinfo.get('managed_installs', []):
|
||||
if item.get('installer_item'):
|
||||
munkicommon.display_info(' + %s-%s' %
|
||||
|
||||
Reference in New Issue
Block a user