Re: Two patches from SUSE

Christoph Thiel <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
On Wed, May 16, 2007 at 10:59:21AM +0100, Paul Nasrat wrote:
> On Wed, 2007-05-16 at 11:25 +0200, Christoph Thiel wrote:
> 
> > Please find a slightly changed createrepo-0.4.8-cachefix.patch attached. I
> > had to add another check for older RPM versions, that behave differently.
> 
> Could you rediff against cvs HEAD, thanks.

Sure, please find the patch attached.

I'v also included a couple of other patches that we are currently using with
our createrepo:

  * missing-tags.patch
    adds support for Enhances, Supplements, Suggests, and Recommends.

  * createrepo-0.4.4-suse-changelogs.patch
    remove stupid leading dash from author on changelog entries.

  * createrepo-0.4.8-cache_utime.patch
    touch cache files that have been used, to be able to cleanup the cache
    after a createrepo run by just looking at the mtime of each file.

  * createrepo-0.4.8-try_sqlitecachec.patch
    make sqlitecachec/yum-metadata-parser a weak dependency (might need
    further work to disable -d option in case sqlitecachec isn't there.)


Best,
Christoph
-- 
Christoph Thiel, Tech. Project Management, Research & Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)

_______________________________________________
Rpm-metadata mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
createrepo-0.4.9-cachefix.patch (text/x-patch, 789 B)
--- dumpMetadata.py
+++ dumpMetadata.py
@@ -599,9 +599,12 @@
             return getChecksum(self.options['sumtype'], fo)
 
         t = []
-        t.append("".join(self.hdr[rpm.RPMTAG_SIGGPG]))   
-        t.append("".join(self.hdr[rpm.RPMTAG_SIGPGP]))
-        t.append("".join(self.hdr[rpm.RPMTAG_HDRID]))
+        if type(self.hdr[rpm.RPMTAG_SIGGPG]) is not types.NoneType:
+            t.append("".join(self.hdr[rpm.RPMTAG_SIGGPG]))   
+        if type(self.hdr[rpm.RPMTAG_SIGPGP]) is not types.NoneType:
+            t.append("".join(self.hdr[rpm.RPMTAG_SIGPGP]))
+        if type(self.hdr[rpm.RPMTAG_HDRID]) is not types.NoneType:
+            t.append("".join(self.hdr[rpm.RPMTAG_HDRID]))
 
         key = md5.new("".join(t)).hexdigest()
missing-tags.patch (text/x-patch, 4.8 KB)
--- dumpMetadata.py
+++ dumpMetadata.py
@@ -267,14 +267,10 @@
             return returnflags
 
         if type(flags) is not types.ListType:
-            newflag = flags & 0xf
-            returnflags.append(newflag)
+            returnflags.append(flags)
         else:
             for flag in flags:
-                newflag = flag
-                if flag is not None:
-                    newflag = flag & 0xf
-                returnflags.append(newflag)
+                returnflags.append(flag)
         return returnflags
 
     def _checkPreReq(self, flags):
@@ -516,36 +512,48 @@
             lst = zip(names, flags, ver, prereq)
         return self._uniq(lst)
         
-    def obsoletesList(self):
+    def tagsList(self, name, flags, version):
         lst = []
-        names = self.hdr[rpm.RPMTAG_OBSOLETENAME]
-        tmpflags = self.hdr[rpm.RPMTAG_OBSOLETEFLAGS]
+        names = self.hdr[name]
+        tmpflags = self.hdr[flags]
         flags = self._correctFlags(tmpflags)
-        ver = self._correctVersion(self.hdr[rpm.RPMTAG_OBSOLETEVERSION])
+        ver = self._correctVersion(self.hdr[version])
         if names is not None:
             lst = zip(names, flags, ver)
         return self._uniq(lst)
 
+    def obsoletesList(self):
+        return self.tagsList(rpm.RPMTAG_OBSOLETENAME, rpm.RPMTAG_OBSOLETEFLAGS,
+                             rpm.RPMTAG_OBSOLETEVERSION)
+
     def conflictsList(self):
-        lst = []
-        names = self.hdr[rpm.RPMTAG_CONFLICTNAME]
-        tmpflags = self.hdr[rpm.RPMTAG_CONFLICTFLAGS]
-        flags = self._correctFlags(tmpflags)
-        ver = self._correctVersion(self.hdr[rpm.RPMTAG_CONFLICTVERSION])
-        if names is not None:
-            lst = zip(names, flags, ver)
-        return self._uniq(lst)
+        return self.tagsList(rpm.RPMTAG_CONFLICTNAME, rpm.RPMTAG_CONFLICTFLAGS,
+                             rpm.RPMTAG_CONFLICTVERSION)
 
     def providesList(self):
-        lst = []
-        names = self.hdr[rpm.RPMTAG_PROVIDENAME]
-        tmpflags = self.hdr[rpm.RPMTAG_PROVIDEFLAGS]
-        flags = self._correctFlags(tmpflags)
-        ver = self._correctVersion(self.hdr[rpm.RPMTAG_PROVIDEVERSION])
-        if names is not None:
-            lst = zip(names, flags, ver)
-        return self._uniq(lst)
+        return self.tagsList(rpm.RPMTAG_PROVIDENAME, rpm.RPMTAG_PROVIDEFLAGS,
+                             rpm.RPMTAG_PROVIDEVERSION)
         
+    def enhancesList(self):
+        lst = self.tagsList(rpm.RPMTAG_ENHANCESNAME, rpm.RPMTAG_ENHANCESFLAGS,
+                            rpm.RPMTAG_ENHANCESVERSION)
+        return [ l for l in lst if not l[1] & rpm.RPMSENSE_STRONG ]
+
+    def supplementsList(self):
+        lst = self.tagsList(rpm.RPMTAG_ENHANCESNAME, rpm.RPMTAG_ENHANCESFLAGS,
+                            rpm.RPMTAG_ENHANCESVERSION)
+        return [ l for l in lst if l[1] & rpm.RPMSENSE_STRONG ]
+
+    def suggestsList(self):
+        lst = self.tagsList(rpm.RPMTAG_SUGGESTSNAME, rpm.RPMTAG_SUGGESTSFLAGS,
+                            rpm.RPMTAG_SUGGESTSVERSION)
+        return [ l for l in lst if not l[1] & rpm.RPMSENSE_STRONG ]
+
+    def recommendsList(self):
+        lst = self.tagsList(rpm.RPMTAG_SUGGESTSNAME, rpm.RPMTAG_SUGGESTSFLAGS,
+                            rpm.RPMTAG_SUGGESTSVERSION)
+        return [ l for l in lst if l[1] & rpm.RPMSENSE_STRONG ]
+
     def changelogLists(self):
         lst = []
         names = self.listTagByName('changelogname')
@@ -629,12 +637,18 @@
     hr.newProp('end', str(rpmObj.rangeend))
     for (lst, nodename) in [(rpmObj.providesList(), 'provides'),
                             (rpmObj.conflictsList(), 'conflicts'),
-                            (rpmObj.obsoletesList(), 'obsoletes')]:
+                            (rpmObj.obsoletesList(), 'obsoletes'),
+                            (rpmObj.enhancesList(), 'enhances'),
+                            (rpmObj.supplementsList(), 'supplements'),
+                            (rpmObj.suggestsList(), 'suggests'),
+                            (rpmObj.recommendsList(), 'recommends')]:
         if len(lst) > 0:               
             rpconode = format.newChild(formatns, nodename, None)
             for (name, flags, (e,v,r)) in lst:
                 entry = rpconode.newChild(formatns, 'entry', None)
                 entry.newProp('name', name)
+                if flags is not None:
+                    flags = flags & 0xf
                 if flags != 0:
                     if flags == 2: arg = 'LT'
                     if flags == 4: arg = 'GT'
@@ -656,6 +670,8 @@
         for (name, flags, (e,v,r), prereq) in depsList:
             entry = rpconode.newChild(formatns, 'entry', None)
             entry.newProp('name', name)
+            if flags is not None:
+                flags = flags & 0xf
             if flags != 0:
                 if flags == 2: arg = 'LT'
                 if flags == 4: arg = 'GT'
createrepo-0.4.8-try_sqlitecachec.patch (text/x-patch, 244 B)
--- dumpMetadata.py
+++ dumpMetadata.py
@@ -29,7 +29,10 @@
 import re
 import stat
 import bz2
-import sqlitecachec
+try:
+    import sqlitecachec
+except ImportError:
+    pass
 
 # done to fix gzip randomly changing the checksum
 import gzip
createrepo-0.4.8-cache_utime.patch (text/x-patch, 350 B)
--- dumpMetadata.py
+++ dumpMetadata.py
@@ -614,7 +614,7 @@
             csumo = open(csumfile, 'r')
             checksum = csumo.readline()
             csumo.close()
-            
+            os.path.os.utime(csumfile, None)
         else:
             checksum = getChecksum(self.options['sumtype'], fo)
             csumo = open(csumfile, 'w')
createrepo-0.4.4-suse-changelogs.patch (text/x-patch, 460 B)
--- dumpMetadata.py
+++ dumpMetadata.py
@@ -744,7 +744,10 @@
     for (name, time, text) in clogs:
         clog = pkg.newChild(None, 'changelog', None)
         clog.addContent(utf8String(text))
-        clog.newProp('author', utf8String(name))
+        if name[0] != '-':
+          clog.newProp('author', utf8String(name))
+        else:
+          clog.newProp('author', utf8String(name[2:]))
         clog.newProp('date', str(time))
     return pkg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.