# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1242695797 -3600
# Node ID 61501fa86b1b6bd5fc5b291200ac6f9048503ecb
# Parent 13a4f4e6d0a36ae60b406a2385830c646873db37
python: get rid of hardcoded search pathes in python code.
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
.hgignore | 1 +
tools/python/Makefile | 13 +++++++++++--
tools/python/xen/util/auxbin.py | 39 ++++++++++-----------------------------
3 files changed, 22 insertions(+), 31 deletions(-)
diff -r 13a4f4e6d0a3 -r 61501fa86b1b .hgignore
--- a/.hgignore Tue May 19 02:12:04 2009 +0100
+++ b/.hgignore Tue May 19 02:16:37 2009 +0100
@@ -183,6 +183,7 @@
^tools/misc/xenpm$
^tools/pygrub/build/.*$
^tools/python/build/.*$
+^tools/python/xen/util/path\.py$
^tools/security/secpol_tool$
^tools/security/xen/.*$
^tools/security/xensec_tool$
diff -r 13a4f4e6d0a3 -r 61501fa86b1b tools/python/Makefile
--- a/tools/python/Makefile Tue May 19 02:12:04 2009 +0100
+++ b/tools/python/Makefile Tue May 19 02:16:37 2009 +0100
@@ -13,9 +13,18 @@ I18NSRCFILES = $(shell find xen/xm/ -nam
I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
NLSDIR = $(SHAREDIR)/locale
+xenpath = "xen/util/path.py"
+
+.PHONY: build buildpy genpath
+genpath:
+ rm -f ${xenpath}
+ echo "SBINDIR=\"$(SBINDIR)\"" >> ${xenpath}
+ echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath}
+ echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
+ echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
+ echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath}
-.PHONY: build buildpy
-buildpy:
+buildpy: genpath
CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
build: buildpy refresh-pot refresh-po $(CATALOGS)
diff -r 13a4f4e6d0a3 -r 61501fa86b1b tools/python/xen/util/auxbin.py
--- a/tools/python/xen/util/auxbin.py Tue May 19 02:12:04 2009 +0100
+++ b/tools/python/xen/util/auxbin.py Tue May 19 02:16:37 2009 +0100
@@ -16,19 +16,10 @@
#============================================================================
-LIB_32 = "/usr/lib"
-LIB_64 = "/usr/lib64"
-LIB_BIN_SUFFIX = "xen/bin"
-
-## The architectures on which the LIB_64 directory is used. This
-# deliberately excludes ia64 and ppc64, and Solaris.
-LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64']
-
-
import os
import os.path
import sys
-
+from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR
def execute(exe, args = None):
exepath = pathTo(exe)
@@ -41,26 +32,16 @@ def execute(exe, args = None):
print exepath, ": ", exn
sys.exit(1)
-
-def pathTo(exe):
- return os.path.join(path(), exe)
-
+SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR ]
+def pathTo(exebin):
+ for dir in SEARCHDIRS:
+ exe = os.path.join(dir, exebin)
+ if os.path.exists(exe):
+ return exe
+ return None
def path():
- return os.path.join(libpath(), LIB_BIN_SUFFIX)
-
+ return LIBEXEC
def libpath():
- machine = os.uname()[4]
- if sys.argv[0] != '-c':
- prefix = os.path.dirname(os.path.dirname(sys.argv[0]))
- path = os.path.join(prefix, os.path.basename(LIB_64))
- if machine in LIB_64_ARCHS and os.path.exists(path):
- return path
- path = os.path.join(prefix, os.path.basename(LIB_32))
- if os.path.exists(path):
- return path
- if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
- return LIB_64
- else:
- return LIB_32
+ return LIBDIR
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|