diff options
Diffstat (limited to 'src/software/test/common.py')
-rw-r--r-- | src/software/test/common.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/software/test/common.py b/src/software/test/common.py index 7726d3e..0d199b2 100644 --- a/src/software/test/common.py +++ b/src/software/test/common.py @@ -51,10 +51,12 @@ def install_pkg(pkg, newer=True): In latter case, a specific version is installed. """ if isinstance(pkg, rpmcache.Package): - rpm_name = pkg.get_nevra(newer) + ".rpm" - if os.path.exists(rpm_name): + try: + rpm_name = rpmcache.get_rpm_name(pkg, newer=newer) subprocess.call(["rpm", "--quiet", "-i", rpm_name]) return + except rpmcache.MissingRPM: + pass pkg = pkg.name subprocess.call(["yum", "-q", "-y", "install", pkg]) @@ -68,9 +70,13 @@ def is_installed(pkg, newer=True): return subprocess.call(["rpm", "--quiet", "-q", pkg]) == 0 else: try: - out = subprocess.check_output( - ["rpm", "-q", "--qf", "%{NEVRA}", pkg.name]) - return out == pkg.get_nevra(newer) + cmd = [ "rpm", "-q", "--qf", "%{EPOCH}:%{NVRA}", pkg.name ] + out = subprocess.check_output(cmd) + epoch, nvra = out.split(':') #pylint: disable=E1103 + if not epoch or epoch == "(none)": + epoch = "0" + return ( epoch == pkg.epoch + and nvra == pkg.get_nevra(newer=newer, with_epoch="NEVER")) except subprocess.CalledProcessError: return False @@ -94,15 +100,17 @@ def is_config_file(pkg, file_path): """ @return True, if file_path is a configuration file of package pkg. """ - out = check_output(['rpm', '-qc', pkg.name]) - return file_path in set(out.splitlines()) + cmd = ['rpm', '-qc', pkg.name] + out = check_output(cmd) + return file_path in set(out.splitlines()) #pylint: disable=E1103 def is_doc_file(pkg, file_path): """ @return True, if file_path is a documentation file of package pkg. """ - out = check_output(['rpm', '-qd', pkg.name]) - return file_path in set(out.splitlines()) + cmd = ['rpm', '-qd', pkg.name] + out = check_output(cmd) + return file_path in set(out.splitlines()) #pylint: disable=E1103 def get_pkg_files(pkg): """ @@ -111,13 +119,14 @@ def get_pkg_files(pkg): @param pkg must be installed package @return list of few files installed by pkg """ - output = check_output(['rpm', '-ql', pkg.name]) + cmd = ['rpm', '-ql', pkg.name] + output = check_output(cmd) configs = set() docs = set() dirs = set() files = set() symlinks = set() - for fpath in output.splitlines(): + for fpath in output.splitlines(): #pylint: disable=E1103 if ( len(dirs) == 0 and not os.path.islink(fpath) and os.path.isdir(fpath)): |