From f1a082e0a271970f14567c7d579dbe8931f5328a Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 2 Apr 2009 12:58:32 +0000 Subject: [PATCH] Merged from trunk -r13244:13253 | 13245 | Add support for --rdeps-only and --root-deps options which | | zmedico | are useful in combination with $ROOT. Thanks to Ned Ludd | | | for the initial patch. | | 13246 | Add a --root option that sets $ROOT (complements the | | zmedico | --config-root option). | | 13247 | Document --root and --config-root. | | zmedico | | | 13248 | Inside depgraph.validate_blockers(), prevent false positives | | zmedico | in PROVIDE virtual blocker matches that can occur for | | | packages for packages that don't actual have the appropriate | | | value in PROVIDE (triggered by profile 'virtuals' settings). | | | Thanks to Ned Ludd for reporting. | | 13249 | Fix bug in old-style virtuals code from previous commit. | | zmedico | | | 13250 | Update dep_getusedeps() docstring. Thanks to Douglass | | zmedico | Anderson . | | 13251 | Implement _use_dep.__repr__(). Thanks to Douglass Anderson | | zmedico | for the suggestion. | | 13252 | Bug #264291 - Fix inappropriate build dir creation for | | zmedico | emerge --fetchonly. | | 13253 | Fix --newuse code to compare installed package USE to the | | zmedico | USE that a binary package was built with (instead of | | | config["PORTAGE_USE"]). | svn path=/main/branches/prefix/; revision=13276 --- man/emerge.1 | 20 +++++++++++++++++++- pym/_emerge/__init__.py | 40 +++++++++++++++++++++++++++++++--------- pym/_emerge/help.py | 30 ++++++++++++++++++++++++++++++ pym/portage/__init__.py | 8 +++++++- pym/portage/dep.py | 7 +++++-- 5 files changed, 92 insertions(+), 13 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index b838f624d..4af770716 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -414,12 +414,29 @@ b blocked by another package (automatically resolved conflict) Results may vary, but the general outcome is a reduced or condensed output from portage's displays. .TP +.BR "\-\-rdeps\-only" +Discard all build\-time dependencies. This option is commonly used together +with \fBROOT\fR and it should not be enabled under normal circumstances. For +currently supported \fBEAPI\fR values, the dependencies specified in the +\fBDEPEND\fR variable are discarded. However, behavior may change for new +\fBEAPI\fRs when related extensions are added in the future. +.TP .BR "\-\-reinstall changed\-use" Tells emerge to include installed packages where USE flags have 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 \-\-root=DIR +Set the \fBROOT\fR environment variable. +.TP +.BR "\-\-root\-deps" +Install build\-time dependencies to \fBROOT\fR instead of /. This option +should not be enabled under normal circumstances. For currently supported +\fBEAPI\fR values, the dependencies specified in the \fBDEPEND\fR variable +are used. However, behavior may change for new +\fBEAPI\fRs when related extensions are added in the future. +.TP .BR "\-\-skipfirst" This option is only valid when used with \fB\-\-resume\fR. It removes the first package in the resume list. Dependencies are recalculated for @@ -474,7 +491,8 @@ command line. .TP \fBROOT\fR = \fI[path]\fR Use \fBROOT\fR to specify the target root filesystem to be used for -merging packages or ebuilds. This variable can be set in \fBmake.conf\fR(5). +merging packages or ebuilds. This variable can be set via the \fB\-\-root\fR +option or in \fBmake.conf\fR(5) (the command line overrides other settings). .br Defaults to /. .TP diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 975ea3d03..f2fb37ead 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -222,6 +222,7 @@ options=[ "--nospinner", "--oneshot", "--onlydeps", "--pretend", "--quiet", "--resume", +"--rdeps-only", "--root-deps", "--searchdesc", "--selective", "--skipfirst", "--tree", @@ -1814,8 +1815,6 @@ class EbuildFetchonly(SlotObject): portdb = root_config.trees["porttree"].dbapi ebuild_path = portdb.findname(pkg.cpv) debug = settings.get("PORTAGE_DEBUG") == "1" - portage.prepare_build_dirs(self.pkg.root, self.settings, 0) - retval = portage.doebuild(ebuild_path, "fetch", self.settings["ROOT"], self.settings, debug=debug, listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all, @@ -5302,8 +5301,16 @@ class depgraph(object): if removal_action and self.myopts.get("--with-bdeps", "y") == "n": edepend["DEPEND"] = "" + bdeps_root = "/" + if self.target_root != "/": + if "--root-deps" in self.myopts: + bdeps_root = myroot + if "--rdeps-only" in self.myopts: + bdeps_root = "/" + edepend["DEPEND"] = "" + deps = ( - ("/", edepend["DEPEND"], + (bdeps_root, edepend["DEPEND"], self._priority(buildtime=(not bdeps_optional), optional=bdeps_optional)), (myroot, edepend["RDEPEND"], self._priority(runtime=True)), @@ -6427,7 +6434,7 @@ class depgraph(object): old_use = vardb.aux_get(cpv, ["USE"])[0].split() old_iuse = set(filter_iuse_defaults( vardb.aux_get(cpv, ["IUSE"])[0].split())) - cur_use = pkgsettings["PORTAGE_USE"].split() + cur_use = pkg.use.enabled cur_iuse = pkg.iuse.all reinstall_for_flags = \ self._reinstall_for_flags( @@ -6775,6 +6782,11 @@ class depgraph(object): not self._have_new_virt(blocker.root, blocker.cp): provider_virtual = True + # Use this to check PROVIDE for each matched package + # when necessary. + atom_set = InternalPackageSet( + initial_atoms=[blocker.atom]) + if provider_virtual: atoms = [] for provider_entry in virtuals[blocker.cp]: @@ -6785,13 +6797,17 @@ class depgraph(object): else: atoms = [blocker.atom] - blocked_initial = [] + blocked_initial = set() for atom in atoms: - blocked_initial.extend(initial_db.match_pkgs(atom)) + for pkg in initial_db.match_pkgs(atom): + if atom_set.findAtomForPackage(pkg): + blocked_initial.add(pkg) - blocked_final = [] + blocked_final = set() for atom in atoms: - blocked_final.extend(final_db.match_pkgs(atom)) + for pkg in final_db.match_pkgs(atom): + if atom_set.findAtomForPackage(pkg): + blocked_final.add(pkg) if not blocked_initial and not blocked_final: parent_pkgs = self._blocker_parents.parent_nodes(blocker) @@ -14876,7 +14892,11 @@ def parse_opts(tmpcmdline, silent=False): "help":"specify conditions to trigger package reinstallation", "type":"choice", "choices":["changed-use"] - } + }, + "--root": { + "help" : "specify the target root filesystem for merging packages", + "action" : "store" + }, } from optparse import OptionParser @@ -15401,6 +15421,8 @@ def emerge_main(): os.environ["PORTAGE_DEBUG"] = "1" if "--config-root" in myopts: os.environ["PORTAGE_CONFIGROOT"] = myopts["--config-root"] + if "--root" in myopts: + os.environ["ROOT"] = myopts["--root"] # Portage needs to ensure a sane umask for the files it creates. os.umask(022) diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index 2c5f04bbf..15aa88a02 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -269,6 +269,12 @@ def help(myaction,myopts,havecolor=1): for line in wrap(desc, desc_width): print desc_indent + line print + print " "+green("--config-root=DIR") + desc = "Set the PORTAGE_CONFIGROOT environment variable " + \ + "which is documented in the emerge(1) man page." + for line in wrap(desc, desc_width): + print desc_indent + line + print print " "+green("--debug")+" ("+green("-d")+" short option)" print " Tell emerge to run the ebuild command in --debug mode. In this" print " mode, the bash build environment will run with the -x option," @@ -404,12 +410,36 @@ def help(myaction,myopts,havecolor=1): print " Effects vary, but the general outcome is a reduced or condensed" print " output from portage's displays." print + print " "+green("--rdeps-only") + desc = "Discard all build-time dependencies. This option is commonly used together " + \ + "with ROOT and it should not be enabled under normal circumstances. For " + \ + "currently supported EAPI values, the dependencies specified in the " + \ + "DEPEND variable are discarded. However, behavior may change for new " + \ + "EAPIs when related extensions are added in the future." + for line in wrap(desc, desc_width): + print desc_indent + line + print print " "+green("--reinstall ") + turquoise("changed-use") print " Tells emerge to include installed packages where USE flags have" print " changed since installation. Unlike --newuse, this option does" print " not trigger reinstallation when flags that the user has not" print " enabled are added or removed." print + print " "+green("--root=DIR") + desc = "Set the ROOT environment variable " + \ + "which is documented in the emerge(1) man page." + for line in wrap(desc, desc_width): + print desc_indent + line + print + print " "+green("--root-deps") + desc = "Install build-time dependencies to ROOT instead of /. This option " + \ + "should not be enabled under normal circumstances. For currently supported " + \ + "EAPI values, the dependencies specified in the DEPEND variable " + \ + "are used. However, behavior may change for new " + \ + "EAPIs when related extensions are added in the future." + for line in wrap(desc, desc_width): + print desc_indent + line + print print " "+green("--skipfirst") desc = "This option is only valid when " + \ "used with --resume. It removes the " + \ diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 64ca4b860..fee4c04bc 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5878,6 +5878,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, logfile=None, returnpid=returnpid) return retval + restrict = set(mysettings.get('PORTAGE_RESTRICT', '').split()) # get possible slot information from the deps file if mydo == "depend": writemsg("!!! DEBUG: dbkey: %s\n" % str(dbkey), 2) @@ -5986,8 +5987,13 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, mysettings["PF"], myroot, mysettings, vartree=vartree) # Build directory creation isn't required for any of these. + # In the fetch phase, the directory is needed only for RESTRICT=fetch + # in order to satisfy the sane $PWD requirement (from bug #239560) + # when pkg_nofetch is spawned. have_build_dirs = False - if not parallel_fetchonly and mydo not in ("digest", "help", "manifest"): + if not parallel_fetchonly and \ + mydo not in ('digest', 'help', 'manifest') and \ + not (mydo == 'fetch' and 'fetch' not in restrict): mystatus = prepare_build_dirs(myroot, mysettings, cleanup) if mystatus: return mystatus diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 0bff1104c..866258715 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -417,6 +417,9 @@ class _use_dep(object): return "" return "[%s]" % (",".join(self.tokens),) + def __repr__(self): + return "portage.dep._use_dep(%s)" % repr(self.tokens) + def evaluate_conditionals(self, use): """ Create a new instance with conditionals evaluated. @@ -740,8 +743,8 @@ def dep_getusedeps( depend ): Pull a listing of USE Dependencies out of a dep atom. Example usage: - >>> dep_getusedeps('app-misc/test:3[foo][-bar]') - ['foo','-bar'] + >>> dep_getusedeps('app-misc/test:3[foo,-bar]') + ('foo', '-bar') @param depend: The depstring to process @type depend: String -- 2.26.2