From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-974897-garchives=archives.gentoo.org@lists.gentoo.org>
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 B48C81396D0
	for <garchives@archives.gentoo.org>; Mon, 25 Sep 2017 02:04:13 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 921B72BC004;
	Mon, 25 Sep 2017 02:04:11 +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 6F3A12BC004
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Sep 2017 02:04:10 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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 055A2340DF9
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Sep 2017 02:04:09 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 486738F66
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Sep 2017 02:04:07 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
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" <zmedico@gentoo.org>
Message-ID: <1506304988.5b286b267cb5cc69cac1c99ec8704ff0e0463e11.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/
X-VCS-Repository: proj/portage
X-VCS-Files: pym/_emerge/depgraph.py
X-VCS-Directories: pym/_emerge/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: 5b286b267cb5cc69cac1c99ec8704ff0e0463e11
X-VCS-Branch: master
Date: Mon, 25 Sep 2017 02:04:07 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 0878d3e0-8793-424a-9abd-12e4babce6eb
X-Archives-Hash: bfa93a43dea42837fbb0850782c39fc7

commit:     5b286b267cb5cc69cac1c99ec8704ff0e0463e11
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 24 18:52:22 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 25 02:03:08 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5b286b26

depgraph: make _minimize_children deterministic (bug 631894)

In order for the eliminate_pkg loop to produce deterministic results,
the order of the pkgs list must not be random. Prefer to eliminate
installed packages first, in case rebuilds are needed, and also sort
in ascending order so that older versions are eliminated first.

X-Gentoo-bug: 631894
X-Gentoo-bug-url: https://bugs.gentoo.org/631894
Reviewed-by: Manuel RĂ¼ger <mrueg <AT> gentoo.org>

 pym/_emerge/depgraph.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index b4fc5f297..785c036b8 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3584,6 +3584,15 @@ class depgraph(object):
 						if atom_set.findAtomForPackage(pkg2, modified_use=self._pkg_use_enabled(pkg2)):
 							atom_pkg_graph.add(pkg2, atom)
 
+			# In order for the following eliminate_pkg loop to produce
+			# deterministic results, the order of the pkgs list must
+			# not be random (bug 631894). Prefer to eliminate installed
+			# packages first, in case rebuilds are needed, and also sort
+			# in ascending order so that older versions are eliminated
+			# first.
+			pkgs = (sorted(pkg for pkg in pkgs if pkg.installed) +
+				sorted(pkg for pkg in pkgs if not pkg.installed))
+
 			for pkg in pkgs:
 				eliminate_pkg = True
 				for atom in atom_pkg_graph.parent_nodes(pkg):