summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-31 04:23:06 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-31 04:23:06 +0000
commit64396f7e8e3914d66d4b5efb9bfd80c8cd7a72fd (patch)
tree70a47dc3100da9328a1cd40bb5ac49e37c40a756
parentJust use stat instead of lstat for config protect, so that broken symlinks ar... (diff)
downloadportage-multirepo-64396f7e8e3914d66d4b5efb9bfd80c8cd7a72fd.tar.gz
portage-multirepo-64396f7e8e3914d66d4b5efb9bfd80c8cd7a72fd.tar.bz2
portage-multirepo-64396f7e8e3914d66d4b5efb9bfd80c8cd7a72fd.zip
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.
svn path=/main/trunk/; revision=4884
-rw-r--r--NEWS2
-rwxr-xr-xbin/archive-conf8
-rwxr-xr-xbin/chkcontents7
-rwxr-xr-xbin/clean_locks8
-rwxr-xr-xbin/dispatch-conf8
-rwxr-xr-xbin/ebuild8
-rwxr-xr-xbin/emaint8
-rwxr-xr-xbin/emerge7
-rwxr-xr-xbin/env-update7
-rwxr-xr-xbin/fix-db.py7
-rwxr-xr-xbin/fixpackages8
-rwxr-xr-xbin/md5check.py8
-rwxr-xr-xbin/pkgname8
-rwxr-xr-xbin/portageq7
-rwxr-xr-xbin/regenworld8
-rwxr-xr-xbin/repoman7
-rwxr-xr-xbin/xpak7
17 files changed, 87 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index 64cd1da6..7f0bc40c 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 0417e97c..b3d17cc6 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", "/usr/lib/portage/pym"))
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/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 4523b630..aae45c6b 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", "/usr/lib/portage/pym"))
-import portage
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
def CONTENTScheck(path):
try:
diff --git a/bin/clean_locks b/bin/clean_locks
index 9c7e110c..71db0b8e 100755
--- a/bin/clean_locks
+++ b/bin/clean_locks
@@ -4,9 +4,11 @@
# $Id$
import os,sys,errno
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage_locks
+try:
+ import portage_locks
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage_locks
if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv:
import portage
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index 277d6ef4..2309b680 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -15,9 +15,13 @@
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", "/usr/lib/portage/pym"))
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
-import portage, dispatch_conf
+import dispatch_conf
from portage_exec import find_binary
FIND_EXTANT_CONFIGS = "find '%s' %s -iname '._cfg????_%s'"
diff --git a/bin/ebuild b/bin/ebuild
index 2d8c0890..da405db0 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", "/usr/lib/portage/pym"))
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/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 016c64ea..bff6856f 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -1,12 +1,16 @@
#!/usr/bin/python -O
import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
from optparse import OptionParser, OptionValueError
import re
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/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 933b461d..959224a1 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", "/usr/lib/portage/pym"))
os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
-import portage
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
del os.environ["PORTAGE_LEGACY_GLOBALS"]
from portage import digraph
diff --git a/bin/env-update b/bin/env-update
index 1026b1fc..b245b399 100755
--- a/bin/env-update
+++ b/bin/env-update
@@ -4,7 +4,6 @@
# $Id$
import os,sys
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/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, "/usr/lib/portage/pym")
+ import portage
portage.env_update(makelinks)
diff --git a/bin/fix-db.py b/bin/fix-db.py
index fef1a4d4..e8bbad2c 100755
--- a/bin/fix-db.py
+++ b/bin/fix-db.py
@@ -4,7 +4,12 @@
# $Id$
import os,sys,re
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
from stat import *
from output import *
diff --git a/bin/fixpackages b/bin/fixpackages
index f9d09dec..f7c1bf51 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", "/usr/lib/portage/pym"))
-
-import portage
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
mysettings = portage.settings
mytrees = portage.db
diff --git a/bin/md5check.py b/bin/md5check.py
index 98f3c810..c83331ed 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", "/usr/lib/portage/pym"))
-
-import portage
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/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 546b05d3..ee480774 100755
--- a/bin/pkgname
+++ b/bin/pkgname
@@ -4,9 +4,11 @@
# $Id$
import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
a=portage.pkgsplit(sys.argv[1])
if a:
diff --git a/bin/portageq b/bin/portageq
index 0424647b..5ee16c4e 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", "/usr/lib/portage/pym"))
import types,string
@@ -332,7 +331,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, "/usr/lib/portage/pym")
+ import portage
if uses_root:
sys.argv[2] = portage.root
function(sys.argv[2:])
diff --git a/bin/regenworld b/bin/regenworld
index d5e28dd7..a7428ed9 100755
--- a/bin/regenworld
+++ b/bin/regenworld
@@ -4,8 +4,12 @@
# $Id$
import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-import portage, string, re
+try:
+ import portage
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import portage
+import string, re
__candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
__noncandidatematcher__ = re.compile(" sync( |$)| clean( |$)| search( |$)|--oneshot|--fetchonly| unmerge( |$)")
diff --git a/bin/repoman b/bin/repoman
index c05ae9e4..4e8f7fc1 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", "/usr/lib/portage/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, "/usr/lib/portage/pym")
+ import portage
del os.environ["PORTAGE_LEGACY_GLOBALS"]
import portage_checksum
diff --git a/bin/xpak b/bin/xpak
index 1a074377..8dcbf145 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", "/usr/lib/portage/pym"))
+try:
+ import xpak
+except ImportError:
+ sys.path.insert(0, "/usr/lib/portage/pym")
+ import xpak
-import xpak
xpak.xpak(sys.argv[1],sys.argv[2])