ia64/xen-unstable

changeset 9956:d61fc1f33954

Use the auxbin module to find the appropriate install directory for our Python
scripts.

This fixes a bug with xm-test not working on 64-bit systems.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri May 05 18:36:12 2006 +0100 (2006-05-05)
parents 3534801f08da
children 0afdf20b3efa
files tools/misc/xend tools/python/xen/util/auxbin.py tools/xm-test/configure.ac tools/xm-test/lib/XmTestLib/__init__.py
line diff
     1.1 --- a/tools/misc/xend	Fri May 05 16:46:48 2006 +0100
     1.2 +++ b/tools/misc/xend	Fri May 05 18:36:12 2006 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4  #  -*- mode: python; -*-
     1.5  #============================================================================
     1.6  # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
     1.7 -# Copyright (C) 2005 XenSource Ltd
     1.8 +# Copyright (C) 2005-2006 XenSource Inc
     1.9  #============================================================================
    1.10  
    1.11  """Xen management daemon.
    1.12 @@ -21,15 +21,31 @@
    1.13     and recover its state when restarted.
    1.14  """
    1.15  import os
    1.16 +import os.path
    1.17  import sys
    1.18  import socket
    1.19  import signal
    1.20  import time
    1.21  import commands
    1.22  
    1.23 -# add fallback path for non-native python path installs if needed
    1.24 -sys.path.append('/usr/lib/python')
    1.25 -sys.path.append('/usr/lib64/python')
    1.26 +
    1.27 +# Use the auxbin module in Xend to determine the correct Python path.  We
    1.28 +# take the first installed instance of auxbin that we find, and then run it
    1.29 +# to determine the correct path, appending that to sys.path.
    1.30 +
    1.31 +AUXBIN = 'xen/util/auxbin.py'
    1.32 +
    1.33 +for p in ['python%s' % sys.version[:3], 'python']:
    1.34 +    for l in ['/usr/lib64', '/usr/lib']:
    1.35 +        d = os.path.join(l, p)
    1.36 +        if os.path.exists(os.path.join(d, AUXBIN)):
    1.37 +            sys.path.append(d)
    1.38 +            import xen.util.auxbin
    1.39 +            libpath = xen.util.auxbin.libpath()
    1.40 +            sys.path = sys.path[:-1]
    1.41 +            sys.path.append(libpath)
    1.42 +            break
    1.43 +
    1.44  from xen.xend.server import SrvDaemon
    1.45  
    1.46  class CheckError(ValueError):
     2.1 --- a/tools/python/xen/util/auxbin.py	Fri May 05 16:46:48 2006 +0100
     2.2 +++ b/tools/python/xen/util/auxbin.py	Fri May 05 18:36:12 2006 +0100
     2.3 @@ -12,14 +12,15 @@
     2.4  # License along with this library; if not, write to the Free Software
     2.5  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     2.6  #============================================================================
     2.7 -# Copyright (C) 2005 XenSource Ltd
     2.8 +# Copyright (C) 2005-2006 XenSource Inc.
     2.9  #============================================================================
    2.10  
    2.11  
    2.12 -LIB_BIN_32 = "/usr/lib/xen/bin"
    2.13 -LIB_BIN_64 = "/usr/lib64/xen/bin"
    2.14 +LIB_32 = "/usr/lib"
    2.15 +LIB_64 = "/usr/lib64"
    2.16 +LIB_BIN_SUFFIX = "xen/bin"
    2.17  
    2.18 -## The architectures on which the LIB_BIN_64 directory is used.  This
    2.19 +## The architectures on which the LIB_64 directory is used.  This
    2.20  # deliberately excludes ia64.
    2.21  LIB_64_ARCHS = [ 'x86_64', 'ppc64', 's390x', 'sparc64']
    2.22  
    2.23 @@ -41,8 +42,12 @@ def pathTo(exe):
    2.24  
    2.25  
    2.26  def path():
    2.27 +    return os.path.join(libpath(), LIB_BIN_SUFFIX)
    2.28 +
    2.29 +
    2.30 +def libpath():
    2.31      machine = os.uname()[4]
    2.32 -    if machine in LIB_64_ARCHS and os.path.exists(LIB_BIN_64):
    2.33 -        return LIB_BIN_64
    2.34 +    if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
    2.35 +        return LIB_64
    2.36      else:
    2.37 -        return LIB_BIN_32
    2.38 +        return LIB_32
     3.1 --- a/tools/xm-test/configure.ac	Fri May 05 16:46:48 2006 +0100
     3.2 +++ b/tools/xm-test/configure.ac	Fri May 05 18:36:12 2006 +0100
     3.3 @@ -13,7 +13,7 @@ AC_CHECK_PROG([LILO],	lilo,	lilo,	"no",	
     3.4  # are two levels above the tests
     3.5  TESTLIB=../../lib
     3.6  RD_PATH=../../ramdisk
     3.7 -TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB:/usr/lib/python RD_PATH=$RD_PATH"
     3.8 +TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB RD_PATH=$RD_PATH"
     3.9  
    3.10  AC_ARG_ENABLE(hvm-support,
    3.11  	[[  --enable-hvm-support           enable hardware virtual machine assist]],
     4.1 --- a/tools/xm-test/lib/XmTestLib/__init__.py	Fri May 05 16:46:48 2006 +0100
     4.2 +++ b/tools/xm-test/lib/XmTestLib/__init__.py	Fri May 05 18:36:12 2006 +0100
     4.3 @@ -11,11 +11,25 @@ from config import *
     4.4  from XenDevice import *
     4.5  from NetConfig import *
     4.6  
     4.7 -# Make sure xen modules are in path
     4.8 -sys.path.append('/usr/lib/python')
     4.9 +# Use the auxbin module in Xend to determine the correct Python path.  We
    4.10 +# take the first installed instance of auxbin that we find, and then run it
    4.11 +# to determine the correct path, appending that to sys.path.
    4.12 +
    4.13 +AUXBIN = 'xen/util/auxbin.py'
    4.14 +
    4.15 +for p in ['python%s' % sys.version[:3], 'python']:
    4.16 +    for l in ['/usr/lib64', '/usr/lib']:
    4.17 +        d = os.path.join(l, p)
    4.18 +        if os.path.exists(os.path.join(d, AUXBIN)):
    4.19 +            sys.path.append(d)
    4.20 +            import xen.util.auxbin
    4.21 +            libpath = xen.util.auxbin.libpath()
    4.22 +            sys.path = sys.path[:-1]
    4.23 +            sys.path.append(libpath)
    4.24 +            break
    4.25  
    4.26  # Give this test a clean slate
    4.27 -destroyAllDomUs();
    4.28 +destroyAllDomUs()
    4.29  
    4.30  if os.environ.get("TEST_VERBOSE"):
    4.31      verbose = True