Patchwork [10/22] createrepo: implement support for recommends

login
register
mail settings
Submitter Mark Hatle
Date Dec. 4, 2012, 5:14 p.m.
Message ID <d9cb3d054dacf0dabe8c699a458bdcd14f021f43.1354641032.git.mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/40299/
State Accepted
Commit 5443525de8c209c27eab0457c9a5a7ca11ec9865
Headers show

Comments

Mark Hatle - Dec. 4, 2012, 5:14 p.m.
From: Paul Eggleton <paul.eggleton@linux.intel.com>

Adds a flag into the output metadata to note recommends relationships
in a way that should not break compatibility with clients that don't
understand this flag.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 .../createrepo/createrepo/recommends.patch         |   71 ++++++++++++++++++++
 .../createrepo/createrepo_0.4.11.bb                |    3 +-
 2 files changed, 73 insertions(+), 1 deletions(-)
 create mode 100644 meta/recipes-support/createrepo/createrepo/recommends.patch

Patch

diff --git a/meta/recipes-support/createrepo/createrepo/recommends.patch b/meta/recipes-support/createrepo/createrepo/recommends.patch
new file mode 100644
index 0000000..dc5de2b
--- /dev/null
+++ b/meta/recipes-support/createrepo/createrepo/recommends.patch
@@ -0,0 +1,71 @@ 
+createrepo: implement recommends support
+
+Record against the corresponding requires entry in the output metadata
+if a dependency relationship is marked with the RPMSENSE_MISSINGOK flag
+(indicating it is a recommendation, rather than a hard dependency).
+
+Upstream-Status: Pending
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+
+diff --git a/dumpMetadata.py b/dumpMetadata.py
+index 70bb2d8..e40e8ac 100644
+--- a/dumpMetadata.py
++++ b/dumpMetadata.py
+@@ -319,6 +319,23 @@ class RpmMetaData:
+                     reqs.append(0)
+         return reqs
+ 
++    def _checkMissingOk(self, flags):
++        reqs=[]
++        if flags is None:
++            return reqs
++
++        if type(flags) is not types.ListType:
++            flags = [flags]
++        for flag in flags:
++            newflag = flag
++            if flag is not None:
++                newflag = flag & rpm.RPMSENSE_MISSINGOK
++                if newflag:
++                    reqs.append(1)
++                else:
++                    reqs.append(0)
++        return reqs
++
+ 
+     def _correctVersion(self, vers):
+         returnvers = []
+@@ -537,9 +554,10 @@ class RpmMetaData:
+         tmpflags = self.hdr[rpm.RPMTAG_REQUIREFLAGS]
+         flags = self._correctFlags(tmpflags)
+         prereq = self._checkPreReq(tmpflags)
++        missingok = self._checkMissingOk(tmpflags)
+         ver = self._correctVersion(self.hdr[rpm.RPMTAG_REQUIREVERSION])
+         if names is not None:
+-            lst = zip(names, flags, ver, prereq)
++            lst = zip(names, flags, ver, prereq, missingok)
+         return self._uniq(lst)
+         
+     def obsoletesList(self):
+@@ -692,7 +710,7 @@ def generateXML(doc, node, formatns, rpmObj, sumtype):
+     depsList = rpmObj.depsList()
+     if len(depsList) > 0:
+         rpconode = format.newChild(formatns, 'requires', None)    
+-        for (name, flags, (e,v,r), prereq) in depsList:
++        for (name, flags, (e,v,r), prereq, missingok) in depsList:
+             entry = rpconode.newChild(formatns, 'entry', None)
+             entry.newProp('name', name)
+             if flags != 0:
+@@ -711,6 +729,8 @@ def generateXML(doc, node, formatns, rpmObj, sumtype):
+                     entry.newProp('rel', str(r))
+             if prereq == 1:
+                 entry.newProp('pre', str(prereq))
++            if missingok:
++                entry.newProp('missingok', '1')
+         
+     for file in rpmObj.usefulFiles():
+         files = format.newChild(None, 'file', None)
+-- 
+1.7.9.5
+
diff --git a/meta/recipes-support/createrepo/createrepo_0.4.11.bb b/meta/recipes-support/createrepo/createrepo_0.4.11.bb
index 8d2dcdf..227ebcb 100644
--- a/meta/recipes-support/createrepo/createrepo_0.4.11.bb
+++ b/meta/recipes-support/createrepo/createrepo_0.4.11.bb
@@ -6,12 +6,13 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=18810669f13b87348459e611d31ab760"
 
 RDEPENDS_${PN}_class-native += "libxml2-native rpm-native"
 
-PR = "r7"
+PR = "r8"
 
 SRC_URI= "http://createrepo.baseurl.org/download/${BP}.tar.gz \
           file://fix-native-install.patch \
           file://python-scripts-should-use-interpreter-from-env.patch \
 	  file://createrepo-rpm549.patch \
+	  file://recommends.patch \
 	  file://rpm-createsolvedb.py \
          "