From: Fabian Groffen Date: Tue, 31 Oct 2006 21:14:14 +0000 (-0000) Subject: Merged from trunk 4883:4889 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=36b8b6afef044ee2d8dc5c6c8d713f6da9d91b40;p=portage.git Merged from trunk 4883:4889 Rely on PYTHONPATH instead of PORTAGE_PYM_PATH for locating portage's python modules, then fall back to an explicit sys.path insertion if an ImportError occurs. Fix a KeyError when the profile doesn't define default USE. Add support for frozen config files for which updates are automatically zapped. Thanks to Bo ?\195?\152rsted Andresen for the initial patch from bug #151685. Recommend people use `emake` rather than `make` when installing with DESTDIR. svn path=/main/branches/prefix/; revision=4892 --- diff --git a/NEWS b/NEWS index a4c96ed62..40ca03644 100644 --- a/NEWS +++ b/NEWS @@ -19,7 +19,7 @@ portage-2.1.2 order and detection of circular dependencies. * The world and system sets allow automatic update of all installed slots. * DEPEND atoms support SLOT dependencies of the form ${CATEGORY}/${PN}:${SLOT}. -* Development: Extend PORTAGE_PYM_PATH support to allow overriding the hardcoded +* Development: Extend PYTHONPATH support to allow overriding the hardcoded /usr/lib/portage/pym for development/testing purposes portage-2.1.1 diff --git a/bin/archive-conf b/bin/archive-conf index 4909f9b33..95e9135ed 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -11,9 +11,13 @@ # import os, sys, string -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage -import portage, dispatch_conf +import dispatch_conf FIND_EXTANT_CONTENTS = "find %s -name CONTENTS" diff --git a/bin/chkcontents b/bin/chkcontents index 65f1a8190..eecb55762 100755 --- a/bin/chkcontents +++ b/bin/chkcontents @@ -9,8 +9,11 @@ # the right files). import string, os.path, os, sys -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage def CONTENTScheck(path): try: diff --git a/bin/clean_locks b/bin/clean_locks index d6cfee151..87ae18a58 100755 --- a/bin/clean_locks +++ b/bin/clean_locks @@ -4,9 +4,13 @@ # $Id: /var/cvsroot/gentoo-src/portage/bin/clean_locks,v 1.1 2004/09/26 10:44:31 carpaski Exp $ import os,sys,errno -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) +try: + import portage_locks +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage_locks -import portage_locks, portage_const +import portage_const if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: print diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 29ecb89d4..03f8b4d5f 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -12,12 +12,20 @@ # dialog menus # +if not hasattr(__builtins__, "set"): + from sets import Set as set + from stat import * from random import * import atexit, commands, os, re, shutil, stat, string, sys -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage -import portage, dispatch_conf, portage_const +import dispatch_conf, portage_const +from portage_exec import find_binary FIND_EXTANT_CONFIGS = "find '%s' %s -iname '._cfg????_%s'" DIFF_CONTENTS = 'diff -Nu %s %s' @@ -99,6 +107,10 @@ class dispatch: return False + # config file freezing support + frozen_files = set(self.options.get("frozen-files", "").split()) + auto_zapped = [] + # # Remove new configs identical to current # and @@ -142,6 +154,18 @@ class dispatch: if os.path.exists(mrgconf): os.unlink(mrgconf) return False + elif conf['current'] in frozen_files: + """Frozen files are automatically zapped. The new config has + already been archived with a .new suffix. When zapped, it is + left with the .new suffix (post_process is skipped), since it + hasn't been merged into the current config.""" + auto_zapped.append(conf['current']) + os.unlink(conf['new']) + try: + os.unlink(mrgconf) + except OSError: + pass + return False elif unmodified or same_cvs or same_wsc or conf ['dir'] in portage.settings ['CONFIG_PROTECT_MASK'].split (): self.replace(newconf, conf['current']) self.post_process(conf['current']) @@ -232,6 +256,13 @@ class dispatch: else: continue + if auto_zapped: + print + print " One or more updates are frozen and have been automatically zapped:" + print + for frozen in auto_zapped: + print " * '%s'" % frozen + print def replace (self, newconf, curconf): """Replace current config with the new/merged version. Also logs diff --git a/bin/ebuild b/bin/ebuild index be83ba5d5..4452ab3c8 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -21,9 +21,13 @@ if "merge" in pargs: os.environ["FEATURES"] = os.environ.get("FEATURES", "") + " -noauto" os.environ["PORTAGE_CALLER"]="ebuild" -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage -import portage, portage_util, portage_const +import portage_util, portage_const # do this _after_ 'import portage' to prevent unnecessary tracing if debug and "python-trace" in portage.features: diff --git a/bin/emaint b/bin/emaint index 23ca3bc97..703d89ca1 100755 --- a/bin/emaint +++ b/bin/emaint @@ -1,12 +1,16 @@ #!@PYTHON@ -O import sys, os -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) from optparse import OptionParser, OptionValueError import re +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage -import os, portage, portage_const, portage_exception +import portage_const, portage_exception class WorldHandler(object): def name(): diff --git a/bin/emerge b/bin/emerge index 6bbb88446..fda949f53 100755 --- a/bin/emerge +++ b/bin/emerge @@ -21,10 +21,13 @@ except KeyboardInterrupt: sys.exit(1) import os, stat -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) os.environ["PORTAGE_LEGACY_GLOBALS"] = "false" -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage del os.environ["PORTAGE_LEGACY_GLOBALS"] from portage import digraph diff --git a/bin/env-update b/bin/env-update index 6390ae4d9..bf6f12902 100755 --- a/bin/env-update +++ b/bin/env-update @@ -4,7 +4,6 @@ # $Id: /var/cvsroot/gentoo-src/portage/bin/env-update,v 1.9 2004/10/04 13:56:50 vapier Exp $ import os,sys -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) def usage(status): print "Usage: env-update [--no-ldconfig]" @@ -24,5 +23,9 @@ if len(sys.argv) > 1: print "!!! Invalid command line options!\n" usage(1) -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage portage.env_update(makelinks) diff --git a/bin/fix-db.py b/bin/fix-db.py index b12b316c8..c8469b138 100755 --- a/bin/fix-db.py +++ b/bin/fix-db.py @@ -4,7 +4,12 @@ # $Id: /var/cvsroot/gentoo-src/portage/bin/fix-db.py,v 1.8 2004/10/11 04:01:00 jstubbs Exp $ import os,sys,re -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) + +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage from stat import * from output import * diff --git a/bin/fixpackages b/bin/fixpackages index 928a7107c..006ef0b85 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -5,9 +5,11 @@ import os,sys os.environ["PORTAGE_CALLER"]="fixpackages" -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) - -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage print print "Done." diff --git a/bin/md5check.py b/bin/md5check.py index df95ad2a8..e9c36cf7f 100755 --- a/bin/md5check.py +++ b/bin/md5check.py @@ -5,9 +5,11 @@ import os,sys,string os.environ["FEATURES"]="mirror cvs" -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) - -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage from threading import * from output import red,green,blue,bold from random import shuffle diff --git a/bin/pkgname b/bin/pkgname index ef946abe7..378e603c3 100755 --- a/bin/pkgname +++ b/bin/pkgname @@ -4,9 +4,11 @@ # $Id: /var/cvsroot/gentoo-src/portage/bin/pkgname,v 1.8 2004/10/04 13:56:50 vapier Exp $ import sys, os -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) - -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage a=portage.pkgsplit(sys.argv[1]) if a: diff --git a/bin/portageq b/bin/portageq index f4fe1f5cd..8f067181b 100755 --- a/bin/portageq +++ b/bin/portageq @@ -20,7 +20,6 @@ except KeyboardInterrupt: sys.exit(1) import os -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) import types,string @@ -322,7 +321,11 @@ def main(): if uses_root: os.environ["ROOT"] = sys.argv[2] global portage - import portage + try: + import portage + except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage if uses_root: sys.argv[2] = portage.root function(sys.argv[2:]) diff --git a/bin/regenworld b/bin/regenworld index ebf315d77..ea1b46e82 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -4,8 +4,12 @@ # $Id: /var/cvsroot/gentoo-src/portage/bin/regenworld,v 1.10.2.1 2005/01/11 03:40:57 carpaski Exp $ import sys, os -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) -import portage, string, re, portage_const +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage +import string, re, portage_const __candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ") __noncandidatematcher__ = re.compile(" sync( |$)| clean( |$)| search( |$)|--oneshot|--fetchonly| unmerge( |$)") diff --git a/bin/repoman b/bin/repoman index 3a63c5ce3..9b30bb7f1 100755 --- a/bin/repoman +++ b/bin/repoman @@ -11,7 +11,6 @@ import errno, os, shutil, sys if not hasattr(__builtins__, "set"): from sets import Set as set exename=os.path.basename(sys.argv[0]) -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) version="1.2" allowed_filename_chars="a-zA-Z0-9._-+:" @@ -24,7 +23,11 @@ map(allowed_filename_chars_set.setdefault, map(chr, map(ord, [".", "-", "_", "+" import string,signal,re,pickle,tempfile os.environ["PORTAGE_LEGACY_GLOBALS"] = "false" -import portage +try: + import portage +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import portage del os.environ["PORTAGE_LEGACY_GLOBALS"] import portage_checksum diff --git a/bin/xpak b/bin/xpak index c983c1439..58491f977 100755 --- a/bin/xpak +++ b/bin/xpak @@ -8,7 +8,10 @@ if len(sys.argv)!=3: print "xpak: expecting three arguments." sys.exit(1) -sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "@PORTAGE_BASE@/pym")) +try: + import xpak +except ImportError: + sys.path.insert(0, "@PORTAGE_BASE@/pym") + import xpak -import xpak xpak.xpak(sys.argv[1],sys.argv[2]) diff --git a/cnf/dispatch-conf.conf b/cnf/dispatch-conf.conf index 11123b2a8..b1ece73bb 100644 --- a/cnf/dispatch-conf.conf +++ b/cnf/dispatch-conf.conf @@ -34,3 +34,6 @@ replace-unmodified=no # Per-session log file of changes made to configuration files #log-file=/var/log/dispatch-conf.log + +# List of frozen files for which dispatch-conf will automatically zap updates +#frozen-files="" diff --git a/man/ebuild.5 b/man/ebuild.5 index 7492774c2..40aed0410 100644 --- a/man/ebuild.5 +++ b/man/ebuild.5 @@ -616,7 +616,7 @@ make \\ \fImake options\fR \\ install .fi -Please do \fBnot\fR use this in place of 'make install DESTDIR=${D}'. +Please do \fBnot\fR use this in place of 'emake install DESTDIR=${D}'. That is the preferred way of installing make-based packages. Also, do not utilize the \fIEXTRA_EINSTALL\fR variable since it is for users. diff --git a/pym/portage.py b/pym/portage.py index 4cf304ea4..e95fa485c 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1552,7 +1552,7 @@ class config: if best_match: defaults.append(cpdict[best_match]) defaults = " ".join(defaults) - if defaults != self.configdict["defaults"]["USE"]: + if defaults != self.configdict["defaults"].get("USE",""): self.configdict["defaults"]["USE"] = defaults has_changed = True useforce = []