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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2C8A713835A for ; Mon, 24 May 2021 06:33:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 44360E0809; Mon, 24 May 2021 06:33:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2BACCE0809 for ; Mon, 24 May 2021 06:33:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A8985340B28 for ; Mon, 24 May 2021 06:33:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3262C632 for ; Mon, 24 May 2021 06:33:48 +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: <1621837350.9946517f1e0ee35b2a6eed1ff6c1fd10acf8fd45.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: lib/_emerge/PackageUninstall.py lib/_emerge/unmerge.py X-VCS-Directories: lib/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9946517f1e0ee35b2a6eed1ff6c1fd10acf8fd45 X-VCS-Branch: master Date: Mon, 24 May 2021 06:33:48 +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: 13a089e8-bd35-494d-86c6-6f051a4aa69f X-Archives-Hash: 6c3f195b11935e4bf0008bd6542438df commit: 9946517f1e0ee35b2a6eed1ff6c1fd10acf8fd45 Author: Felix Bier gmail com> AuthorDate: Sun May 9 23:27:19 2021 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon May 24 06:22:30 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9946517f Sort emerge --unmerge order for determinism This commit changes the order in which packages are uninstalled with --unmerge to be deterministic. Before this commit, when an atom specified with --unmerge matches multiple versions, these versions were uninstalled in a random order. For example, when some-pkg-1.0.0 and some-pkg-2.0.0 are installed, then running emerge --unmerge some-pkg will unmerge 1.0.0 and 2.0.0 in a random order. With this commit, when an atom matches multiple versions, they are uninstalled in a sorted order. So in the above example, 1.0.0 will be unmerged before 2.0.0. This does not affect the order specified on the command-line, for example when running: emerge --unmerge =some-pkg-2.0.0 =some-pkg-1.0.0 that order is respected, as before this commit. Similarly, when uninstalling multiple different packages, e.g.: emerge --unmerge some-pkg some-other-pkg the sorting only applies to the versions matching each atom, so the versions matching some-pkg are sorted separately from the versions matching some-other-pkg, and since some-pkg is specified before some-other-pkg, its versions will be uninstalled first. Motivation: When a package has a custom pkg_postrm hook, uninstalling multiple versions in a random order can leave the filesystem in a different state depending on which version is uninstalled last. When running emerge as part of a larger build system such as catalyst, this is an obstacle towards reproducible builds. Bug: https://bugs.gentoo.org/782724 Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Zac Medico gentoo.org> lib/_emerge/PackageUninstall.py | 2 +- lib/_emerge/unmerge.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/_emerge/PackageUninstall.py b/lib/_emerge/PackageUninstall.py index 43210b4bc..8786c2cd1 100644 --- a/lib/_emerge/PackageUninstall.py +++ b/lib/_emerge/PackageUninstall.py @@ -71,7 +71,7 @@ class PackageUninstall(CompositeTask): # Output only gets logged if it comes after prepare_build_dirs() # which initializes PORTAGE_LOG_FILE. - retval, pkgmap = _unmerge_display(self.pkg.root_config, + retval, _ = _unmerge_display(self.pkg.root_config, self.opts, "unmerge", [self.pkg.cpv], clean_delay=0, writemsg_level=self._writemsg_level) diff --git a/lib/_emerge/unmerge.py b/lib/_emerge/unmerge.py index e8b7c9aaa..09e155de3 100644 --- a/lib/_emerge/unmerge.py +++ b/lib/_emerge/unmerge.py @@ -432,6 +432,11 @@ def _unmerge_display(root_config, myopts, unmerge_action, cp_dict[k].update(v) pkgmap = [unordered[cp] for cp in sorted(unordered)] + # Sort each set of selected packages + if ordered: + for pkg in pkgmap: + pkg["selected"] = sorted(pkg["selected"], key=cpv_sort_key()) + for x in range(len(pkgmap)): selected = pkgmap[x]["selected"] if not selected: