[yum-commits] Branch 'yum-3_2_X' - 4 commits - rpmUtils/arch.py yum/__init__.py yum/misc.py yum/rpmtrans.py

James Antill james at osuosl.org
Tue May 31 14:15:06 UTC 2011


 rpmUtils/arch.py |    2 +
 yum/__init__.py  |   14 ++++-----
 yum/misc.py      |    6 +++-
 yum/rpmtrans.py  |   79 ++++++++++++++++++++++++++++++++++++++-----------------
 4 files changed, 69 insertions(+), 32 deletions(-)

New commits:
commit 7738cfbffe3066fca4a6c8a514f9b56f09ab2eb3
Author: James Antill <james at and.org>
Date:   Fri May 27 16:24:34 2011 -0400

    Work around RHEL-5 python broken getlocale() call. BZ 708292

diff --git a/yum/misc.py b/yum/misc.py
index b7e8534..2f6ddfe 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -998,7 +998,11 @@ def setup_locale(override_codecs=True, override_time=False):
 
 
 def get_my_lang_code():
-    mylang = locale.getlocale(locale.LC_MESSAGES)
+    try:
+        mylang = locale.getlocale(locale.LC_MESSAGES)
+    except ValueError, e:
+        # This is RHEL-5 python crack, Eg. en_IN can't be parsed properly
+        mylang = (None, None)
     if mylang == (None, None): # odd :)
         mylang = 'C'
     else:
commit 4d587cf37c8976e6f1b2f3b33b181e52190e8eb7
Author: Dennis Gilmore <dennis at ausil.us>
Date:   Thu May 26 15:36:32 2011 -0500

    we need to set the basearch on arm hardware to arm.

diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index 72cba60..6082005 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -359,6 +359,8 @@ def getBaseArch(myarch=None):
         return "sparc"
     elif myarch.startswith("ppc64"):
         return "ppc"
+    elif myarch.startswith("arm"):
+        return "arm"
         
     if isMultiLibArch(arch=myarch):
         if myarch in multilibArches:
commit 2e00059aa4057da49f2862fe3eab4d2f887964cd
Author: James Antill <james at and.org>
Date:   Thu May 26 11:19:36 2011 -0400

    Do ts_done create at the same time as ts_all, so it's consistent. BZ 707668.

diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index 08bf99d..6687080 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -272,21 +272,58 @@ class RPMTransaction:
         else:
             return (None, None)
 
+    def _fn_rm_installroot(self, filename):
+        """ Remove the installroot from the filename. """
+        # to handle us being inside a chroot at this point
+        # we hand back the right path to those 'outside' of the chroot() calls
+        # but we're using the right path inside.
+        if self.base.conf.installroot == '/':
+            return filename
+
+        return filename.replace(os.path.normpath(self.base.conf.installroot),'')
+
+    def ts_done_open(self):
+        """ Open the transaction done file, must be started outside the
+            chroot. """
+
+        if self.test: return False
+
+        if hasattr(self, '_ts_done'):
+            return True
+
+        self.ts_done_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir,
+                                                      self._ts_time)
+        ts_done_fn = self._fn_rm_installroot(self.ts_done_fn)
+
+        try:
+            self._ts_done = open(ts_done_fn, 'w')
+        except (IOError, OSError), e:
+            self.display.errorlog('could not open ts_done file: %s' % e)
+            self._ts_done = None
+            return False
+        self._fdSetCloseOnExec(self._ts_done.fileno())
+        return True
+
+    def ts_done_write(self, msg):
+        """ Write some data to the transaction done file. """
+        if self._ts_done is None:
+            return
+
+        try:
+            self._ts_done.write(msg)
+            self._ts_done.flush()
+        except (IOError, OSError), e:
+            #  Having incomplete transactions is probably worse than having
+            # nothing.
+            self.display.errorlog('could not write to ts_done file: %s' % e)
+            self._ts_done = None
+            misc.unlink_f(self.ts_done_fn)
+
     def ts_done(self, package, action):
         """writes out the portions of the transaction which have completed"""
         
-        if self.test: return
+        if not self.ts_done_open(): return
     
-        if not hasattr(self, '_ts_done'):
-            self.ts_done_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time)
-            
-            try:
-                self._ts_done = open(self.ts_done_fn, 'w')
-            except (IOError, OSError), e:
-                self.display.errorlog('could not open ts_done file: %s' % e)
-                return
-            self._fdSetCloseOnExec(self._ts_done.fileno())
-        
         # walk back through self._te_tuples
         # make sure the package and the action make some kind of sense
         # write it out and pop(0) from the list
@@ -322,14 +359,7 @@ class RPMTransaction:
         # hope springs eternal that this isn't wrong
         msg = '%s %s:%s-%s-%s.%s\n' % (t,e,n,v,r,a)
 
-        try:
-            self._ts_done.write(msg)
-            self._ts_done.flush()
-        except (IOError, OSError), e:
-            #  Having incomplete transactions is probably worse than having
-            # nothing.
-            del self._ts_done
-            misc.unlink_f(self.ts_done_fn)
+        self.ts_done_write(msg)
         self._te_tuples.pop(0)
     
     def ts_all(self):
@@ -361,17 +391,15 @@ class RPMTransaction:
         self._ts_time = time.strftime('%Y-%m-%d.%H:%M.%S')
         tsfn = '%s/transaction-all.%s' % (self.base.conf.persistdir, self._ts_time)
         self.ts_all_fn = tsfn
-        # to handle us being inside a chroot at this point
-        # we hand back the right path to those 'outside' of the chroot() calls
-        # but we're using the right path inside.
-        if self.base.conf.installroot != '/':
-            tsfn = tsfn.replace(os.path.normpath(self.base.conf.installroot),'')
+        tsfn = self._fn_rm_installroot(tsfn)
+
         try:
             if not os.path.exists(os.path.dirname(tsfn)):
                 os.makedirs(os.path.dirname(tsfn)) # make the dir,
             fo = open(tsfn, 'w')
         except (IOError, OSError), e:
             self.display.errorlog('could not open ts_all file: %s' % e)
+            self._ts_done = None
             return
 
         try:
@@ -383,7 +411,9 @@ class RPMTransaction:
         except (IOError, OSError), e:
             #  Having incomplete transactions is probably worse than having
             # nothing.
+            self.display.errorlog('could not write to ts_all file: %s' % e)
             misc.unlink_f(tsfn)
+            self._ts_done = None
 
     def callback( self, what, bytes, total, h, user ):
         if what == rpm.RPMCALLBACK_TRANS_START:
@@ -424,6 +454,7 @@ class RPMTransaction:
         if self.test: return
         self.trans_running = True
         self.ts_all() # write out what transaction will do
+        self.ts_done_open()
 
     def _transProgress(self, bytes, total, h):
         pass
commit 1dc6cf253df2c1f3f5a9beaf6be97b234edf4a3d
Author: Ville-Pekka Vainio <vpivaini at cs.helsinki.fi>
Date:   Thu May 26 17:38:49 2011 +0300

    Fix unicode problems with grpid
    
    Running yum groupremove with a group name which does not exist and
    includes unicode characters raises a UnicodeDecodeError.
    
    Pass grpid to to_unicode before printing it to avoid errors like this.

diff --git a/yum/__init__.py b/yum/__init__.py
index 61c71cf..587ee69 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2782,7 +2782,7 @@ class YumBase(depsolve.Depsolve):
         
         thesegroups = self.comps.return_groups(grpid)
         if not thesegroups:
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
 
         for thisgroup in thesegroups:
             thisgroup.toremove = True
@@ -2801,7 +2801,7 @@ class YumBase(depsolve.Depsolve):
 
         thesegroups = self.comps.return_groups(grpid)
         if not thesegroups:
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
 
         for thisgroup in thesegroups:
             thisgroup.toremove = False
@@ -2832,13 +2832,13 @@ class YumBase(depsolve.Depsolve):
         """
 
         if not self.comps.has_group(grpid):
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
         
         txmbrs_used = []
         thesegroups = self.comps.return_groups(grpid)
      
         if not thesegroups:
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
 
         package_types = self.conf.group_package_types
         if group_package_types:
@@ -2927,11 +2927,11 @@ class YumBase(depsolve.Depsolve):
             in the group(s) are force removed from the transaction. """
         
         if not self.comps.has_group(grpid):
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
             
         thesegroups = self.comps.return_groups(grpid)
         if not thesegroups:
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
         
         for thisgroup in thesegroups:
             thisgroup.selected = False
@@ -3311,7 +3311,7 @@ class YumBase(depsolve.Depsolve):
 
         thesegroups = self.comps.return_groups(grpid)
         if not thesegroups:
-            raise Errors.GroupsError, _("No Group named %s exists") % grpid
+            raise Errors.GroupsError, _("No Group named %s exists") % to_unicode(grpid)
         pkgnames = set()
         for thisgroup in thesegroups:
             pkgnames.update(thisgroup.packages)


More information about the Yum-commits mailing list