[Rpm-metadata] Testing on HEAD

Hans-Peter Jansen hpj at urpla.net
Fri Jul 28 22:51:23 UTC 2006


Am Freitag, 28. Juli 2006 21:51 schrieb Paul Nasrat:
> On Fri, 2006-07-28 at 15:47 -0400, Paul Nasrat wrote:
> > I think I've fixed up the relative/absolute/split path cases with
> > the new os.path.walk based finder.  I've nuked the unit tests for
> > now but I'd be gratefull if people could test out HEAD and see if
> > it's working from them in their use cases.
> >
> > I know I need to make the cache code paths write to the correct
> > outputdir.  So if someone can clarify the expected behaviour I'll
> > do that.
>
> Actually I reread my mail and HEAD should now behave like it did
> previously for relative cache dir (and now it'll work with
> --outputdir too!).

Confirmed. In the typical usage modes, this version behaves just as 
before you broke it ;-) Haven't looked at --outputdir or --split 
options, yet, but rediffed my timestamp check option. Mind looking 
into it this time, and just tell, if this has a chance to go in or not.

--- genpkgmetadata.py.orig	2006-07-28 23:42:59.000000000 +0200
+++ genpkgmetadata.py	2006-07-29 00:11:43.075334984 +0200
@@ -56,6 +56,8 @@ def usage(retval=1):
                     (<filename> relative to directory-of-packages)
      -v, --verbose = run verbosely
      -c, --cachedir <dir> = specify which dir to use for the checksum cache
+     -C, --checkts = don't generate repo metadata, if their ctimes are newer
+                     than the rpm ctimes.
      -h, --help = show this help
      -V, --version = output version
      -p, --pretty = output xml files in pretty format.
@@ -90,6 +92,17 @@ class MetaDataGenerator:
         os.path.walk(startdir, extension_visitor, filelist)
         return filelist
 
+    def checkTimeStamps(self, directory):
+        if self.cmds['checkts']:
+            files = self.getFileList(self.cmds['basedir'], directory, '.rpm')
+            files = self.trimRpms(files)
+            for f in files:
+                fn = os.path.join(self.cmds['basedir'], directory, f)
+                if not os.path.exists(fn):
+                    errorprint(_('cannot get to file: %s') % fn)
+                if os.path.getctime(fn) > self.cmds['mdtimestamp']:
+                    return False
+        return True
 
     def trimRpms(self, files):
         badrpms = []
@@ -360,17 +373,19 @@ def parseArgs(args):
     cmds['cachedir'] = None
     cmds['basedir'] = os.getcwd()
     cmds['cache'] = False
+    cmds['checkts'] = False
+    cmds['mdtimestamp'] = 0
     cmds['split'] = False
     cmds['outputdir'] = ""
     cmds['file-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
     cmds['dir-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*']
 
     try:
-        gopts, argsleft = getopt.getopt(args, 'phqVvng:s:x:u:c:o:', ['help', 'exclude=',
+        gopts, argsleft = getopt.getopt(args, 'phqVvng:s:x:u:c:o:C', ['help', 'exclude=',
                                                                   'quiet', 'verbose', 'cachedir=', 'basedir=',
                                                                   'baseurl=', 'groupfile=', 'checksum=',
                                                                   'version', 'pretty', 'split', 'outputdir=',
-                                                                  'noepoch'])
+                                                                  'noepoch', 'checkts'])
     except getopt.error, e:
         errorprint(_('Options Error: %s.') % e)
         usage()
@@ -428,6 +443,8 @@ def parseArgs(args):
             elif arg in ['-c', '--cachedir']:
                 cmds['cache'] = True
                 cmds['cachedir'] = a
+            elif arg in ['-C', '--checkts']:
+                cmds['checkts'] = True
             elif arg == '--basedir':
                 cmds['basedir'] = a
             elif arg in ['-o','--outputdir']:
@@ -439,6 +456,10 @@ def parseArgs(args):
         errorprint(_('Options Error: %s') % e)
         usage()
 
+    if cmds['split'] and cmds['checkts']:
+        errorprint(_('--split and --checkts options are mutually exclusive'))
+        sys.exit(1)
+
     directory = directories[0]
 # 
     directory = os.path.normpath(directory)
@@ -522,13 +543,21 @@ def main(args):
                 if not os.access(filepath, os.W_OK):
                     errorprint(_('error in must be able to write to metadata files:\n  -> %s') % filepath)
                     usage()
-
+                if cmds['checkts']:
+                    ts = os.path.getctime(filepath)
+                    if ts > cmds['mdtimestamp']:
+                        cmds['mdtimestamp'] = ts
+        
     if cmds['split']:
         cmds['basedir'] = oldbase
         mdgen = SplitMetaDataGenerator(cmds)
         mdgen.doPkgMetadata(directories)
     else:
         mdgen = MetaDataGenerator(cmds)
+        if cmds['checkts'] and mdgen.checkTimeStamps(directory):
+            if cmds['verbose']:
+                print _('repo is up to date')
+            sys.exit(0)
         mdgen.doPkgMetadata(directory)
     mdgen.doRepoMetadata()

--- ChangeLog.orig	2006-07-19 21:12:39.546793958 +0200
+++ ChangeLog	2006-07-19 21:29:48.365194764 +0200
@@ -1,3 +1,10 @@
+2006-07-19 21:03  hpj at urpla.net
+
+	* genpkgmetadata.py, docs/createrepo.8:
+	-C, --checkts option added to avoid metadata generation, if ctime
+	filestamps are up to date. It's currently mutually exclusive with
+	the --split option.
+
 2006-07-19 14:23  lmacken
 
 	* createrepo.spec: remove python-urlgrabber dependency
--- docs/createrepo.8.orig	2006-07-19 21:12:54.095275300 +0200
+++ docs/createrepo.8	2006-07-19 21:29:45.396300173 +0200
@@ -32,6 +32,12 @@ cache of checksums of packages in the re
 createrepo over the same repository of files that do not have a complete
 change out of all packages this decreases the processing time dramatically.
 .br
+.IP "\fB\-C --checkts\fP"
+Don't generate repo metadata, if their timestamps are newer than its rpms.
+This option decreases the processing time drastically again, if you happen
+to run it on an unmodified repo, but it is (currently) mutual exclusive
+with the --split option.
+.br
 .IP "\fB\--split\fP"
 Run in split media mode. Rather than pass a single directory, take a set of
 directories corresponding to different volumes in a media set.

Pete



More information about the Rpm-metadata mailing list