From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1JbsKL-0008AK-9b for garchives@archives.gentoo.org; Wed, 19 Mar 2008 07:03:09 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5914FE062A; Wed, 19 Mar 2008 07:03:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 1EBF6E062A for ; Wed, 19 Mar 2008 07:03:08 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 8F26965880 for ; Wed, 19 Mar 2008 07:03:07 +0000 (UTC) Received: from zmedico by stork.gentoo.org with local (Exim 4.68) (envelope-from ) id 1JbsKI-0005Hq-Gk for gentoo-commits@lists.gentoo.org; Wed, 19 Mar 2008 07:03:06 +0000 To: gentoo-commits@lists.gentoo.org From: "Zac Medico (zmedico)" Subject: [gentoo-commits] portage r9483 - main/trunk/pym/_emerge X-VCS-Repository: portage X-VCS-Revision: 9483 X-VCS-Files: main/trunk/pym/_emerge/__init__.py X-VCS-Directories: main/trunk/pym/_emerge X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Zac Medico Date: Wed, 19 Mar 2008 07:03:06 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 992d7759-4d11-4c06-af06-fc729fcc11f1 X-Archives-Hash: f7d0648d63c38fefb86650e165266488 Author: zmedico Date: 2008-03-19 07:03:05 +0000 (Wed, 19 Mar 2008) New Revision: 9483 Modified: main/trunk/pym/_emerge/__init__.py Log: Bug #201045 - Fix unmerge() to preserve unmerge order so that dependencie= s are respected. Also, eliminate duplicate package selections since the sam= e package may be selected by multiple atoms but we can only unmerge it once= . Modified: main/trunk/pym/_emerge/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/trunk/pym/_emerge/__init__.py 2008-03-18 23:44:12 UTC (rev 9482) +++ main/trunk/pym/_emerge/__init__.py 2008-03-19 07:03:05 UTC (rev 9483) @@ -4984,9 +4984,13 @@ not ("--quiet" in myopts): print darkgreen(newline+\ ">>> These are the packages that would be unmerged:") -=09 - pkgmap =3D {} - numselected =3D 0 + + # Preservation of order is required for --depclean and --prune so + # that dependencies are respected. Use all_selected to eliminate + # duplicate packages since the same package may be selected by + # multiple atoms. + pkgmap =3D [] + all_selected =3D set() for x in candidate_catpkgs: # cycle through all our candidate deps and determine # what will and will not get unmerged @@ -5011,17 +5015,15 @@ portage.writemsg("\n--- Couldn't find '%s' to %s.\n" % \ (x, unmerge_action), noiselevel=3D-1) continue - =09 - mycp =3D portage.versions.pkgsplit(mymatch[0])[0] - =09 - if not mycp in pkgmap: - pkgmap[mycp] =3D {"protected": set(), "selected": set(), "omitted": = set()} =20 - if unmerge_action =3D=3D "unmerge": - for y in mymatch: - if y not in pkgmap[mycp]["selected"]: - pkgmap[mycp]["selected"].add(y) - numselected +=3D len(mymatch) + pkgmap.append( + {"protected": set(), "selected": set(), "omitted": set()}) + mykey =3D len(pkgmap) - 1 + if unmerge_action=3D=3D"unmerge": + for y in mymatch: + if y not in all_selected: + pkgmap[mykey]["selected"].add(y) + all_selected.add(y) elif unmerge_action =3D=3D "prune": if len(mymatch) =3D=3D 1: continue @@ -5042,10 +5044,10 @@ best_version =3D mypkg best_slot =3D myslot best_counter =3D mycounter - pkgmap[mycp]["protected"].add(best_version) - pkgmap[mycp]["selected"] =3D set([mypkg for mypkg in mymatch \ - if mypkg !=3D best_version]) - numselected +=3D len(pkgmap[mycp]["selected"]) + pkgmap[mykey]["protected"].add(best_version) + pkgmap[mykey]["selected"].update(mypkg for mypkg in mymatch \ + if mypkg !=3D best_version and mypkg not in all_selected) + all_selected.update(pkgmap[mykey]["selected"]) else: # unmerge_action =3D=3D "clean" slotmap=3D{} @@ -5062,19 +5064,21 @@ =09 for myslot in slotmap: counterkeys =3D slotmap[myslot].keys() - counterkeys.sort() if not counterkeys: continue counterkeys.sort() - pkgmap[mycp]["protected"].add( + pkgmap[mykey]["protected"].add( slotmap[myslot][counterkeys[-1]]) del counterkeys[-1] #be pretty and get them in order of merge: for ckey in counterkeys: - pkgmap[mycp]["selected"].add(slotmap[myslot][ckey]) - numselected +=3D 1 + mypkg =3D slotmap[myslot][ckey] + if mypkg not in all_selected: + pkgmap[mykey]["selected"].add(mypkg) + all_selected.add(mypkg) # ok, now the last-merged package # is protected, and the rest are selected + numselected =3D len(all_selected) if global_unmerge and not numselected: portage.writemsg_stdout("\n>>> No outdated packages were found on you= r system.\n") return 0 @@ -5087,9 +5091,6 @@ finally: if vdb_lock: portage.locks.unlockdir(vdb_lock) - all_selected =3D set() - for x in pkgmap: - all_selected.update(pkgmap[x]["selected"]) =09 from portage.sets.base import EditablePackageSet =09 @@ -5111,7 +5112,7 @@ # we don't want to unmerge packages that are still listed in user-edita= ble package sets # listed in "world" as they would be remerged on the next update of "wo= rld" or the=20 # relevant package sets. - for cp in pkgmap: + for cp in xrange(len(pkgmap)): for cpv in pkgmap[cp]["selected"].copy(): parents =3D [] for s in installed_sets: @@ -5139,21 +5140,20 @@ =09 del installed_sets =09 - for x in pkgmap: + for x in xrange(len(pkgmap)): selected =3D pkgmap[x]["selected"] if not selected: continue for mytype, mylist in pkgmap[x].iteritems(): if mytype =3D=3D "selected": continue - pkgmap[x][mytype] =3D \ - set([cpv for cpv in mylist if cpv not in all_selected]) - cp =3D portage.cpv_getkey(list(selected)[0]) + mylist.difference_update(all_selected) + cp =3D portage.cpv_getkey(iter(selected).next()) for y in localtree.dep_match(cp): if y not in pkgmap[x]["omitted"] and \ - y not in pkgmap[x]["selected"] and \ - y not in pkgmap[x]["protected"] and \ - y not in all_selected: + y not in pkgmap[x]["selected"] and \ + y not in pkgmap[x]["protected"] and \ + y not in all_selected: pkgmap[x]["omitted"].add(y) if global_unmerge and not pkgmap[x]["selected"]: #avoid cluttering the preview printout with stuff that isn't getting = unmerged @@ -5213,7 +5213,7 @@ if not autoclean: countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging") =20 - for x in pkgmap: + for x in xrange(len(pkgmap)): for y in pkgmap[x]["selected"]: print ">>> Unmerging "+y+"..." emergelog(xterm_titles, "=3D=3D=3D Unmerging... ("+y+")") --=20 gentoo-commits@lists.gentoo.org mailing list