rpms/createrepo/devel almost-0.9.2.patch, NONE, 1.1 createrepo.spec, 1.34, 1.35

Seth Vidal (skvidal) fedora-extras-commits at redhat.com
Tue Jan 15 15:55:48 UTC 2008


Author: skvidal

Update of /cvs/extras/rpms/createrepo/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23966

Modified Files:
	createrepo.spec 
Added Files:
	almost-0.9.2.patch 
Log Message:
patch brings us up to createrepo HEAD - but not _quite_ 0.9.2



almost-0.9.2.patch:

--- NEW FILE almost-0.9.2.patch ---
diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index a26a596..0421e1e 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -1,3 +1,18 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Copyright 2007  Red Hat, Inc - written by seth vidal skvidal at fedoraproject.org
+
 import exceptions
 import os
 import sys
@@ -5,6 +20,7 @@ import libxml2
 import string
 import fnmatch
 import hashlib
+import time
 import rpm
 import yumbased
 from optparse import OptionContainer
@@ -27,6 +43,7 @@ from utils import _gzipOpen, bzipFile
 __version__ = '0.9.1'
 
 
+
 class MDError(exceptions.Exception):
     def __init__(self, value=None):
         exceptions.Exception.__init__(self)
@@ -51,6 +68,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$']
@@ -65,7 +83,8 @@ class MetaDataConfig(object):
         self.finaldir = 'repodata'
         self.olddir = '.olddata'
         self.mdtimestamp = 0
-
+        self.directory = None
+        self.directories = []
 
 class SimpleMDCallBack(object):
     def errorlog(self, thing):
@@ -79,6 +98,9 @@ class SimpleMDCallBack(object):
         sys.stdout.write("\r%d/%d - %s" % (current, total, item))
         sys.stdout.flush()
             
+#FIXME = make it so you pass in a dir to doPkgMetadata() and it
+# parses out basedir and directory for relative dir from there
+# it creates the .repodata directory in the output location, etc
         
 class MetaDataGenerator:
     def __init__(self, config_obj=None, callback=None):
@@ -95,7 +117,17 @@ class MetaDataGenerator:
         self.pkgcount = 0
         self.files = []
 
-    # module
+    def _setup_and_check_repo_dir(self, direc):
+        if os.path.isabs(direc):
+            self.conf.basedir = os.path.dirname(direc)
+            self.conf.directory = os.path.basename(direc)
+        else:
+            self.conf.basedir = os.path.realpath(self.conf.basedir)
+
+        if not self.conf.opts.outputdir:
+            self.conf.outputdir = os.path.join(self.conf.basedir, direc)
+
+
     def _os_path_walk(self, top, func, arg):
         """Directory tree walk with callback function.
          copy of os.path.walk, fixes the link/stating problem
@@ -181,6 +213,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)
@@ -354,6 +389,9 @@ class MetaDataGenerator:
             db_compressed_sums = {}
             
             if self.conf.database:
+                if self.conf.verbose:
+                    self.callback.log("Starting %s db creation: %s" % (ftype, time.ctime()))
+            
                 if ftype == 'primary':
                     rp.getPrimary(complete_path, csum)
                                 
@@ -400,7 +438,9 @@ class MetaDataGenerator:
                 unchecksum = data.newChild(None, 'open-checksum', db_csums[ftype])
                 unchecksum.newProp('type', sumtype)
                 database_version = data.newChild(None, 'database_version', dbversion)
-                
+                if self.conf.verbose:
+                    self.callback.log("Ending %s db creation: %s" % (ftype, time.ctime()))
+
                 
             data = reporoot.newChild(None, 'data', None)
             data.newProp('type', ftype)
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/createrepo/yumbased.py b/createrepo/yumbased.py
index db6226f..b1a638d 100644
--- a/createrepo/yumbased.py
+++ b/createrepo/yumbased.py
@@ -1,4 +1,19 @@
 #!/usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Copyright 2007  Red Hat, Inc - written by seth vidal skvidal at fedoraproject.org
+
 
 import os
 import sys
@@ -38,7 +53,14 @@ class CreateRepoPackage(YumLocalPackage):
         self._hdrstart = None
         self._hdrend = None
         self.xml_node = libxml2.newDoc("1.0")
-                
+        self.arch = self.isSrpm()
+        
+    def isSrpm(self):
+        if self.tagByName('sourcepackage') == 1 or not self.tagByName('sourcerpm'):
+            return 'src'
+        else:
+            return self.tagByName('arch')
+
         
     def _xml(self, item):
         item = utils.utf8String(item)
@@ -227,11 +249,11 @@ class CreateRepoPackage(YumLocalPackage):
             dirs = self._return_primary_dirs()
                 
         for fn in files:
-            msg += """    <file>%s</file>\n""" % utils.utf8String(fn)
+            msg += """    <file>%s</file>\n""" % self._xml(fn)
         for fn in dirs:
-            msg += """    <file type="dir">%s</file>\n""" % utils.utf8String(fn)
+            msg += """    <file type="dir">%s</file>\n""" % self._xml(fn)
         for fn in ghosts:
-            msg += """    <file type="ghost">%s</file>\n""" % utils.utf8String(fn)
+            msg += """    <file type="ghost">%s</file>\n""" % self._xml(fn)
         
         return msg
 
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:


Index: createrepo.spec
===================================================================
RCS file: /cvs/extras/rpms/createrepo/devel/createrepo.spec,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- createrepo.spec	10 Jan 2008 14:19:57 -0000	1.34
+++ createrepo.spec	15 Jan 2008 15:55:10 -0000	1.35
@@ -3,11 +3,11 @@
 Summary: Creates a common metadata repository
 Name: createrepo
 Version: 0.9.1
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2
 Group: System Environment/Base
 Source: %{name}-%{version}.tar.gz
-Patch: file-lists-escape.patch
+Patch: almost-0.9.2.patch
 URL: http://linux.duke.edu/projects/metadata/
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArchitectures: noarch
@@ -43,6 +43,9 @@
 %{python_sitelib}/createrepo
 
 %changelog
+* Tue Jan 15 2008 Seth Vidal <skvidal at fedoraproject.org> 0.9.1-3
+- more patches - almost 0.9.2 but not quite
+
 * Thu Jan 10 2008 Seth Vidal <skvidal at fedoraproject.org> 0.9.1-2
 - patch to fix bug until 0.9.2
 




More information about the fedora-extras-commits mailing list