Virt: re-write and refactor of cpu_vendor() utility function
[autotest-zwu.git] / client / virt / virt_installer.py
blob5ee128caee7ec9dfa2ff6c0730365dd75bc586b3
1 import os, shutil, logging
2 from autotest_lib.client.bin import utils
5 def check_configure_options(script_path):
6 """
7 Return the list of available options (flags) of a GNU autoconf like
8 configure build script.
10 @param script: Path to the configure script
11 """
12 abspath = os.path.abspath(script_path)
13 help_raw = utils.system_output('%s --help' % abspath, ignore_status=True)
14 help_output = help_raw.split("\n")
15 option_list = []
16 for line in help_output:
17 cleaned_line = line.lstrip()
18 if cleaned_line.startswith("--"):
19 option = cleaned_line.split()[0]
20 option = option.split("=")[0]
21 option_list.append(option)
23 return option_list
26 def save_build(build_dir, dest_dir):
27 logging.debug('Saving the result of the build on %s', dest_dir)
28 base_name = os.path.basename(build_dir)
29 tarball_name = base_name + '.tar.bz2'
30 os.chdir(os.path.dirname(build_dir))
31 utils.system('tar -cjf %s %s' % (tarball_name, base_name))
32 shutil.move(tarball_name, os.path.join(dest_dir, tarball_name))