[Rpm-metadata] Branch 'maintenance' - genpkgmetadata.py readMetadata.py

Seth Vidal skvidal at linux.duke.edu
Fri Jan 18 20:45:12 UTC 2008


 genpkgmetadata.py |   11 ++++++++++-
 readMetadata.py   |   39 +++++++++++++++++++++------------------
 2 files changed, 31 insertions(+), 19 deletions(-)

New commits:
commit cb9dfcb56f8190ffc440c7c841c969ab31d1bd91
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Fri Jan 18 15:41:32 2008 -0500

    add --skip-stat to maintenance version of createrepo

diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index bef0225..631f95f 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -65,6 +65,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.
+     --skip-stat = skip the stat() call on a --update, assumes if the name
+                   is the same then the file is the same.
     """)
 
     sys.exit(retval)
@@ -151,6 +153,9 @@ class MetaDataGenerator:
                 'verbose' : self.cmds['verbose'],
                 'pkgdir' : os.path.normpath(os.path.join(self.cmds['basedir'], directory))
             }
+            if self.cmds['skip_stat']:
+                opts['do_stat'] = False
+                
             #and scan the old repo
             self.oldData = readMetadata.MetadataIndex(self.cmds['outputdir'],
                                                       basefile, flfile, otherfile, opts)
@@ -434,6 +439,7 @@ def parseArgs(args):
     cmds['file-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
     cmds['dir-pattern-match'] = ['.*bin\/.*', '^\/etc\/.*']
     cmds['skip-symlinks'] = False
+    cmds['skip_stat'] = False
     cmds['pkglist'] = []
 
     try:
@@ -442,7 +448,8 @@ def parseArgs(args):
                                                                   'baseurl=', 'groupfile=', 'checksum=',
                                                                   'version', 'pretty', 'split', 'outputdir=',
                                                                   'noepoch', 'checkts', 'database', 'update',
-                                                                  'skip-symlinks', 'pkglist='])
+                                                                  'skip-symlinks', 'pkglist=',
+                                                                  'skip-stat'])
     except getopt.error, e:
         errorprint(_('Options Error: %s.') % e)
         usage()
@@ -514,6 +521,8 @@ def parseArgs(args):
                 cmds['database'] = True
             elif arg in ['-S', '--skip-symlinks']:
                 cmds['skip-symlinks'] = True
+            elif arg == '--skip-stat':
+                cmds['skip_stat'] = True
             elif arg in ['-i', '--pkglist']:
                 cmds['pkglist'] = a
                                 
diff --git a/readMetadata.py b/readMetadata.py
index 60e6129..3aaa891 100644
--- a/readMetadata.py
+++ b/readMetadata.py
@@ -87,6 +87,8 @@ class MetadataIndex(object):
         mtime = None
         size = None
         relpath = None
+        do_stat = self.opts.get('do_stat', True)
+
         while node is not None:
             if node.type != "element":
                 node = node.next
@@ -112,24 +114,25 @@ class MetadataIndex(object):
         if size is None:
             print _("size missing for %s") % relpath
             return
-        filepath = os.path.join(self.opts['pkgdir'], relpath)
-        try:
-            st = os.stat(filepath)
-        except OSError:
-            #file missing -- ignore
-            return
-        if not stat.S_ISREG(st.st_mode):
-            #ignore non files
-            return
-        #check size and mtime
-        if st.st_size != size:
-            if self.opts.get('verbose'):
-                print _("Size (%i -> %i) changed for file %s") % (size,st.st_size,filepath)
-            return
-        if st.st_mtime != mtime:
-            if self.opts.get('verbose'):
-                print _("Modification time changed for %s") % filepath
-            return
+        if do_stat:
+            filepath = os.path.join(self.opts['pkgdir'], relpath)
+            try:
+                st = os.stat(filepath)
+            except OSError:
+                #file missing -- ignore
+                return
+            if not stat.S_ISREG(st.st_mode):
+                #ignore non files
+                return
+            #check size and mtime
+            if st.st_size != size:
+                if self.opts.get('verbose'):
+                    print _("Size (%i -> %i) changed for file %s") % (size,st.st_size,filepath)
+                return
+            if st.st_mtime != mtime:
+                if self.opts.get('verbose'):
+                    print _("Modification time changed for %s") % filepath
+                return
         #otherwise we index
         self.basenodes[relpath] = top
         self.pkg_ids[relpath] = pkgid



More information about the Rpm-metadata mailing list