summaryrefslogtreecommitdiff
path: root/Pkg.py
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-02-06 13:11:08 -0800
committerAnas Nashif <anas.nashif@intel.com>2013-02-06 17:32:17 -0800
commit1b2063d75a26bcf584d3f80d3019b4c298dee2f6 (patch)
tree03c78ef4ffcae7046e6966d9b14099759322b7b1 /Pkg.py
parent26b7b2ed08528ff3e784c792d199c7af4d3b3945 (diff)
downloadrpmlint-1b2063d75a26bcf584d3f80d3019b4c298dee2f6.tar.gz
rpmlint-1b2063d75a26bcf584d3f80d3019b4c298dee2f6.tar.bz2
rpmlint-1b2063d75a26bcf584d3f80d3019b4c298dee2f6.zip
add-weak-dependencies.diff
===================================================================
Diffstat (limited to 'Pkg.py')
-rw-r--r--Pkg.py57
1 files changed, 55 insertions, 2 deletions
diff --git a/Pkg.py b/Pkg.py
index 14118aa..1656f8d 100644
--- a/Pkg.py
+++ b/Pkg.py
@@ -426,6 +426,10 @@ class Pkg:
self._missingok_files = None
self._files = None
self._requires = None
+ self._suggests = None
+ self._supplements = None
+ self._enhances = None
+ self._recommends = None
self._req_names = -1
if header:
@@ -673,6 +677,22 @@ class Pkg:
self._gatherDepInfo()
return self._requires
+ def recommends(self):
+ self._gatherDepInfo()
+ return self._recommends
+
+ def suggests(self):
+ self._gatherDepInfo()
+ return self._suggests
+
+ def supplements(self):
+ self._gatherDepInfo()
+ return self._supplements
+
+ def enhances(self):
+ self._gatherDepInfo()
+ return self._enhances
+
def prereq(self):
"""Get package PreReqs as list of
(name, flags, (epoch, version, release)) tuples."""
@@ -709,7 +729,7 @@ class Pkg:
# internal function to gather dependency info used by the above ones
def _gather_aux(self, header, list, nametag, flagstag, versiontag,
- prereq = None):
+ prereq = None, strong_only = False, weak_only = False):
names = header[nametag]
flags = header[flagstag]
versions = header[versiontag]
@@ -720,7 +740,11 @@ class Pkg:
if prereq is not None and flags[loop] & PREREQ_FLAG:
prereq.append((names[loop], flags[loop] & (~PREREQ_FLAG),
evr))
- else:
+ elif strong_only and flags[loop] & rpm.RPMSENSE_STRONG:
+ list.append((names[loop], versions[loop], flags[loop] & (~rpm.RPMSENSE_STRONG)))
+ elif weak_only and not (flags[loop] & rpm.RPMSENSE_STRONG):
+ list.append((names[loop], versions[loop], flags[loop]))
+ elif not (weak_only or strong_only):
list.append((names[loop], flags[loop], evr))
def _gatherDepInfo(self):
@@ -730,6 +754,10 @@ class Pkg:
self._provides = []
self._conflicts = []
self._obsoletes = []
+ self._suggests = []
+ self._supplements = []
+ self._enhances = []
+ self._recommends = []
self._gather_aux(self.header, self._requires,
rpm.RPMTAG_REQUIRENAME,
@@ -748,6 +776,30 @@ class Pkg:
rpm.RPMTAG_OBSOLETENAME,
rpm.RPMTAG_OBSOLETEFLAGS,
rpm.RPMTAG_OBSOLETEVERSION)
+ try:
+ self._gather_aux(self.header, self._recommends,
+ rpm.RPMTAG_SUGGESTSNAME,
+ rpm.RPMTAG_SUGGESTSFLAGS,
+ rpm.RPMTAG_SUGGESTSVERSION,
+ strong_only=True)
+ self._gather_aux(self.header, self._suggests,
+ rpm.RPMTAG_SUGGESTSNAME,
+ rpm.RPMTAG_SUGGESTSFLAGS,
+ rpm.RPMTAG_SUGGESTSVERSION,
+ weak_only=True)
+ self._gather_aux(self.header, self._supplements,
+ rpm.RPMTAG_ENHANCESNAME,
+ rpm.RPMTAG_ENHANCESFLAGS,
+ rpm.RPMTAG_ENHANCESVERSION,
+ strong_only=True)
+ self._gather_aux(self.header, self._enhances,
+ rpm.RPMTAG_ENHANCESNAME,
+ rpm.RPMTAG_ENHANCESFLAGS,
+ rpm.RPMTAG_ENHANCESVERSION,
+ weak_only=True)
+ except:
+ pass
+
def scriptprog(self, which):
"""Get the specified script interpreter as a string.
@@ -761,6 +813,7 @@ class Pkg:
prog = " ".join(prog)
return prog
+
def getInstalledPkgs(name):
"""Get list of installed package objects by name."""