From ab814bb1a7751e0b868a2d565ed39e4869c27c07 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 18 Jun 2008 15:41:54 +0000 Subject: [PATCH] Merged from trunk 10709:10715 | 10710 | Use optparse instead of getopt. | | zmedico | | | 10711 | Add a help string for --debug. | | zmedico | | | 10712 | Bug #225285 - Add a --skip-manifest option that disables all | | zmedico | interaction with the manifest. | | 10713 | Bug #225285 - Add support for persistent options stored in | | zmedico | the EBUILD_DEFAULT_OPTS environment variable (similar to | | | {EMERGE,QUICKPKG}_DEFAULT_OPTS). | | 10714 | Add an exemption for x-modular in the "inherit.autotools" | | zmedico | check. Thanks to remi` for reporting. | | 10715 | As suggested by remi`, make the 'inherit.autotools' check | | zmedico | only ebuilds that inherit the autotools eclass directly | | | (rather than indirectly through an eclass such as apache-2 | | | or x-modular). | svn path=/main/branches/prefix/; revision=10716 --- bin/ebuild | 48 ++++++++++++++++++++++++++++++----------- pym/portage/__init__.py | 5 ++++- pym/repoman/checks.py | 13 ++++++----- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index 53fa7cdd4..1f6088654 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -3,22 +3,32 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-src/portage/bin/ebuild,v 1.18.2.3 2005/05/07 04:32:59 ferringb Exp $ -import getopt, os, sys +import optparse +import os +import sys -if len(sys.argv) <= 2: - print "Usage: ebuild [command] ..." - print "" - print "See the ebuild(1) man page for more info" - sys.exit(1) +description = "See the ebuild(1) man page for more info" +usage = "Usage: ebuild [command] ..." +parser = optparse.OptionParser(description=description, usage=usage) +force_help = "When used together with the digest or manifest " + \ + "command, this option forces regeneration of digests for all " + \ + "distfiles associated with the current ebuild. Any distfiles " + \ + "that do not already exist in ${DISTDIR} will be automatically fetched." -try: - opts, pargs = getopt.getopt(sys.argv[1:], '', ['debug', 'force']) -except getopt.GetoptError, e: - print e - sys.exit(1) -debug = ("--debug",'') in opts -force = ("--force",'') in opts +parser.add_option("--force", help=force_help, action="store_true", dest="force") +parser.add_option("--debug", help="show debug output", + action="store_true", dest="debug") +parser.add_option("--ignore-default-opts", + action="store_true", + help="do not use the EBUILD_DEFAULT_OPTS environment variable") +parser.add_option("--skip-manifest", help="skip all manifest checks", + action="store_true", dest="skip_manifest") + +opts, pargs = parser.parse_args(args=sys.argv[1:]) + +if len(pargs) < 2: + parser.error("missing required args") if "merge" in pargs: print "Disabling noauto in features... merge disables it. (qmerge doesn't)" @@ -35,6 +45,13 @@ else: sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) import portage +if not opts.ignore_default_opts: + default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split() + opts, pargs = parser.parse_args(default_opts + sys.argv[1:]) + +debug = opts.debug +force = opts.force + import portage.util, portage.const import portage.dep portage.dep._dep_check_strict = True @@ -148,6 +165,11 @@ if "test" in pargs: tmpsettings["FEATURES"] = " ".join(tmpsettings.features) tmpsettings.backup_changes("FEATURES") +if opts.skip_manifest: + tmpsettings["EBUILD_SKIP_MANIFEST"] = "1" + tmpsettings.backup_changes("EBUILD_SKIP_MANIFEST") + portage._doebuild_manifest_exempt_depend += 1 + build_dir_phases = set(["setup", "unpack", "compile", "test", "install", "package", "rpm"]) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 639056a1e..238af6cda 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3316,8 +3316,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", if try_mirrors: mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] + skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1" pkgdir = mysettings.get("O") - if pkgdir is not None: + if not (pkgdir is None or skip_manifest): mydigests = Manifest( pkgdir, mysettings["DISTDIR"]).getTypeDigests("DIST") else: @@ -4083,6 +4084,8 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0): """Verifies checksums. Assumes all files have been downloaded. DEPRECATED: this is now only a compability wrapper for portage.manifest.Manifest().""" + if mysettings.get("EBUILD_SKIP_MANIFEST") == "1": + return 1 pkgdir = mysettings["O"] manifest_path = os.path.join(pkgdir, "Manifest") if not os.path.exists(manifest_path): diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index 0f339adbc..b4caff27f 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -219,6 +219,7 @@ _constant_checks = tuple((c() for c in ( _iuse_def_re = re.compile(r'^IUSE=.*') _comment_re = re.compile(r'(^|\s*)#') +_inherit_autotools_re = re.compile(r'^\s*inherit\s(.*\s)?autotools(\s|$)') _autotools_funcs = ( "eaclocal", "eautoconf", "eautoheader", "eautomake", "eautoreconf", "_elibtoolize") @@ -229,17 +230,15 @@ def run_checks(contents, pkg): checks = list(_constant_checks) checks.append(EbuildHeader(pkg.mtime)) iuse_def = None - inherit_autotools = "autotools" in pkg.inherited - if inherit_autotools: - if "apache-2" in pkg.inherited: - # eautoreconf is called by apache-2_src_unpack(), - # so the ebuild doesn't need to call it. - inherit_autotools = False + inherit_autotools = None autotools_func_call = None for num, line in enumerate(contents): comment = _comment_re.match(line) if comment is None: - if inherit_autotools and autotools_func_call is None: + if inherit_autotools is None: + inherit_autotools = _inherit_autotools_re.match(line) + if inherit_autotools is not None and \ + autotools_func_call is None: autotools_func_call = _autotools_func_re.search(line) if iuse_def is None: iuse_def = _iuse_def_re.match(line) -- 2.26.2