Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | createrepo: implement recommends support |
| 2 | |
| 3 | Record against the corresponding requires entry in the output metadata |
| 4 | if a dependency relationship is marked with the RPMSENSE_MISSINGOK flag |
| 5 | (indicating it is a recommendation, rather than a hard dependency). |
| 6 | |
| 7 | Upstream-Status: Pending |
| 8 | |
| 9 | Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> |
| 10 | |
| 11 | diff --git a/dumpMetadata.py b/dumpMetadata.py |
| 12 | index 70bb2d8..e40e8ac 100644 |
| 13 | --- a/dumpMetadata.py |
| 14 | +++ b/dumpMetadata.py |
| 15 | @@ -319,6 +319,23 @@ class RpmMetaData: |
| 16 | reqs.append(0) |
| 17 | return reqs |
| 18 | |
| 19 | + def _checkMissingOk(self, flags): |
| 20 | + reqs=[] |
| 21 | + if flags is None: |
| 22 | + return reqs |
| 23 | + |
| 24 | + if type(flags) is not types.ListType: |
| 25 | + flags = [flags] |
| 26 | + for flag in flags: |
| 27 | + newflag = flag |
| 28 | + if flag is not None: |
| 29 | + newflag = flag & rpm.RPMSENSE_MISSINGOK |
| 30 | + if newflag: |
| 31 | + reqs.append(1) |
| 32 | + else: |
| 33 | + reqs.append(0) |
| 34 | + return reqs |
| 35 | + |
| 36 | |
| 37 | def _correctVersion(self, vers): |
| 38 | returnvers = [] |
| 39 | @@ -537,9 +554,10 @@ class RpmMetaData: |
| 40 | tmpflags = self.hdr[rpm.RPMTAG_REQUIREFLAGS] |
| 41 | flags = self._correctFlags(tmpflags) |
| 42 | prereq = self._checkPreReq(tmpflags) |
| 43 | + missingok = self._checkMissingOk(tmpflags) |
| 44 | ver = self._correctVersion(self.hdr[rpm.RPMTAG_REQUIREVERSION]) |
| 45 | if names is not None: |
| 46 | - lst = zip(names, flags, ver, prereq) |
| 47 | + lst = zip(names, flags, ver, prereq, missingok) |
| 48 | return self._uniq(lst) |
| 49 | |
| 50 | def obsoletesList(self): |
| 51 | @@ -692,7 +710,7 @@ def generateXML(doc, node, formatns, rpmObj, sumtype): |
| 52 | depsList = rpmObj.depsList() |
| 53 | if len(depsList) > 0: |
| 54 | rpconode = format.newChild(formatns, 'requires', None) |
| 55 | - for (name, flags, (e,v,r), prereq) in depsList: |
| 56 | + for (name, flags, (e,v,r), prereq, missingok) in depsList: |
| 57 | entry = rpconode.newChild(formatns, 'entry', None) |
| 58 | entry.newProp('name', name) |
| 59 | if flags != 0: |
| 60 | @@ -711,6 +729,8 @@ def generateXML(doc, node, formatns, rpmObj, sumtype): |
| 61 | entry.newProp('rel', str(r)) |
| 62 | if prereq == 1: |
| 63 | entry.newProp('pre', str(prereq)) |
| 64 | + if missingok: |
| 65 | + entry.newProp('missingok', '1') |
| 66 | |
| 67 | for file in rpmObj.usefulFiles(): |
| 68 | files = format.newChild(None, 'file', None) |
| 69 | -- |
| 70 | 1.7.9.5 |
| 71 | |