Solves ticket #244. Enables us to attach configuration files (like fas.conf) to individual tests just by placing a symlink there. --- Makefile | 1 + autoqa.spec | 1 + lib/autotest/site_packages.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 lib/autotest/site_packages.py
diff --git a/Makefile b/Makefile index adbead8..ac4ddeb 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ install: build for t in tests/*; do cp -a $$t $(PREFIX)$(TEST_DIR); done install -d $(PREFIX)$(AUTOTEST_DIR)/client/bin install -m 0644 lib/autotest/site_utils.py $(PREFIX)$(AUTOTEST_DIR)/client/bin + install -m 0644 lib/autotest/site_packages.py $(PREFIX)$(AUTOTEST_DIR)/client/common_lib ( cd lib/python; $(PYTHON) setup.py install --skip-build --root $(PREFIX)/ ) ## front-ends/israwhidebroken install -d $(PREFIX)/usr/sbin diff --git a/autoqa.spec b/autoqa.spec index d30251a..261b20a 100644 --- a/autoqa.spec +++ b/autoqa.spec @@ -85,6 +85,7 @@ rm -rf $RPM_BUILD_ROOT %{testdir} %{hookdir} %{_datadir}/autotest/client/bin/site_utils.py* +%{_datadir}/autotest/client/common_lib/site_packages.py* %{python_sitelib}/autoqa*
diff --git a/lib/autotest/site_packages.py b/lib/autotest/site_packages.py new file mode 100644 index 0000000..445e916 --- /dev/null +++ b/lib/autotest/site_packages.py @@ -0,0 +1,32 @@ +# site_packages.py - site-specific autotest packages methods for use in autoqa +# +# this must be copied to autotest/client/common_lib, because it is imported by +# autotest/client/common_lib/packages.py +# +# Author: Kamil Paral kparal@redhat.com + +import os +from autotest_lib.client.common_lib import utils, base_packages + +class SitePackageManager(base_packages.BasePackageManager): + # same as common_lib.base_packages.tar_package, but with de-referencing of symlinks enabled + def tar_package(self, pkg_name, src_dir, dest_dir, exclude_string=None): + ''' + Create a tar.bz2 file with the name 'pkg_name' say test-blah.tar.bz2. + Excludes the directories specified in exclude_string while tarring + the source. Returns the tarball path. + ''' + tarball_path = os.path.join(dest_dir, pkg_name) + temp_path = tarball_path + '.tmp' + # AutoQA change -> add '-h' option to dereference symlinks (to be used with fas.conf, etc) + cmd = "tar -h -cvjf %s -C %s %s " % (temp_path, src_dir, exclude_string) + + try: + utils.system(cmd) + except: + os.unlink(temp_path) + raise + + os.rename(temp_path, tarball_path) + return tarball_path +