virt.virt_test_utils: run_autotest - 'tar' needs relative paths to strip the leading '/'
[autotest-zwu.git] / client / bin / os_dep.py
blob3f95a98e4bc1fe80e74c5c477a82bdec823f7901
1 import os
3 """
4 One day, when this module grows up, it might actually try to fix things.
5 'apt-cache search | apt-get install' ... or a less terrifying version of
6 the same. With added distro-independant pixie dust.
7 """
9 def command(cmd):
10 # this could use '/usr/bin/which', I suppose. But this seems simpler
11 for dir in os.environ['PATH'].split(':'):
12 file = os.path.join(dir, cmd)
13 if os.path.exists(file):
14 return file
15 raise ValueError('Missing command: %s' % cmd)
18 def commands(*cmds):
19 results = []
20 for cmd in cmds:
21 results.append(command(cmd))
24 def library(lib):
25 lddirs = [x.rstrip() for x in open('/etc/ld.so.conf', 'r').readlines()]
26 for dir in ['/lib', '/usr/lib'] + lddirs:
27 file = os.path.join(dir, lib)
28 if os.path.exists(file):
29 return file
30 raise ValueError('Missing library: %s' % lib)
33 def libraries(*libs):
34 results = []
35 for lib in libs:
36 results.append(library(lib))