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

[email protected] (Seth Vidal)
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 createrepo/__init__.py     |    4 +++
 createrepo/readMetadata.py |   38 +++++++++++++++++++------------------
 genpkgmetadata.py          |   46 +++++++++++++++++++++++++++++++--------------
 3 files changed, 56 insertions(+), 32 deletions(-)

New commits:
commit d9aae1d5ba72694ea97dc87e20e52561f0fbf6f8
Author: Seth Vidal <[email protected]>
Date:   Tue Jan 15 10:21:35 2008 -0500

    - add --skip-stat to skip the stat() call on updates - this is mostly
      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

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index f57e06b..4fc6c58 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -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)
diff --git a/createrepo/readMetadata.py b/createrepo/readMetadata.py
index 2b0713b..72ac845 100644
--- a/createrepo/readMetadata.py
+++ b/createrepo/readMetadata.py
@@ -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
diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index 22d7931..38cd151 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.