source: trunk/packages/xen-common/xen-common/tools/python/xen/util/auxbin.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 1.6 KB
Line 
1#============================================================================
2# This library is free software; you can redistribute it and/or
3# modify it under the terms of version 2.1 of the GNU Lesser General Public
4# License as published by the Free Software Foundation.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the Free Software
13# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14#============================================================================
15# Copyright (C) 2005-2006 XenSource Inc.
16#============================================================================
17
18
19LIB_32 = "/usr/lib"
20LIB_64 = "/usr/lib64"
21LIB_BIN_SUFFIX = "xen/bin"
22
23## The architectures on which the LIB_64 directory is used.  This
24# deliberately excludes ia64 and ppc64, and Solaris.
25LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64']
26
27
28import os
29import os.path
30
31
32def execute(exe, args = None):
33    exepath = pathTo(exe)
34    a = [ exepath ]
35    if args:
36        a.extend(args)
37    os.execv(exepath, a)
38
39
40def pathTo(exe):
41    return os.path.join(path(), exe)
42
43
44def path():
45    return os.path.join(libpath(), LIB_BIN_SUFFIX)
46
47
48def libpath():
49    machine = os.uname()[4]
50    if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
51        return LIB_64
52    else:
53        return LIB_32
Note: See TracBrowser for help on using the repository browser.