- add --skip-stat to skip the stat() call on updates - this is mostly
authorSeth Vidal <skvidal@fedoraproject.org>
Tue, 15 Jan 2008 15:21:35 +0000 (10:21 -0500)
committerSeth Vidal <skvidal@fedoraproject.org>
Tue, 15 Jan 2008 15:21:35 +0000 (10:21 -0500)
  b/c the fedora createrepo call is done over nfs and that is VERY VERY
  slow for 20K stat() calls :(
- fix --pkglist - patch from jesse keating
- document options in --help output

createrepo/__init__.py
createrepo/readMetadata.py
genpkgmetadata.py

index f57e06beee17df686d24d85f55aa31959dcb7d02..4fc6c5852a83067e3b5fd452c68ece600dc9095c 100644 (file)
@@ -67,6 +67,7 @@ class MetaDataConfig(object):
         self.checkts = False
         self.split = False        
         self.update = False
+        self.skip_stat = False
         self.database = False
         self.outputdir = None
         self.file_patterns = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
@@ -211,6 +212,9 @@ class MetaDataGenerator:
                 'verbose' : self.conf.verbose,
                 'pkgdir' : os.path.normpath(os.path.join(self.conf.basedir, directory))
             }
+            if self.conf.skip_stat:
+                opts['do_stat'] = False
+                
             #and scan the old repo
             self.oldData = readMetadata.MetadataIndex(self.conf.outputdir,
                                                       primaryfile, flfile, otherfile, opts)
index 2b0713bde8ec5b4c15c79961015480980ee463ee..72ac845c621d9457b5e5660f882670044a42a33f 100644 (file)
@@ -81,6 +81,7 @@ 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
@@ -106,24 +107,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
index 22d793107c04f3d72e1d3270df8e6d18d84839ec..38cd1519d57ea34dc07aa0542468d3a7b4bcedc9 100755 (executable)
@@ -46,21 +46,39 @@ def parseArgs(args, conf):
                       help="output more debugging info.")
     parser.add_option("-x", "--excludes", default=[], action="append",
                       help="files to exclude")
-    parser.add_option("-u", "--baseurl", default=None)
-    parser.add_option("-g", "--groupfile", default=None)
-    parser.add_option("-s", "--checksum", default="sha", dest='sumtype')
-    parser.add_option("-n", "--noepoch", default=False, action="store_true")
-    parser.add_option("-p", "--pretty", default=False, action="store_true")
-    parser.add_option("-c", "--cachedir", default=None)
-    parser.add_option("--basedir", default=os.getcwd())
-    parser.add_option("-C", "--checkts", default=False, action="store_true")
-    parser.add_option("-d", "--database", default=False, action="store_true")
-    parser.add_option("--update", default=False, action="store_true")
-    parser.add_option("--split", default=False, action="store_true")
-    parser.add_option("-i", "--pkglist", default=False, action="store_true")
-    parser.add_option("-o", "--outputdir", default="")
+    parser.add_option("-u", "--baseurl", default=None,
+                      help="baseurl to append on all files")
+    parser.add_option("-g", "--groupfile", default=None,
+                      help="path to groupfile to include in metadata")
+    parser.add_option("-s", "--checksum", default="sha", dest='sumtype',
+                      help="Deprecated, ignore")
+    parser.add_option("-n", "--noepoch", default=False, action="store_true",
+                      help="don't add zero epochs for non-existent epochs"\
+                         "(incompatible with yum and smart but required for" \
+                         "systems with rpm < 4.2.1)")
+    parser.add_option("-p", "--pretty", default=False, action="store_true",
+                      help="make sure all xml generated is formatted")
+    parser.add_option("-c", "--cachedir", default=None,
+                      help="set path to cache dir")
+    parser.add_option("-C", "--checkts", default=False, action="store_true",
+      help="check timestamps on files vs the metadata to see if we need to update")
+    parser.add_option("-d", "--database", default=False, action="store_true",
+                      help="create sqlite database files")
+    parser.add_option("--update", default=False, action="store_true",
+                      help="use the existing repodata to speed up creation of new")
+    parser.add_option("--skip-stat", dest='skip_stat', default=False, action="store_true",
+                      help="skip the stat() call on a --update, assumes if the file" \
+                            "name is the same then the file is still the same" \
+                            "(only use this if you're fairly trusting or gullible)" )
+    parser.add_option("--split", default=False, action="store_true",
+                      help="generate split media")
+    parser.add_option("-i", "--pkglist", default=None, 
+        help="use only the files listed in this file from the directory specified")
+    parser.add_option("-o", "--outputdir", default=None,
+             help="<dir> = optional directory to output to")
     parser.add_option("-S", "--skip-symlinks", dest="skip_symlinks",
-                      default=False, action="store_true")
+                      default=False, action="store_true",
+                      help="ignore symlinks of packages")
 
     (opts, argsleft) = parser.parse_args()
     if len(argsleft) > 1 and not opts.split: