diff --git a/sau/gentoo.py b/sau/gentoo.py index 91b546b..c2f7041 100644 --- a/sau/gentoo.py +++ b/sau/gentoo.py @@ -5,7 +5,7 @@ import subprocess import sau import sau.helpers -EIX_SYNC_PATH='/usr/bin/eix-sync' +EIX_UPDATE_PATH='/usr/bin/eix-update' RC_SERVICE_PATH='/sbin/rc-service' EMERGE_PATH='/usr/bin/emerge' EQUERY_PATH='/usr/bin/equery' @@ -118,6 +118,27 @@ def _sync_portage(): for line in err.splitlines(): log.warning("stderr: {}".format(line)) + if os.path.exists(EIX_UPDATE_PATH): + cmd = [ EIX_UPDATE_PATH, '-q' ] + 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: + log.warning("eix-update failed:") + for line in out.splitlines(): + log.warning("stdout: {}".format(line)) + for line in err.splitlines(): + log.warning("stderr: {}".format(line)) + + def _parse_version(version): slot_re = re.compile('^(\(~\))?([^\(]+)(\([^\)]+\))$') match = re.match(slot_re, version) @@ -127,59 +148,6 @@ def _parse_version(version): 'slot': match.group(2) } -def _get_upgradable_packages_eix(): - log = logging.getLogger(sau.LOGNAME) - conf = sau.config - - filter_re = re.compile('^(No |$|--$|The names of all|Found \d+)') - - proc = subprocess.Popen( - [EIX, '-Ttnc'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - - out, err = proc.communicate() - - out = out.decode('utf-8') - err = err.decode('utf-8') - - default_version_diff = conf.getint('default', 'min_version_diff', fallback=2) - upgradable = set() - for line in out.splitlines(): - if re.match(filter_re, line): - continue - - match = re.match(package_re, line) - if not match: - continue - - if match.group(1) != 'U': - log.warning('Bad status for package {}, manual upgrade required'.format(match.group(2))) - continue - - min_diff = conf.getint('packages', match.group(2), fallback=default_version_diff) - installed, latest = match.group(3).split(' -> ') - installed = installed.split() - latest = latest.split() - installed = [_parse_version(x) for x in installed] - latest = [_parse_version(x) for x in latest] - for pkg in installed: - latest_in_slot = [x for x in latest if x['slot'] == pkg['slot']] - if not latest_in_slot: - log.warning('Could not find latest version of {} in slot {}'.format(match.group(2), pkg['slot'])) - continue - latest_in_slot = latest_in_slot[0] - if pkg['version'] == latest_in_slot['version']: - continue - diff = sau.helpers.version_diff(latest_in_slot['version'], pkg['version']) - if min_diff >= diff: - log.debug('configured level {} >= pkg level {}'.format(min_diff, diff)) - upgrade_pkg.add('{}:{}'.format(match.group(2), pkg['slot'])) - else: - log.debug('configured level {} < pkg level {}'.format(min_diff, diff)) - - return upgradable - def pkg_upgrade(): log = logging.getLogger(sau.LOGNAME) conf = sau.config