add option to disable rebuilds

This commit is contained in:
Fredrik Eriksson 2024-08-14 08:35:27 +02:00
parent fc6f29c0e1
commit 62ff301c3c
Signed by: feffe
GPG Key ID: E6B5580B853D322B
2 changed files with 104 additions and 96 deletions

View File

@ -45,6 +45,11 @@ do_depclean=yes
# do eix-sync on Gentoo # do eix-sync on Gentoo
do_reposync=yes do_reposync=yes
# do live-rebuild, go-rebuild, rust-rebuild, perl-cleaner etc. on Gentoo
# set to no if using binary packages that are bumped when needed.
# Leave as yes on package builders and if not using binary packages.
do_rebuilds=yes
# to only write to stderr when something unexpected happens or manual action is required # to only write to stderr when something unexpected happens or manual action is required
# set stderr_loglevel to warning # set stderr_loglevel to warning
stderr_loglevel=debug stderr_loglevel=debug

View File

@ -261,113 +261,116 @@ def pkg_upgrade():
if line.startswith(' * '): if line.startswith(' * '):
log.warning(line) log.warning(line)
# from here on we shouldn't need to rebuild the upgraded packages again ## rebuild as needed
exclude_list = ' --exclude '.join(rebuild_packages.keys()).split() do_rebuild = conf.getboolean('default', 'do_rebuilds', fallback=True)
if do_rebuilds:
# from here on we shouldn't need to rebuild the upgraded packages again
exclude_list = ' --exclude '.join(rebuild_packages.keys()).split()
# Rebuild go # Rebuild go
go_packages = [] go_packages = []
cmd = None cmd = None
for package,eclasses in rebuild_packages.items(): for package,eclasses in rebuild_packages.items():
if 'go-module' in eclasses or package == 'dev-lang/go': if 'go-module' in eclasses or package == 'dev-lang/go':
go_packages.append(package) go_packages.append(package)
if 'dev-lang/go' in go_packages: if 'dev-lang/go' in go_packages:
log.info("Running golang-rebuild due to update of dev-lang/go") log.info("Running golang-rebuild due to update of dev-lang/go")
cmd = [
EMERGE_PATH,
'--color', 'n',
'-q',
'--usepkg-exclude', '*/*',
'@golang-rebuild',
'--exclude' ] + exclude_list
elif go_packages:
dependencies = []
for package in go_packages:
dependencies.append(get_dependencies(package))
dependencies = set(dependencies)
upgraded = set(rebuild_packages.keys())
not_upgraded = dependencies-upgraded
if not_upgraded:
log.info(f'Rebuilding packages dependant of go modules {", ".join(go_packages)}')
cmd = [ cmd = [
EMERGE_PATH, EMERGE_PATH,
'--color', 'n', '--color', 'n',
'-q', '-q',
'--usepkg-exclude', '*/*'] + not_upgraded '--usepkg-exclude', '*/*',
if cmd: '@golang-rebuild',
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000) '--exclude' ] + exclude_list
elif go_packages:
dependencies = []
for package in go_packages:
dependencies.append(get_dependencies(package))
dependencies = set(dependencies)
upgraded = set(rebuild_packages.keys())
not_upgraded = dependencies-upgraded
if not_upgraded:
log.info(f'Rebuilding packages dependant of go modules {", ".join(go_packages)}')
cmd = [
EMERGE_PATH,
'--color', 'n',
'-q',
'--usepkg-exclude', '*/*'] + not_upgraded
if cmd:
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err:
log.error('Rebuild of go packages returned {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during go rebuild')
else:
log.info('go rebuild complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# rebuild rust
if 'dev-lang/rust' in rebuild_packages:
log.info("Running rust-rebuild due to update of dev-lang/rust")
cmd = [
EMERGE_PATH,
'--color', 'n',
'-q',
'--usepkg-exclude', '*/*',
'@rust-rebuild',
'--exclude' ] + exclude_list
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err:
log.error('Rebuild of rust packages returned {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during rust rebuild')
else:
log.info('rust rebuild complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# run perl-cleaner
if 'dev-lang/perl' in rebuild_packages:
log.info("Running perl-cleaner due to perl upgrade")
cmd = [ PCLEAN_PATH, '--all', '--', '-q', '--usepkg-exclude', '*/*']
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err:
log.error('perl-cleaner failed with code {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during perl-cleaner')
else:
log.info('perl-cleaner complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# rebuild live packages
cmd = [ EMERGE_PATH, '--color', 'n', '-q', '--usepkg-exclude', '*/*', '@live-rebuild' ]
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=3600)
if ret != 0 or err: if ret != 0 or err:
log.error('Rebuild of go packages returned {}'.format(ret)) log.error('live-rebuild returned {}'.format(ret))
for line in out.splitlines(): for line in out.splitlines():
log.error('stdout: {}'.format(line)) log.error('stdout: {}'.format(line))
for line in err.splitlines(): for line in err.splitlines():
log.error('stderr: {}'.format(line)) log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during go rebuild') raise sau.errors.UpgradeError(f'Error during live-rebuild')
else: else:
log.info('go rebuild complete') log.info('live-rebuild complete')
for line in out.splitlines(): for line in out.splitlines():
if line.startswith(' * '): if line.startswith(' * '):
log.warning(line) log.warning(line)
# rebuild rust
if 'dev-lang/rust' in rebuild_packages:
log.info("Running rust-rebuild due to update of dev-lang/rust")
cmd = [
EMERGE_PATH,
'--color', 'n',
'-q',
'--usepkg-exclude', '*/*',
'@rust-rebuild',
'--exclude' ] + exclude_list
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err:
log.error('Rebuild of rust packages returned {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during rust rebuild')
else:
log.info('rust rebuild complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# run perl-cleaner ## Depclean
if 'dev-lang/perl' in rebuild_packages:
log.info("Running perl-cleaner due to perl upgrade")
cmd = [ PCLEAN_PATH, '--all', '--', '-q', '--usepkg-exclude', '*/*']
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err:
log.error('perl-cleaner failed with code {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during perl-cleaner')
else:
log.info('perl-cleaner complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# rebuild live packages
cmd = [ EMERGE_PATH, '--color', 'n', '-q', '--usepkg-exclude', '*/*', '@live-rebuild' ]
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=3600)
if ret != 0 or err:
log.error('live-rebuild returned {}'.format(ret))
for line in out.splitlines():
log.error('stdout: {}'.format(line))
for line in err.splitlines():
log.error('stderr: {}'.format(line))
raise sau.errors.UpgradeError(f'Error during live-rebuild')
else:
log.info('live-rebuild complete')
for line in out.splitlines():
if line.startswith(' * '):
log.warning(line)
# Depclean
if conf.getboolean('default', 'do_depclean', fallback=False): if conf.getboolean('default', 'do_depclean', fallback=False):
cmd = [ EMERGE_PATH, '--color', 'n', '-q', '--depclean' ] cmd = [ EMERGE_PATH, '--color', 'n', '-q', '--depclean' ]
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=3600) ret, out, err = sau.helpers.exec_cmd(cmd, timeout=3600)
@ -385,8 +388,8 @@ def pkg_upgrade():
log.warning(line) log.warning(line)
# Preserved rebuild ## Preserved rebuild
cmd = [ EMERGE_PATH, '--color', 'n', '-q', '@preserved-rebuild' ] cmd = [ EMERGE_PATH, '--color', 'n', '--usepkg-exclude', '*/*', '-q', '@preserved-rebuild' ]
ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000) ret, out, err = sau.helpers.exec_cmd(cmd, timeout=72000)
if ret != 0 or err: if ret != 0 or err: