From 15c88e9b527c1265eda48a7b0f1ce6eae1974096 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Tue, 7 Jul 2009 15:10:15 +0000 Subject: [PATCH] Merged from trunk -r13794:13803 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit | 13798 | Bug #273631 - Add default src_install implementation for | | zmedico | EAPI 3. Thanks to Markus Meier for this | | | patch (and people in #gentoo-portage for bash syntax | | | tweaks). | | 13799 | Bug #273622 - Add pkg_pretend support for the ebuild(1) | | zmedico | command (emerge support not implemented yet). Thanks to | | | Markus Meier for this patch. | | 13800 | Bug #273640 - Add --disable-dependency-tracking to econf | | zmedico | arguments for EAPI 3. Thanks to Markus Meier | | | for this patch. | | 13801 | Optimize dbapi._iter_match_use() so that it shares a single | | zmedico | compiled regex for all implicit iuse checks. This avoids | | | lots of expensibe re.compile() calls. Thanks to Marat | | | Radchenko for the initial | | | patch. | | 13802 | Bug #276866 - --binpkg-respect-use < y | n > Tells emerge to | | zmedico | ignore binary packages if their use flags don't match the | | | current configuration. (default: ´n´) Thanks to Sebastian | | | Mingramm (few) for this patch (small | | | tweaks by me). | | 13803 | Shorten the preserved libs message when in --quiet mode. | | zmedico | Thanks to Sebastian Mingramm (few) for | | | this patch. | svn path=/main/branches/prefix/; revision=13804 --- bin/ebuild.sh | 56 ++++++++++++++++++++++++++++++++--- man/emerge.1 | 4 +++ pym/_emerge/depgraph.py | 6 ++-- pym/_emerge/help.py | 7 +++++ pym/_emerge/main.py | 28 +++++++++++++++--- pym/portage/__init__.py | 6 +++- pym/portage/dbapi/__init__.py | 14 ++++----- pym/portage/dbapi/porttree.py | 1 - 8 files changed, 103 insertions(+), 19 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index ff47591e5..1e86a58e1 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -493,6 +493,11 @@ econf() { done fi + # EAPI=3 adds --disable-dependency-tracking to econf + if ! hasq "$EAPI" 0 1 2 ; then + set -- --disable-dependency-tracking "$@" + fi + # if the profile defines a location to install libs to aside from default, pass it on. # if the ebuild passes in --libdir, they're responsible for the conf_libdir fun. local CONF_LIBDIR LIBDIR_VAR="LIBDIR_${ABI}" @@ -599,6 +604,10 @@ _eapi0_src_compile() { _eapi2_src_compile } +_eapi0_src_install() { + _eapi2_src_install +} + _eapi0_src_test() { if emake -j1 check -n &> /dev/null; then vecho ">>> Test phase [check]: ${CATEGORY}/${PF}" @@ -622,6 +631,10 @@ _eapi1_src_compile() { _eapi2_src_compile } +_eapi1_src_install() { + _eapi2_src_install +} + _eapi2_src_configure() { if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then econf @@ -634,15 +647,33 @@ _eapi2_src_compile() { fi } -src_install() { +_eapi2_src_install() { if use prefix ; then - # this avoids misc errors in prefix because it doesn't exist + # this avoids misc errors in Prefix because it doesn't exist # by default mkdir -p "${ED}" return fi } +_eapi3_src_install() { + if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then + emake DESTDIR="${D}" install + fi + + if [[ -z $DOCS ]] ; then + local d + for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \ + THANKS BUGS FAQ CREDITS CHANGELOG ; do + [[ -s "${d}" ]] && dodoc "${d}" + done + elif [[ $(declare -p DOCS) == "declare -a "* ]] ; then + dodoc "${DOCS[@]}" + else + dodoc ${DOCS} + fi +} + ebuild_phase() { declare -F "$1" >/dev/null && qa_call $1 } @@ -655,6 +686,10 @@ ebuild_phase_with_hooks() { done } +dyn_pretend() { + ebuild_phase_with_hooks pkg_pretend +} + dyn_setup() { ebuild_phase_with_hooks pkg_setup } @@ -1073,6 +1108,7 @@ dyn_help() { echo "than one option is specified, each will be executed in order." echo echo " help : show this help screen" + echo " pretend : execute package specific pretend actions" echo " setup : execute package specific setup actions" echo " fetch : download source archive(s) and patches" echo " digest : create a manifest file for the package" @@ -1340,6 +1376,10 @@ _ebuild_arg_to_phase() { local phase_func="" case "$arg" in + pretend) + ! hasq $eapi 0 1 2 && \ + phase_func=pkg_pretend + ;; setup) phase_func=pkg_setup ;; @@ -1433,6 +1473,9 @@ _ebuild_phase_funcs() { declare -F src_compile >/dev/null || \ src_compile() { _eapi2_src_compile "$@" ; } + [[ $eapi == 2 ]] || declare -F src_install >/dev/null || \ + src_install() { _eapi3_src_install "$@" ; } + if hasq $phase_func $default_phases ; then _eapi2_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } @@ -1793,11 +1836,16 @@ _source_ebuild() { pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm pkg_setup src_test src_unpack" ;; - *) + 2) valid_phases="src_compile pkg_config src_configure pkg_info src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst src_prepare pkg_prerm pkg_setup src_test src_unpack" ;; + *) + valid_phases="src_compile pkg_config src_configure pkg_info + src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst + src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack" + ;; esac DEFINED_PHASES= @@ -1996,7 +2044,7 @@ ebuild_main() { fi export SANDBOX_ON="0" ;; - help|setup|preinst) + help|pretend|setup|preinst) #pkg_setup needs to be out of the sandbox for tmp file creation; #for example, awking and piping a file in /tmp requires a temp file to be created #in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break. diff --git a/man/emerge.1 b/man/emerge.1 index 787e2e37f..852116d18 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -249,6 +249,10 @@ it is interpreted as acceptance of the first choice. Note that the input buffer is not cleared prior to the prompt, so an accidental press of the "Enter" key at any time prior to the prompt will be interpreted as a choice!\fR .TP +.BR "\-\-binpkg\-respect\-use < y | n >" +Tells emerge to ignore binary packages if their use flags +don't match the current configuration. (default: \'n\') +.TP .BR "\-\-buildpkg " (\fB\-b\fR) Tells emerge to build binary packages for all ebuilds processed in addition to actually merging the packages. Useful for maintainers diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 47ddc4907..a000e900a 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -574,7 +574,8 @@ class depgraph(object): orig_use, orig_iuse, cur_use, cur_iuse): """Return a set of flags that trigger reinstallation, or None if there are no such flags.""" - if "--newuse" in self._frozen_config.myopts: + if "--newuse" in self._frozen_config.myopts or \ + "--binpkg-respect-use" in self._frozen_config.myopts: flags = set(orig_iuse.symmetric_difference( cur_iuse).difference(forced_flags)) flags.update(orig_iuse.intersection(orig_use).symmetric_difference( @@ -2157,7 +2158,8 @@ class depgraph(object): # reject the built package if necessary. if built and not installed and \ ("--newuse" in self._frozen_config.myopts or \ - "--reinstall" in self._frozen_config.myopts): + "--reinstall" in self._frozen_config.myopts or \ + "--binpkg-respect-use" in self._frozen_config.myopts): iuses = pkg.iuse.all old_use = pkg.use.enabled if myeb: diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index 34a4bda29..f78c2e0e0 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -249,6 +249,13 @@ def help(myopts, havecolor=1): print " to the prompt, so an accidental press of the \"Enter\" key at any" print " time prior to the prompt will be interpreted as a choice!" print + print " " + green("--binpkg-respect-use") + \ + " < " + turquoise("y") + " | " + turquoise("n") + " >" + desc = "Tells emerge to ignore binary packages if their use flags" + \ + " don't match the current configuration. (default: 'n')" + for line in wrap(desc, desc_width): + print desc_indent + line + print print " "+green("--buildpkg")+" ("+green("-b")+" short option)" desc = "Tells emerge to build binary packages for all ebuilds processed in" + \ " addition to actually merging the packages. Useful for maintainers" + \ diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 19b9cf524..1a4ee877d 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -215,15 +215,21 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): if icount > 0: out.einfo("Processed %d info files." % (icount,)) -def display_preserved_libs(vardbapi): +def display_preserved_libs(vardbapi, myopts): MAX_DISPLAY = 3 # Ensure the registry is consistent with existing files. vardbapi.plib_registry.pruneNonExisting() if vardbapi.plib_registry.hasEntries(): - print - print colorize("WARN", "!!!") + " existing preserved libs:" + if "--quiet" in myopts: + print + print colorize("WARN", "!!!") + " existing preserved libs found" + return + else: + print + print colorize("WARN", "!!!") + " existing preserved libs:" + plibdata = vardbapi.plib_registry.getPreservedLibs() linkmap = vardbapi.linkmap consumer_map = {} @@ -360,7 +366,7 @@ def post_emerge(root_config, myopts, mtimedb, retval): display_news_notification(root_config, myopts) if retval in (None, os.EX_OK) or (not "--pretend" in myopts): - display_preserved_libs(vardbapi) + display_preserved_libs(vardbapi, myopts) sys.exit(retval) @@ -381,6 +387,7 @@ def insert_optional_args(args): jobs_opts = ("-j", "--jobs") default_arg_opts = { '--deselect' : ('n',), + '--binpkg-respect-use' : ('n', 'y',), '--root-deps' : ('rdeps',), } arg_stack = args[:] @@ -499,6 +506,14 @@ def parse_opts(tmpcmdline, silent=False): "type":"choice", "choices":["changed-use"] }, + + "--binpkg-respect-use": { + "help" : "discard binary packages if their use flags \ + don't match the current configuration", + "type" : "choice", + "choices" : ("True", "y", "n") + }, + "--root": { "help" : "specify the target root filesystem for merging packages", "action" : "store" @@ -540,6 +555,11 @@ def parse_opts(tmpcmdline, silent=False): if myoptions.deselect == "True": myoptions.deselect = True + if myoptions.binpkg_respect_use in ("y", "True",): + myoptions.binpkg_respect_use = True + else: + myoptions.binpkg_respect_use = None + if myoptions.root_deps == "True": myoptions.root_deps = True diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index dc47cb13a..85c5312e0 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -4942,6 +4942,9 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0, if mydo == "prepare" and eapi in ("0", "1"): return os.EX_OK + if mydo == "pretend" and eapi in ("0", "1", "2"): + return os.EX_OK + kwargs = actionmap[mydo]["args"] mysettings["EBUILD_PHASE"] = mydo _doebuild_exit_status_unlink( @@ -5907,7 +5910,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, clean_phases = ("clean", "cleanrm") validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst", - "config", "info", "setup", "depend", + "config", "info", "setup", "depend", "pretend", "fetch", "fetchall", "digest", "unpack", "prepare", "configure", "compile", "test", "install", "rpm", "qmerge", "merge", @@ -6476,6 +6479,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # args are for the to spawn function actionmap = { +"pretend": {"cmd":ebuild_sh, "args":{"droppriv":0, "free":1, "sesandbox":0, "fakeroot":0}}, "setup": {"cmd":ebuild_sh, "args":{"droppriv":0, "free":1, "sesandbox":0, "fakeroot":0}}, "unpack": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0, "sesandbox":sesandbox, "fakeroot":0}}, "prepare": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0, "sesandbox":sesandbox, "fakeroot":0}}, diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index abd6cc870..08b7a3b9b 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -23,7 +23,7 @@ class dbapi(object): _category_re = re.compile(r'^\w[-.+\w]*$') _pkg_dir_name_re = re.compile(r'^\w[-+\w]*$') _categories = None - _iuse_implicit = None + _iuse_implicit_re = None _use_mutable = False _known_keys = frozenset(x for x in auxdbkeys if not x.startswith("UNUSED_0")) @@ -149,20 +149,20 @@ class dbapi(object): 1) Check for required IUSE intersection (need implicit IUSE here). 2) Check enabled/disabled flag states. """ - if self._iuse_implicit is None: - self._iuse_implicit = self.settings._get_implicit_iuse() + if self._iuse_implicit_re is None: + self._iuse_implicit_re = re.compile("^(%s)$" % \ + "|".join(self.settings._get_implicit_iuse())) + iuse_implicit_re = self._iuse_implicit_re for cpv in cpv_iter: try: iuse, slot, use = self.aux_get(cpv, ["IUSE", "SLOT", "USE"]) except KeyError: continue use = use.split() - iuse = self._iuse_implicit.union( - re.escape(x.lstrip("+-")) for x in iuse.split()) - iuse_re = re.compile("^(%s)$" % "|".join(iuse)) + iuse = frozenset(x.lstrip('+-') for x in iuse.split()) missing_iuse = False for x in atom.use.required: - if iuse_re.match(x) is None: + if x not in iuse and iuse_implicit_re.match(x) is None: missing_iuse = True break if missing_iuse: diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 7c886ae25..e29377f72 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -133,7 +133,6 @@ class portdbapi(dbapi): else: from portage import settings self.mysettings = config(clone=settings) - self._iuse_implicit = self.mysettings._get_implicit_iuse() self._categories = self.mysettings.categories # This is strictly for use in aux_get() doebuild calls when metadata # is generated by the depend phase. It's safest to use a clone for -- 2.26.2