aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-06-28 11:50:53 +0200
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-06-28 20:17:09 +0200
commit51641610aea61c0633912dafc5a8f51e454cade9 (patch)
treee1d4da2bc640617b8e5021e859a06c28188aff4d /MgaRepo
parent0f3861e168d9edc1611b106af32e3cbce3f86ddd (diff)
downloadmgarepo-51641610aea61c0633912dafc5a8f51e454cade9.tar
mgarepo-51641610aea61c0633912dafc5a8f51e454cade9.tar.gz
mgarepo-51641610aea61c0633912dafc5a8f51e454cade9.tar.bz2
mgarepo-51641610aea61c0633912dafc5a8f51e454cade9.tar.xz
mgarepo-51641610aea61c0633912dafc5a8f51e454cade9.zip
implement get_rpm_tag for getting package tags from spec file
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/rpmutil.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 443a403..0bd2ef8 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -899,4 +899,22 @@ def get_submit_info(path):
return name, url, max
+def get_pkg_tag(tag, subpkg=None):
+ topdir = getpkgtopdir()
+ speclist = glob.glob(os.path.join(topdir, "SPECS", "*.spec"))
+ if not speclist:
+ raise Error("no spec files found")
+ specfile = speclist[0]
+
+ pkg = rpm.spec(specfile)
+ if subpkg is None:
+ header = pkg.sourceHeader
+ elif isinstance(subpkg,int):
+ header = pkg.packages(subpkg)
+ else:
+ raise Error("Subpkg must be the index number of a package,"\
+ "or None for source package")
+
+ return header[tag]
+
# vim:et:ts=4:sw=4