diff options
author | 2024-02-04 22:38:52 -0800 | |
---|---|---|
committer | 2024-02-04 22:43:11 -0800 | |
commit | cba5d579f170ee9616b1903dedc3597eafb1aee7 (patch) | |
tree | d5b1b126f130575fcd9a3a9e1f65bb49a5e95101 /bin | |
parent | process.spawn: Avoid os.environ pickling error (diff) | |
download | portage-cba5d579f170ee9616b1903dedc3597eafb1aee7.tar.gz portage-cba5d579f170ee9616b1903dedc3597eafb1aee7.tar.bz2 portage-cba5d579f170ee9616b1903dedc3597eafb1aee7.zip |
bin/fixpackages: multiprocessing spawn compat
Use __main__ to avoid this RuntimeError:
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
Bug: https://bugs.gentoo.org/914876
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fixpackages | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/bin/fixpackages b/bin/fixpackages index 6f88bea7c..76c8f6d38 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import argparse @@ -17,44 +17,49 @@ if osp.isfile( import portage portage._internal_caller = True -from portage import os from portage.output import EOutput from textwrap import wrap from portage._global_updates import _global_updates -mysettings = portage.settings -mytrees = portage.db -mtimedb = portage.mtimedb -description = """The fixpackages program performs package move updates on - configuration files, installed packages, and binary packages.""" -description = " ".join(description.split()) +def main(): + mysettings = portage.settings + mytrees = portage.db + mtimedb = portage.mtimedb -parser = argparse.ArgumentParser(description=description) -parser.parse_args() + description = """The fixpackages program performs package move updates on + configuration files, installed packages, and binary packages.""" + description = " ".join(description.split()) -if mysettings["ROOT"] != "/": - out = EOutput() - msg = ( - "The fixpackages program is not intended for use with " - + 'ROOT != "/". Instead use `emaint --fix movebin` and/or ' - + "`emaint --fix moveinst." - ) - for line in wrap(msg, 72): - out.eerror(line) - sys.exit(1) - -try: - os.nice(int(mysettings.get("PORTAGE_NICENESS", "0"))) -except (OSError, ValueError) as e: - portage.writemsg( - f"!!! Failed to change nice value to '{mysettings['PORTAGE_NICENESS']}'\n" - ) - portage.writemsg(f"!!! {str(e)}\n") - del e + parser = argparse.ArgumentParser(description=description) + parser.parse_args() + + if mysettings["ROOT"] != "/": + out = EOutput() + msg = ( + "The fixpackages program is not intended for use with " + + 'ROOT != "/". Instead use `emaint --fix movebin` and/or ' + + "`emaint --fix moveinst." + ) + for line in wrap(msg, 72): + out.eerror(line) + sys.exit(1) + + try: + os.nice(int(mysettings.get("PORTAGE_NICENESS", "0"))) + except (OSError, ValueError) as e: + portage.writemsg( + f"!!! Failed to change nice value to '{mysettings['PORTAGE_NICENESS']}'\n" + ) + portage.writemsg(f"!!! {str(e)}\n") + del e + + _global_updates(mytrees, mtimedb["updates"], if_mtime_changed=False) + + print() + print("Done.") + print() -_global_updates(mytrees, mtimedb["updates"], if_mtime_changed=False) -print() -print("Done.") -print() +if __name__ == "__main__": + main() |