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 | |
---|
19 | LIB_32 = "/usr/lib" |
---|
20 | LIB_64 = "/usr/lib64" |
---|
21 | LIB_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. |
---|
25 | LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64'] |
---|
26 | |
---|
27 | |
---|
28 | import os |
---|
29 | import os.path |
---|
30 | |
---|
31 | |
---|
32 | def 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 | |
---|
40 | def pathTo(exe): |
---|
41 | return os.path.join(path(), exe) |
---|
42 | |
---|
43 | |
---|
44 | def path(): |
---|
45 | return os.path.join(libpath(), LIB_BIN_SUFFIX) |
---|
46 | |
---|
47 | |
---|
48 | def 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 |
---|