From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3419415815E for ; Mon, 5 Feb 2024 06:44:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5D1B22BC015; Mon, 5 Feb 2024 06:44:28 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 384A92BC015 for ; Mon, 5 Feb 2024 06:44:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2EB49343107 for ; Mon, 5 Feb 2024 06:44:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 63C63358 for ; Mon, 5 Feb 2024 06:44:25 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1707115391.cba5d579f170ee9616b1903dedc3597eafb1aee7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/fixpackages X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: cba5d579f170ee9616b1903dedc3597eafb1aee7 X-VCS-Branch: master Date: Mon, 5 Feb 2024 06:44:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5821d8ae-f1f7-4dd5-bc46-fd99fcb19f9b X-Archives-Hash: be53dd0b4cf8b6c93cf97f9b158ce4fc commit: cba5d579f170ee9616b1903dedc3597eafb1aee7 Author: Zac Medico gentoo org> AuthorDate: Mon Feb 5 06:38:52 2024 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Feb 5 06:43:11 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cba5d579 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 gentoo.org> bin/fixpackages | 71 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/bin/fixpackages b/bin/fixpackages index 6f88bea7c3..76c8f6d388 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()