[svn] r5402 - trunk/tools/mrepo

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Mon May 14 18:43:58 CEST 2007


Author: dag
Date: 2007-05-14 18:43:56 +0200 (Mon, 14 May 2007)
New Revision: 5402

Modified:
   trunk/tools/mrepo/ChangeLog
   trunk/tools/mrepo/TODO
   trunk/tools/mrepo/mrepo
Log:
Check whether version of createrepo is older than 0.4.6 (Francois Aucamp)

Modified: trunk/tools/mrepo/ChangeLog
===================================================================
--- trunk/tools/mrepo/ChangeLog	2007-05-14 09:21:06 UTC (rev 5401)
+++ trunk/tools/mrepo/ChangeLog	2007-05-14 16:43:56 UTC (rev 5402)
@@ -8,7 +8,7 @@
 - Added 5Server and 5Client products to gensystemid (Oliver Falk)
 - Added rhel5s.conf and rhel5c.conf (Oliver Falk)
 - Added amd64 as alias for x86_64 to accomodate Sun's Java packages (Tom G. Christensen)
-- Option -f/--force now rewrites apt release files (Tom G. Christensen)
+- Check whether version of createrepo is older than 0.4.6 (Francois Aucamp)
 
 * 0.8.4 - Sint-Jacobsplein - released 13/12/2006
 - Renamed Yam to mrepo (Matthew Hannigan)

Modified: trunk/tools/mrepo/TODO
===================================================================
--- trunk/tools/mrepo/TODO	2007-05-14 09:21:06 UTC (rev 5401)
+++ trunk/tools/mrepo/TODO	2007-05-14 16:43:56 UTC (rev 5402)
@@ -28,6 +28,7 @@
 + Complain when a required tool is not available
 + Add URPMI and Red Carpet support (help needed)
 + Add YaST/YOU support (both for mirroring as providing metadata, seems impossible ?)
++ Update Apt release info transparantly when mrepo config changes (Tom G. Christensen)
 
 ### Reporting utility
 + Logwatch configuration for mrepo

Modified: trunk/tools/mrepo/mrepo
===================================================================
--- trunk/tools/mrepo/mrepo	2007-05-14 09:21:06 UTC (rev 5401)
+++ trunk/tools/mrepo/mrepo	2007-05-14 16:43:56 UTC (rev 5402)
@@ -695,6 +695,25 @@
         "Create a repomd repository"
         if not cf.cmd['createrepo']:
             raise mrepoGenerateException('Command createrepo is not found. Skipping.')
+
+        ### Find the createrepo version we are using (due to groupfile usage changes)
+        createrepo_version = None
+        groupfilename = 'RPMS.%s/comps.xml' % self.name
+        try:
+            sys.path.append("/usr/share/createrepo")
+            import genpkgmetadata
+            createrepo_version = genpkgmetadata.__version__
+            sys.path.remove("/usr/share/createrepo")
+            del genpkgmetadata
+        except:
+            pass
+
+        ### If version < 0.4.6, then use the old createrepo behaviour
+        if not createrepo_version:
+            error(0, '%s: Version of createrepo could not be found. Assuming newer than 0.4.6.' % self.dist.nick)
+        elif vercmp(createrepo_version, '0.4.6') < 0:
+            groupfilename = 'comps.xml'
+
         opts = ' ' + cf.createrepooptions
         if op.force:
             opts = ' --pretty'
@@ -715,7 +734,7 @@
             groupfile = os.path.join(cf.srcdir, self.dist.nick, self.name + '-comps.xml')
             if os.path.isfile(groupfile):
                 symlink(groupfile, os.path.join(self.wwwdir, 'comps.xml'))
-                repoopts = repoopts + ' --groupfile "RPMS.%s/comps.xml"' % self.name
+                repoopts = repoopts + ' --groupfile "%s"' % groupfilename
             info(2, '%s: Create repomd repository for %s' % (self.dist.nick, self.name))
             ret = run('%s %s %s' % (cf.cmd['createrepo'], repoopts, self.wwwdir))
             if ret:
@@ -754,7 +773,7 @@
 
         ### Write out /srcdir/nick/base/release
         releasefile = os.path.join(self.dist.dir, 'base', 'release')
-        if op.force or not os.path.exists(releasefile):
+        if not os.path.exists(releasefile):
             open(releasefile, 'w').write(
                 'Origin: %s\n'\
                 'Label: %s\n'\
@@ -769,7 +788,7 @@
 
         ### Write out /srcdir/nick/base/release.repo
         releasefile = os.path.join(self.dist.dir, 'base', 'release.'+ self.name)
-        if op.force or not os.path.exists(releasefile):
+        if not os.path.exists(releasefile):
             open(releasefile, 'w').write(
                 'Archive: %s\n'\
                 'Component: %s\n'\
@@ -939,6 +958,17 @@
 def reposort(a, b):
     return cmp(a.name, b.name)
 
+def vercmp(a, b):
+    al = a.split('.')
+    bl = b.split('.')
+    minlen = min(len(al), len(bl))
+    for i in range(1, minlen):
+        if cmp(al[i], bl[i]) < 0:
+            return -1
+        elif cmp(al[i], bl[i]) > 0:
+            return 1
+    return 0
+
 def symlinkglob(str, *targets):
     "Symlink files to multiple targets"
     for file in glob.glob(str):




More information about the commits mailing list