From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QFCpm-0002Wp-6E for garchives@archives.gentoo.org; Wed, 27 Apr 2011 22:03:46 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B45091C0D5; Wed, 27 Apr 2011 22:03:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5F1601C0C3 for ; Wed, 27 Apr 2011 22:03:38 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DCB5B1B401C for ; Wed, 27 Apr 2011 22:03:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 43E3580505 for ; Wed, 27 Apr 2011 22:03:37 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <3bfc83bb03b7c7edd031df62a7a38acba4d628e2.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: man/emerge.1 pym/_emerge/depgraph.py pym/_emerge/main.py X-VCS-Directories: man/ pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 3bfc83bb03b7c7edd031df62a7a38acba4d628e2 Date: Wed, 27 Apr 2011 22:03:37 +0000 (UTC) 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: X-Archives-Hash: 4ae0431cc1f740c8b5c5dfc046afa35a commit: 3bfc83bb03b7c7edd031df62a7a38acba4d628e2 Author: David James google com> AuthorDate: Wed Apr 27 22:02:39 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Apr 27 22:02:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D3bfc83bb emerge: add 3 new options similar to --exclude Add --nousepkg-atoms, --useoldpkg-atoms, and --reinstall-atoms flag to Portage reinstall-atoms accepts a space separated list of package names or slot atoms. Emerge will treat matching packages as if they are not installed, and reinstall them if necessary. useoldpkg-atoms accepts a space separated list of package names or slot atoms. Emerge will prefer matching binary packages over newer unbuilt packages. This is useful in case you want to request that a particular package won't be rebuilt from source. nousepkg-atoms accepts a space separated list of package names or slot atoms. Emerge will ignore matching binary packages. Change-Id: I0d73039c6a4cd63695b28ffc80215628e0e05c95 BUG=3Dchromium-os:12507 TEST=3DTry out the flag Review URL: http://codereview.chromium.org/6577024 --- man/emerge.1 | 13 ++++++++ pym/_emerge/depgraph.py | 78 ++++++++++++++++++++++++++++++++++-------= ----- pym/_emerge/main.py | 79 ++++++++++++++++++++++++++++++++++-------= ------ 3 files changed, 128 insertions(+), 42 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index 2693b67..67f3e47 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -479,6 +479,10 @@ may have changed. Disables the spinner for the session. The spinner is active when the terminal device is determined to be a TTY. This flag disables it regard= less. .TP +.BR "\-\-nousepkg\-atoms " ATOMS +A space separated list of package names or slot atoms. Emerge will ignor= e +matching binary packages. +.TP .BR "\-\-oneshot " (\fB\-1\fR) Emerge as normal, but do not add the packages to the world file for later updating. @@ -549,6 +553,11 @@ changed since installation. Unlike \fB\-\-newuse\fR= , this option does not trigger reinstallation when flags that the user has not enabled are added or removed. .TP +.BR "\-\-reinstall\-atoms " ATOMS +A space separated list of package names or slot atoms. Emerge will treat +matching packages as if they are not installed, and reinstall them if +necessary. +.TP .BR \-\-root=3DDIR Set the \fBROOT\fR environment variable. .TP @@ -606,6 +615,10 @@ atoms may match multiple versions of slotted package= s. Use unbuilt ebuild metadata for visibility checks on built packages. .TP +.BR "\-\-useoldpkg\-atoms " ATOMS +A space separated list of package names or slot atoms. Emerge will prefe= r +matching binary packages over newer unbuilt packages. +.TP .BR "\-\-usepkg [ y | n ] (\-k short option)" Tells emerge to use binary packages (from $PKGDIR) if they are available= , thus=20 possibly avoiding some time\-consuming compiles. This option is useful = for CD=20 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index a0a4622..84e7d24 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -70,6 +70,16 @@ class _scheduler_graph_config(object): self.graph =3D graph self.mergelist =3D mergelist =20 +def _wildcard_set(atoms): + pkgs =3D InternalPackageSet(allow_wildcard=3DTrue) + for x in atoms: + try: + x =3D Atom(x, allow_wildcard=3DTrue) + except portage.exception.InvalidAtom: + x =3D Atom("*/" + x, allow_wildcard=3DTrue) + pkgs.add(x) + return pkgs + class _frozen_depgraph_config(object): =20 def __init__(self, settings, trees, myopts, spinner): @@ -109,13 +119,14 @@ class _frozen_depgraph_config(object): =20 self._required_set_names =3D set(["world"]) =20 - self.excluded_pkgs =3D InternalPackageSet(allow_wildcard=3DTrue) - for x in ' '.join(myopts.get("--exclude", [])).split(): - try: - x =3D Atom(x, allow_wildcard=3DTrue) - except portage.exception.InvalidAtom: - x =3D Atom("*/" + x, allow_wildcard=3DTrue) - self.excluded_pkgs.add(x) + atoms =3D ' '.join(myopts.get("--exclude", [])).split() + self.excluded_pkgs =3D _wildcard_set(atoms) + atoms =3D ' '.join(myopts.get("--reinstall-atoms", [])).split() + self.reinstall_atoms =3D _wildcard_set(atoms) + atoms =3D ' '.join(myopts.get("--nousepkg-atoms", [])).split() + self.nousepkg_atoms =3D _wildcard_set(atoms) + atoms =3D ' '.join(myopts.get("--useoldpkg-atoms", [])).split() + self.useoldpkg_atoms =3D _wildcard_set(atoms) =20 class _depgraph_sets(object): def __init__(self): @@ -1237,6 +1248,7 @@ class depgraph(object): vardb =3D root_config.trees["vartree"].dbapi traversed_virt_pkgs =3D set() =20 + reinstall_atoms =3D self._frozen_config.reinstall_atoms for atom, child in self._minimize_children( pkg, dep_priority, root_config, selected_atoms[pkg]): =20 @@ -1254,7 +1266,9 @@ class depgraph(object): =20 mypriority =3D dep_priority.copy() if not atom.blocker: - inst_pkgs =3D vardb.match_pkgs(atom) + inst_pkgs =3D [inst_pkg for inst_pkg in vardb.match_pkgs(atom) + if not reinstall_atoms.findAtomForPackage(inst_pkg, + modified_use=3Dself._pkg_use_enabled(inst_pkg))] if inst_pkgs: for inst_pkg in inst_pkgs: if self._pkg_visibility_check(inst_pkg): @@ -1344,7 +1358,9 @@ class depgraph(object): # This is a GLEP 37 virtual, so its deps are all runtime. mypriority =3D self._priority(runtime=3DTrue) if not atom.blocker: - inst_pkgs =3D vardb.match_pkgs(atom) + inst_pkgs =3D [inst_pkg for inst_pkg in vardb.match_pkgs(atom) + if not reinstall_atoms.findAtomForPackage(inst_pkg, + modified_use=3Dself._pkg_use_enabled(inst_pkg))] if inst_pkgs: for inst_pkg in inst_pkgs: if self._pkg_visibility_check(inst_pkg): @@ -3161,6 +3177,10 @@ class depgraph(object): dont_miss_updates =3D "--update" in self._frozen_config.myopts use_ebuild_visibility =3D self._frozen_config.myopts.get( '--use-ebuild-visibility', 'n') !=3D 'n' + reinstall_atoms =3D self._frozen_config.reinstall_atoms + nousepkg_atoms =3D self._frozen_config.nousepkg_atoms + useoldpkg_atoms =3D self._frozen_config.useoldpkg_atoms + matched_oldpkg =3D [] # Behavior of the "selective" parameter depends on # whether or not a package matches an argument atom. # If an installed package provides an old-style @@ -3200,7 +3220,14 @@ class depgraph(object): modified_use=3Dself._pkg_use_enabled(pkg)): continue =20 - if packages_with_invalid_use_config and \ + if built and not installed and nousepkg_atoms.findAtomForPackage(pk= g, \ + modified_use=3Dself._pkg_use_enabled(pkg)): + break + + useoldpkg =3D useoldpkg_atoms.findAtomForPackage(pkg, \ + modified_use=3Dself._pkg_use_enabled(pkg)) + + if packages_with_invalid_use_config and (not built or not useoldpkg= ) and \ (not pkg.installed or dont_miss_updates): # Check if a higher version was rejected due to user # USE configuration. The packages_with_invalid_use_config @@ -3282,7 +3309,7 @@ class depgraph(object): # instances (installed or binary). # If --usepkgonly is enabled, assume that # the ebuild status should be ignored. - if not use_ebuild_visibility and usepkgonly: + if not use_ebuild_visibility and (usepkgonly or useoldpkg): if pkg.installed and pkg.masks: continue else: @@ -3419,7 +3446,7 @@ class depgraph(object): break # Compare built package to current config and # reject the built package if necessary. - if built and (not installed or matched_pkgs_ignore_use) and \ + if built and not useoldpkg and (not installed or matched_pkgs_ignor= e_use) and \ ("--newuse" in self._frozen_config.myopts or \ "--reinstall" in self._frozen_config.myopts or \ "--binpkg-respect-use" in self._frozen_config.myopts): @@ -3434,7 +3461,7 @@ class depgraph(object): forced_flags.update(pkgsettings.useforce) forced_flags.update(pkgsettings.usemask) cur_iuse =3D iuses - if myeb and not usepkgonly: + if myeb and not usepkgonly and not useoldpkg: cur_iuse =3D myeb.iuse.all if self._reinstall_for_flags(forced_flags, old_use, iuses, @@ -3442,7 +3469,7 @@ class depgraph(object): break # Compare current config to installed package # and do not reinstall if possible. - if not installed and \ + if not installed and not useoldpkg and \ ("--newuse" in self._frozen_config.myopts or \ "--reinstall" in self._frozen_config.myopts) and \ cpv in vardb.match(atom): @@ -3460,8 +3487,13 @@ class depgraph(object): cur_use, cur_iuse) if reinstall_for_flags: reinstall =3D True + if reinstall_atoms.findAtomForPackage(pkg, \ + modified_use=3Dself._pkg_use_enabled(pkg)): + reinstall =3D True if not built: myeb =3D pkg + elif useoldpkg: + matched_oldpkg.append(pkg) matched_packages.append(pkg) if reinstall_for_flags: self._dynamic_config._reinstall_nodes[pkg] =3D \ @@ -3545,14 +3577,20 @@ class depgraph(object): allow_license_changes=3Dallow_license_changes): return pkg, existing_node =20 - bestmatch =3D portage.best( - [pkg.cpv for pkg in matched_packages \ + visible_matches =3D [] + if matched_oldpkg: + visible_matches =3D [pkg.cpv for pkg in matched_oldpkg \ if self._pkg_visibility_check(pkg, allow_unstable_keywords=3Dallow_= unstable_keywords, - allow_license_changes=3Dallow_license_changes)]) - if not bestmatch: + allow_license_changes=3Dallow_license_changes)] + if not visible_matches: + visible_matches =3D [pkg.cpv for pkg in matched_packages \ + if self._pkg_visibility_check(pkg, allow_unstable_keywords=3Dallow_= unstable_keywords, + allow_license_changes=3Dallow_license_changes)] + if visible_matches: + bestmatch =3D portage.best(visible_matches) + else: # all are masked, so ignore visibility - bestmatch =3D portage.best( - [pkg.cpv for pkg in matched_packages]) + bestmatch =3D portage.best([pkg.cpv for pkg in matched_packages]) matched_packages =3D [pkg for pkg in matched_packages \ if portage.dep.cpvequal(pkg.cpv, bestmatch)] =20 diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 96fee89..af243c0 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -544,6 +544,23 @@ def insert_optional_args(args): =20 return new_args =20 +def _find_bad_atoms(atoms): + bad_atoms =3D [] + for x in ' '.join(atoms).split(): + bad_atom =3D False + try: + atom =3D portage.dep.Atom(x, allow_wildcard=3DTrue) + except portage.exception.InvalidAtom: + try: + atom =3D portage.dep.Atom("*/"+x, allow_wildcard=3DTrue) + except portage.exception.InvalidAtom: + bad_atom =3D True + + if bad_atom or atom.operator or atom.blocker or atom.use: + bad_atoms.append(x) + return bad_atoms + + def parse_opts(tmpcmdline, silent=3DFalse): myaction=3DNone myopts =3D {} @@ -680,6 +697,14 @@ def parse_opts(tmpcmdline, silent=3DFalse): "choices":["changed-use"] }, =20 + "--reinstall-atoms": { + "help" :"A space separated list of package names or slot atoms. " += \ + "Emerge will treat matching packages as if they are not " + \ + "installed, and reinstall them if necessary. Implies --deep.", + + "action" : "append", + }, + "--binpkg-respect-use": { "help" : "discard binary packages if their use flags \ don't match the current configuration", @@ -701,6 +726,13 @@ def parse_opts(tmpcmdline, silent=3DFalse): "choices" : true_y_or_n }, =20 + "--nousepkg-atoms": { + "help" :"A space separated list of package names or slot atoms. " += \ + "Emerge will ignore matching binary packages. ", + + "action" : "append", + }, + "--package-moves": { "help" : "perform package moves when necessary", "type" : "choice", @@ -764,6 +796,13 @@ def parse_opts(tmpcmdline, silent=3DFalse): "choices" : true_y_or_n }, =20 + "--useoldpkg-atoms": { + "help" :"A space separated list of package names or slot atoms. " += \ + "Emerge will prefer matching binary packages over newer unbuilt pack= ages. ", + + "action" : "append", + }, + "--usepkg": { "shortopt" : "-k", "help" : "use binary packages", @@ -852,32 +891,28 @@ def parse_opts(tmpcmdline, silent=3DFalse): myoptions.depclean_lib_check =3D True =20 if myoptions.exclude: - exclude =3D [] - bad_atoms =3D [] - for x in ' '.join(myoptions.exclude).split(): - bad_atom =3D False - try: - atom =3D portage.dep.Atom(x, allow_wildcard=3DTrue) - except portage.exception.InvalidAtom: - try: - atom =3D portage.dep.Atom("*/"+x, allow_wildcard=3DTrue) - except portage.exception.InvalidAtom: - bad_atom =3D True - =09 - if bad_atom: - bad_atoms.append(x) - else: - if atom.operator or atom.blocker or atom.use: - bad_atoms.append(x) - else: - exclude.append(atom) - + bad_atoms =3D _find_bad_atoms(myoptions.exclude) if bad_atoms and not silent: parser.error("Invalid Atom(s) in --exclude parameter: '%s' (only pack= age names and slot atoms (with wildcards) allowed)\n" % \ (",".join(bad_atoms),)) =20 - if myoptions.fail_clean in true_y: - myoptions.fail_clean =3D True + if myoptions.reinstall_atoms: + bad_atoms =3D _find_bad_atoms(myoptions.reinstall_atoms) + if bad_atoms and not silent: + parser.error("Invalid Atom(s) in --reinstall-atoms parameter: '%s' (o= nly package names and slot atoms (with wildcards) allowed)\n" % \ + (",".join(bad_atoms),)) + + if myoptions.nousepkg_atoms: + bad_atoms =3D _find_bad_atoms(myoptions.nousepkg_atoms) + if bad_atoms and not silent: + parser.error("Invalid Atom(s) in --nousepkg-atoms parameter: '%s' (on= ly package names and slot atoms (with wildcards) allowed)\n" % \ + (",".join(bad_atoms),)) + + if myoptions.useoldpkg_atoms: + bad_atoms =3D _find_bad_atoms(myoptions.useoldpkg_atoms) + if bad_atoms and not silent: + parser.error("Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (o= nly package names and slot atoms (with wildcards) allowed)\n" % \ + (",".join(bad_atoms),)) =20 if myoptions.getbinpkg in true_y: myoptions.getbinpkg =3D True