diff options
author | Dmitry Kovalenko <d.kovalenko@samsung.com> | 2017-08-17 10:43:07 +0300 |
---|---|---|
committer | Dmitriy Nikiforov <d.nikiforov@partner.samsung.com> | 2017-09-05 21:51:25 +0300 |
commit | d56b03e92ddf43e6c94671c444cf68258396776c (patch) | |
tree | d0b8eb91785d4b76f950400cecbb718730fbe865 /infra/commands | |
parent | 42f8ee58eaae26b1bf4668ab0f25d9204cfd696a (diff) | |
download | fuzz-testing-d56b03e92ddf43e6c94671c444cf68258396776c.tar.gz fuzz-testing-d56b03e92ddf43e6c94671c444cf68258396776c.tar.bz2 fuzz-testing-d56b03e92ddf43e6c94671c444cf68258396776c.zip |
Add initial version of script rpm_n_reqs.py
Script searches rpm and all its dependecies in GBS cache.
It's expected to use this script to install all dependecies of fuzzed package.
Change-Id: I45d08f67c4a2d011c2db59d07cc751991a143db8
Signed-off-by: Dmitry Kovalenko <d.kovalenko@samsung.com>
Diffstat (limited to 'infra/commands')
-rwxr-xr-x | infra/commands/rpm_n_reqs.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/infra/commands/rpm_n_reqs.py b/infra/commands/rpm_n_reqs.py new file mode 100755 index 0000000..aa9a13b --- /dev/null +++ b/infra/commands/rpm_n_reqs.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +from glob import glob +import sys +import subprocess +import re + + +def call_cmd(cmd): + try: + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + except subprocess.CalledProcessError as err: + sys.stderr.write(err.output.decode()) + exit(err.returncode) + return proc.stdout + + +def recur_reqs(req): + if len(rpm_provides[req]) > 1: + print "Use first ocurance of package '" + req +\ + "'. TODO get newer version." + pkg_file = rpm_provides[req][0]["file"] + print pkg_file + out = call_cmd("rpm -qpR " + pkg_file) + for line in out: + pkg = line.strip() + if pkg in rpm_provides: + recur_reqs(pkg) + # else: + # print "Not found '{}'".format(pkg) + + +if len(sys.argv) != 3: + print "Usage: {} <gbs_root_path> <required_pkg>".format(sys.argv[0]) + print "Search for <required_pkg> and all its dependencies in GBS cache" + exit(0) + +cache = sys.argv[1] + "/local/cache" +req = sys.argv[2] + +rpm_provides = {} + +cached_rpms = glob(cache + "/*/*.rpm") +for rpm in cached_rpms: + out = call_cmd("rpm -qpp " + rpm) + for line in out: + pkg = re.search(r"(.*)-([\d.]*)-([\d.]*).x86_64", line) + if pkg: + if pkg.group(1) not in rpm_provides: + rpm_provides[pkg.group(1)] = [] + rpm_provides[pkg.group(1)].append({"file": rpm, + "version1": pkg.group(2), + "version2": pkg.group(3)}) +if req in rpm_provides: + recur_reqs(req) +else: + print "'{}' not found in caches".format(req) |