From 6f19bf71cacf59a507ebdf2287e31de2fb6dedd1 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sun, 7 Apr 2019 10:02:44 +0200 Subject: [PATCH] only upgrade on freebsd if no package require manual attention --- sau/freebsd.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/sau/freebsd.py b/sau/freebsd.py index b8f11da..bf5c929 100644 --- a/sau/freebsd.py +++ b/sau/freebsd.py @@ -151,27 +151,26 @@ def pkg_upgrade(): else: log.debug('configured level {} < pkg level {}'.format(diff, pkg['upgrade_level'])) pkg['upgrade'] = False - - upgradables = [x['pkg'] for x in upgrades if x['upgrade'] ] - if upgradables: - cmd = [ PKG_PATH, 'upgrade', '-yq' ] + upgradables - log.debug('Executing "{}"'.format(' '.join(cmd))) - proc = subprocess.Popen( - cmd, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) - out, err = proc.communicate() - out = out.decode('utf-8') - err = err.decode('utf-8') - if proc.returncode != 0 or err: - log.warning('{} failed:'.format(' '.join(cmd))) - for line in out.splitlines(): - log.warning('stdout: {}'.format(line)) - for line in err.splitlines(): - log.warning('stderr: {}'.format(line)) for pkg in [x for x in upgrades if not x['upgrade']]: - log.warning('Package require manual upgrade: {} {} -> {}'.format(pkg['pkg'], pkg['version_old'], pkg['version_new'])) + log.warning('Package require manual upgrade, no upgrades done: {} {} -> {}'.format(pkg['pkg'], pkg['version_old'], pkg['version_new'])) + return False + + cmd = [ PKG_PATH, 'upgrade', '-yq' ] + log.debug('Executing "{}"'.format(' '.join(cmd))) + proc = subprocess.Popen( + cmd, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE) + out, err = proc.communicate() + out = out.decode('utf-8') + err = err.decode('utf-8') + if proc.returncode != 0 or err: + log.warning('{} failed:'.format(' '.join(cmd))) + for line in out.splitlines(): + log.warning('stdout: {}'.format(line)) + for line in err.splitlines(): + log.warning('stderr: {}'.format(line)) return True