Re: createrepo 0.4.3

Hans-Peter Jansen <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
Am Donnerstag, 14. Juli 2005 08:45 schrieb seth vidal:
> hi folks,
>  I just released createrepo 0.4.3 - it includes the cachedir option
> and I mostly included it for work regarding the fedora extras
> buildsys. However, it should help a lot of people speed up their
> metadata generation. The next big change will be 0.5.0 which should
> include an array of new items.

Hi Seth,

I unfortunately didn't got to testing this until today, and had two 
issues here:
 - SuSE 9.3 is based on rpm 4.1.1 and that throws:

Traceback (most recent call last):
  File "/usr/share/createrepo/genpkgmetadata.py", line 485, in ?
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 417, in main
    doPkgMetadata(cmds, ts)
  File "/usr/share/createrepo/genpkgmetadata.py", line 266, in doPkgMetadata
    mdobj = dumpMetadata.RpmMetaData(ts, file, cmds)
  File "/usr/share/createrepo/dumpMetadata.py", line 231, in __init__
    self.pkgid = self.doChecksumCache(fo)
  File "/usr/share/createrepo/dumpMetadata.py", line 565, in doChecksumCache
    csumtag = '%s-%s' % (self.hdr['name'] , self.hdr['hdrid'])
KeyError: 'unknown header tag'

I have two possible fixes for this, the first one 
(createrepo-nohdrid.diff) is simple straight forward, but some 
commercial packages e.g. VMware-workstation-5.0.0-13124.i386.rpm
don't provide the SHA1 header, which leads to a unsatisfying 
VMware-workstation-None checksum cache file.

createrepo-nohdrid-take2.diff tries to circumvent this behavior.
Make your choice.

The second issue is with the cachedir location. I think, it's 
most convenient for users to place it relative to the repo dir.
createrepo-rel-cachedir.diff does just that, if not specified
absolute.

Let me knows, what you think about it.

Pete

_______________________________________________
Rpm-metadata mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
createrepo-nohdrid.diff (text/x-diff, 559 B)
--- dumpMetadata.py	2005-07-14 08:37:38.000000000 +0200
+++ /usr/share/createrepo/dumpMetadata.py	2005-07-30 19:55:02.235928981 +0200
@@ -562,7 +562,7 @@
         if not self.options['cache']:
             return getChecksum(self.options['sumtype'], fo)
         
-        csumtag = '%s-%s' % (self.hdr['name'] , self.hdr['hdrid'])
+        csumtag = '%s-%s' % (self.hdr['name'] , self.hdr[rpm.RPMTAG_SHA1HEADER])
         csumfile = '%s/%s' % (self.options['cachedir'], csumtag)
         if os.path.exists(csumfile):
             csumo = open(csumfile, 'r')
createrepo-rel-cachedir.diff (text/x-diff, 562 B)
--- genpkgmetadata.py	2005-07-14 08:37:38.000000000 +0200
+++ /usr/share/createrepo/genpkgmetadata.py	2005-07-30 19:43:16.646037526 +0200
@@ -202,6 +202,8 @@
                 errorprint(_('This option is deprecated'))
             elif arg in ['-c', '--cachedir']:
                 cmds['cache'] = True
+                if not os.path.isabs(a):
+                    a = os.path.join(directory, a)
                 cmds['cachedir'] = a
                 if not checkAndMakeDir(a):
                     errorprint(_('Error: cannot open/write to cache dir %s' % a))
createrepo-nohdrid-take2.diff (text/x-diff, 1.6 KB)
--- dumpMetadata.py.orig	2005-07-30 22:02:25.095445678 +0200
+++ dumpMetadata.py	2005-07-30 23:08:29.155486051 +0200
@@ -555,14 +555,32 @@
         """return a checksum for a package:
            - check if the checksum cache is enabled
               if not - return the checksum
-              if so - check to see if it has a cache file
+              if so - search for a usable key in the header
+              - check to see if it has a cache file
                 if so, open it and return the first line's contents
                 if not, grab the checksum and write it to a file for this pkg
             """
         if not self.options['cache']:
             return getChecksum(self.options['sumtype'], fo)
+     
+        # first try the easy ones
+        key = None
+        for h in (rpm.RPMTAG_SHA1HEADER, rpm.RPMTAG_RSAHEADER, rpm.RPMTAG_DSAHEADER):
+            key = self.hdr[h]
+            if key:
+                break
+
+        # now the not so easy ones
+        if not key:
+            for h in (rpm.RPMTAG_SIGPGP, rpm.RPMTAG_SIGMD5, rpm.RPMTAG_SIGGPG):
+                key = self.hdr[h]
+                if key:
+                    # generate hexdigest from signature
+                    key = "".join([hex(ord(x))[2:].zfill(2)
+                                for x in tuple(self.hdr[h])])
+                    break
         
-        csumtag = '%s-%s' % (self.hdr['name'] , self.hdr['hdrid'])
+        csumtag = '%s-%s' % (self.hdr['name'], key)
         csumfile = '%s/%s' % (self.options['cachedir'], csumtag)
         if os.path.exists(csumfile):
             csumo = open(csumfile, 'r')
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.