[createrepo] latest head fix the worker exit issue

Seth Vidal skvidal at fedoraproject.org
Thu Jan 27 19:07:47 UTC 2011


commit c000a5abda0a2f9f4f75c038e530f18ebab604a7
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Jan 27 14:07:38 2011 -0500

    latest head fix the worker exit issue

 createrepo-head.patch |  152 ++++++++++---------------------------------------
 createrepo.spec       |    7 ++-
 2 files changed, 37 insertions(+), 122 deletions(-)
---
diff --git a/createrepo-head.patch b/createrepo-head.patch
index 4ee5f7a..4673323 100644
--- a/createrepo-head.patch
+++ b/createrepo-head.patch
@@ -1,125 +1,35 @@
-diff --git a/createrepo.spec b/createrepo.spec
-index 0d4bbd8..57a0196 100644
---- a/createrepo.spec
-+++ b/createrepo.spec
-@@ -11,7 +11,7 @@ URL: http://createrepo.baseurl.org/
- BuildRoot: %{_tmppath}/%{name}-%{version}root
- BuildArchitectures: noarch
- Requires: python >= 2.1, rpm-python, rpm >= 0:4.1.1, libxml2-python
--Requires: yum-metadata-parser, yum >= 3.2.23
-+Requires: yum-metadata-parser, yum >= 3.2.23, python-deltarpm
- 
- %description
- This utility will generate a common metadata repository from a directory of
 diff --git a/createrepo/__init__.py b/createrepo/__init__.py
-index 4601a15..0ffe6cb 100644
+index 8f2538e..07abc27 100644
 --- a/createrepo/__init__.py
 +++ b/createrepo/__init__.py
-@@ -298,8 +298,8 @@ class MetaDataGenerator:
-                     self.callback.errorlog(_('cannot get to file: %s') % fn)
-                 if os.path.getctime(fn) > self.conf.mdtimestamp:
-                     return False
--                else:
--                    return True
-+            
-+            return True
-                 
-         return False
- 
-@@ -543,6 +543,17 @@ class MetaDataGenerator:
-                                       (othernode, self.otherfile)):
-                     if node is None:
-                         break
-+
-+                    if self.conf.baseurl:
-+                        anode = node.children
-+                        while anode is not None:
-+                            if anode.type != "element":
-+                                anode = anode.next
-+                                continue
-+                            if anode.name == "location":
-+                                anode.setProp('xml:base', self.conf.baseurl)
-+                            anode = anode.next
-+
-                     output = node.serialize('UTF-8', self.conf.pretty)
-                     if output:
-                         outfile.write(output)
-diff --git a/createrepo/deltarpms.py b/createrepo/deltarpms.py
-index 26a6715..d14d3fa 100644
---- a/createrepo/deltarpms.py
-+++ b/createrepo/deltarpms.py
-@@ -18,7 +18,7 @@
- import os.path
- import commands
- from yum import misc
--import gzip
-+import deltarpm
- from utils import MDError
- 
- class DeltaRPMPackage:
-@@ -44,17 +44,16 @@ class DeltaRPMPackage:
-         os.lseek(fd, 0, 0)
-         fo = os.fdopen(fd, 'rb')
-         self.csum = misc.checksum(self.csum_type, fo)
--        fo.seek(int(self.po.hdrend))
--        self._getOldInfo(fo)
-         del fo
-         del fd
-+        self._getDRPMInfo(os.path.join(basedir, filename))
+@@ -660,7 +660,12 @@ class MetaDataGenerator:
+                     if line:
+                         self.callback.errorlog('Worker %s: %s' % (num, line.rstrip()))
                      
-     def _stringToNEVR(self, string):
-         i = string.rfind("-", 0, string.rfind("-")-1)
-         name = string[:i]
-         (epoch, ver, rel) = self._stringToVersion(string[i+1:])
-         return (name, epoch, ver, rel)
--        
-+
-     def _getLength(self, in_data):
-         length = 0
-         for val in in_data:
-@@ -62,27 +61,12 @@ class DeltaRPMPackage:
-             length += ord(val)
-         return length
-         
--    def _getOldInfo(self, fo):
--        try:
--            compobj = gzip.GzipFile("", "rb", 9, fo)
--        except:
--            raise zlibError("Data not stored in gzip format")
--            
--        if compobj.read(4)[:3] != "DLT":
--            raise Exception("Not a deltarpm")
-+    def _getDRPMInfo(self, filename):
-+        d = deltarpm.readDeltaRPM(filename)
-+        self.oldnevrstring = d['old_nevr']
-+        self.oldnevr = self._stringToNEVR(d['old_nevr'])
-+        self.sequence = d['seq']
-         
--        nevr_length = self._getLength(compobj.read(4))
--        nevr = compobj.read(nevr_length).strip("\x00")
--        seq_length = self._getLength(compobj.read(4))
--        seq = compobj.read(seq_length)
--        hex_seq = ""
--        for char in seq:
--            hex_seq += str("%02x" % ord(char))
--        self.oldnevrstring = nevr
--        self.oldnevr = self._stringToNEVR(nevr)
--        self.sequence = hex_seq
--        compobj.close()
--            
-     def _stringToVersion(self, strng):
-         i = strng.find(':')
-         if i != -1:
-diff --git a/createrepo/readMetadata.py b/createrepo/readMetadata.py
-index 285e54d..6711d30 100644
---- a/createrepo/readMetadata.py
-+++ b/createrepo/readMetadata.py
-@@ -136,7 +136,7 @@ class MetadataIndex(object):
-                 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 int(st.st_mtime) != mtime:
-                 if self.opts.get('verbose'):
-                     print _("Modification time changed for %s") % filepath
-                 return
+-                
++            for (num, job) in worker_jobs.items():
++                if job.returncode != 0:
++                    msg = "Worker exited with non-zero value: %s. Fatal." % job.returncode
++                    self.callback.errorlog(msg)
++                    raise MDError, msg
++                    
+             if not self.conf.quiet:
+                 self.callback.log("Workers Finished")
+             # finished with workers
+diff --git a/worker.py b/worker.py
+index eb35ef7..591a922 100755
+--- a/worker.py
++++ b/worker.py
+@@ -83,8 +83,10 @@ def main(args):
+                                                         external_data=external_data)
+             pri.write(pkg.xml_dump_primary_metadata())
+             fl.write(pkg.xml_dump_filelists_metadata())
+-            other.write(pkg.xml_dump_other_metadata(clog_limit=
+-                                            globalopts.get('clog_limit', None)))
++            clog_limit=globalopts.get('clog_limit', None)
++            if clog_limit is not None:
++                 clog_limit = int(clog_limit)
++            other.write(pkg.xml_dump_other_metadata(clog_limit=clog_limit))
+         except yum.Errors.YumBaseError, e:
+             print >> sys.stderr, "Error: %s" % e
+             continue
diff --git a/createrepo.spec b/createrepo.spec
index 923d262..2cf4362 100644
--- a/createrepo.spec
+++ b/createrepo.spec
@@ -3,11 +3,12 @@
 Summary: Creates a common metadata repository
 Name: createrepo
 Version: 0.9.9
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2
 Group: System Environment/Base
 Source: %{name}-%{version}.tar.gz
 Patch0: ten-changelog-limit.patch
+Patch1: createrepo-head.patch
 URL: http://createrepo.baseurl.org/
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArchitectures: noarch
@@ -22,6 +23,7 @@ packages.
 %prep
 %setup -q
 %patch0 -p0
+%patch1 -p1
 
 %build
 
@@ -45,6 +47,9 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/createrepo
 
 %changelog
+* Thu Jan 27 2011 Seth Vidal <skvidal at fedoraproject.org> - 0.9.9-2
+- make sure when a worker exits with a non-zero returncode we exit, too.
+
 * Wed Jan 26 2011 Seth Vidal <skvidal at fedoraproject.org> - 0.9.9-1
 - 0.9.9
 - change yum requires to 3.2.29


More information about the scm-commits mailing list