From: Paul Nasrat Date: Fri, 11 Aug 2006 20:01:38 +0000 (+0000) Subject: Patch from Hans-Peter Jansen X-Git-Tag: upstream/0.9.9~223 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17790f290c3b39fc32115bec34cf4f6ebc270527;p=tools%2Fcreaterepo.git Patch from Hans-Peter Jansen -C, --checkts option added to avoid metadata generation, if ctime filestamps are up to date. It's currently mutually exclusive with the --split option. --- diff --git a/docs/createrepo.8 b/docs/createrepo.8 index 6af66ee..f19fe5d 100644 --- a/docs/createrepo.8 +++ b/docs/createrepo.8 @@ -32,6 +32,12 @@ cache of checksums of packages in the repository. In consecutive runs of 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. diff --git a/genpkgmetadata.py b/genpkgmetadata.py index 1cbddd5..c00986b 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -56,6 +56,8 @@ def usage(retval=1): ( relative to directory-of-packages) -v, --verbose = run verbosely -c, --cachedir = 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()