Re: Minor patch for createrepo (to allow .deb indexing)

"Javier Palacios" <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
> >> Sounds like a good idea, but is createrepo able to really >index< .deb
> >> files; I mean getting name, version, release, description, ... from the
> >> pkgs?
> >>
> >
> > not as-is but I guess it could be made to be.
>

Actually it is quite easy. The main problem is on the yum part, not in
the createrepo one.

> kk. Just wanted to now if this piece of code is somewhere/-what hidden
> where I had no look at yet :-)

I've attached the full patch for createrepo. What it is not yet ready
for human eyes is the dpkg2rpm module which is actually where the real
work is. I want to make some cleaning and  repeat a couple of
integration tests with yum prior to release the python code.

The current version is able to index at least a multiarch dvd (32/64
bits and ppc) for debian 4.0 and the ubuntu server 7.04 for i386, as
well as an FC6 dvd.

_______________________________________________
Rpm-metadata mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
dpkg_extension.patch (text/x-patch, 4 KB)
diff --git a/dumpMetadata.py b/dumpMetadata.py
index 396435a..af1f24e 100644
--- a/dumpMetadata.py
+++ b/dumpMetadata.py
@@ -251,7 +251,10 @@ class RpmMetaData:
         fo = os.fdopen(fd, 'rb')
         self.pkgid = self.doChecksumCache(fo)
         fo.seek(0)
-        (self.rangestart, self.rangeend) = byteranges(fo)
+        if rpm.__name__ == "rpm" :
+            (self.rangestart, self.rangeend) = byteranges(fo)
+        else :
+            (self.rangestart, self.rangeend) = (0,0)
         fo.close()
         del fo
         del fd
diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index 22b7c85..50f0075 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -64,6 +64,8 @@ def usage(retval=1):
      -p, --pretty = output xml files in pretty format.
      --update = update existing metadata (if present)
      -d, --database = generate the sqlite databases.
+     --pkgtype <type> = create repository with packages of type <type>
+                     (only 'deb' is currently supported)
     """)
 
     sys.exit(retval)
@@ -99,7 +101,7 @@ class MetaDataGenerator:
 
     def checkTimeStamps(self, directory):
         if self.cmds['checkts']:
-            files = self.getFileList(self.cmds['basedir'], directory, '.rpm')
+            files = self.getFileList(self.cmds['basedir'], directory, self.cmds['pkgext'])
             files = self.trimRpms(files)
             for f in files:
                 fn = os.path.join(self.cmds['basedir'], directory, f)
@@ -138,7 +140,7 @@ class MetaDataGenerator:
             #and scan the old repo
             self.oldData = readMetadata.MetadataIndex(self.cmds['outputdir'],
                                                       basefile, flfile, otherfile, opts)
-        files = self.getFileList(self.cmds['basedir'], directory, '.rpm')
+        files = self.getFileList(self.cmds['basedir'], directory, self.cmds['pkgext'])
         files = self.trimRpms(files)
         self.pkgcount = len(files)
         self.openMetadataDocs()
@@ -346,7 +348,7 @@ class SplitMetaDataGenerator(MetaDataGenerator):
             return
         filematrix = {}
         for mydir in directories:
-            filematrix[mydir] = self.getFileList(self.cmds['basedir'], mydir, '.rpm')
+            filematrix[mydir] = self.getFileList(self.cmds['basedir'], mydir, self.cmds['pkgext'])
             self.trimRpms(filematrix[mydir])
             self.pkgcount += len(filematrix[mydir])
 
@@ -414,6 +416,7 @@ def parseArgs(args):
     cmds['file-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
     cmds['dir-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*']
     cmds['skip-symlinks'] = False
+    cmds['pkgext'] = '.rpm'
 
     try:
         gopts, argsleft = getopt.getopt(args, 'phqVvndg:s:x:u:c:o:CS', ['help', 'exclude=',
@@ -421,7 +424,7 @@ def parseArgs(args):
                                                                   'baseurl=', 'groupfile=', 'checksum=',
                                                                   'version', 'pretty', 'split', 'outputdir=',
                                                                   'noepoch', 'checkts', 'database', 'update',
-                                                                  'skip-symlinks'])
+                                                                  'skip-symlinks', 'pkgtype='])
     except getopt.error, e:
         errorprint(_('Options Error: %s.') % e)
         usage()
@@ -493,6 +496,15 @@ def parseArgs(args):
                 cmds['database'] = True
             elif arg in ['-S', '--skip-symlinks']:
                 cmds['skip-symlinks'] = True
+            elif arg == '--pkgtype':
+                if a == "deb" :
+                    import dpkg2rpm
+                    __builtins__.globals()['rpm'] = dpkg2rpm
+                    __builtins__.globals()['dumpMetadata'].rpm = dpkg2rpm
+                    cmds['pkgext'] = '.deb'
+                else :
+                    errorprint(_('Package system %s not supported') % a)
+                    usage()
                 
     except ValueError, e:
         errorprint(_('Options Error: %s') % e)
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.