[yum-commits] 6 commits - cli.py docs/yum.conf.5 rpmUtils/arch.py yumcommands.py yum/config.py yum/__init__.py yum/transactioninfo.py

James Antill james at osuosl.org
Fri Apr 27 13:10:53 UTC 2012


 cli.py                 |   12 ++++++++++++
 docs/yum.conf.5        |   27 ++++++++++++++++++++++++++-
 rpmUtils/arch.py       |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 yum/__init__.py        |   41 +++++++++++++++++++++++++++++++++++------
 yum/config.py          |    1 +
 yum/transactioninfo.py |   10 ++++++++++
 yumcommands.py         |    5 ++++-
 7 files changed, 137 insertions(+), 8 deletions(-)

New commits:
commit 24dde23643f98ed355fcf50fb09807e2b08ea620
Author: Phil Knirsch <pknirsch at redhat.com>
Date:   Fri Apr 27 09:09:15 2012 -0400

     Do arm arch detection in the same way rpm does it. Once we have the rpm API
    in place we can switch over to that easily.
    
     Minor cleanups by James Antill.

diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index 7d67907..2226dc5 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -3,6 +3,8 @@
 
 import os
 import rpm
+import ctypes
+import struct
 
 _ppc64_native_is_best = False
 
@@ -31,6 +33,7 @@ arches = {
     "ia32e": "x86_64",
     
     # ppc
+    "ppc64p7": "ppc64",
     "ppc64pseries": "ppc64",
     "ppc64iseries": "ppc64",    
     "ppc64": "ppc",
@@ -82,6 +85,13 @@ arches = {
     "ia64": "noarch",
     }
 
+#  Will contain information parsed from /proc/self/auxv via _parse_auxv().
+# Should move into rpm really.
+_aux_vector = {
+    "platform": "",
+    "hwcap": 0,
+    }
+
 def legitMultiArchesInSameLib(arch=None):
     # this is completely crackrock - if anyone has a better way I
     # am all ears
@@ -222,6 +232,32 @@ def _try_read_cpuinfo():
     except:
         return []
 
+def _parse_auxv():
+    """ Read /proc/self/auxv and parse it into global dict for easier access
+        later on, very similar to what rpm does. """
+    # In case we can't open and read /proc/self/auxv, just return
+    try:
+        data = open("/proc/self/auxv", "rb").read()
+    except:
+        return
+
+    # Define values from /usr/include/elf.h
+    AT_PLATFORM = 15
+    AT_HWCAP = 16
+    fmtlen = struct.calcsize("LL")
+    offset = 0
+    platform = ctypes.c_char_p()
+
+    # Parse the data and fill in _aux_vector dict
+    while offset <= len(data) - fmtlen:
+        at_type, at_val = struct.unpack_from("LL", data, offset)
+        if at_type == AT_PLATFORM:
+            platform.value = at_val
+            _aux_vector["platform"] = platform.value
+        if at_type == AT_HWCAP:
+            _aux_vector["hwcap"] = at_val
+        offset = offset + fmtlen
+
 def getCanonX86Arch(arch):
     # 
     if arch == "i586":
@@ -260,6 +296,17 @@ def getCanonPPCArch(arch):
         if line.find("machine") != -1:
             machine = line.split(':')[1]
             break
+
+    platform = _aux_vector["platform"]
+    if machine is None and not platform:
+        return arch
+
+    try:
+        if platform.startswith("power") and int(platform[5:]) >= 7:
+            return "ppc64p7"
+    except:
+        pass
+
     if machine is None:
         return arch
 
@@ -324,6 +371,8 @@ def getCanonArch(skipRpmPlatform = 0):
         
     arch = os.uname()[4]
 
+    _parse_auxv()
+
     if (len(arch) == 4 and arch[0] == "i" and arch[2:4] == "86"):
         return getCanonX86Arch(arch)
 
commit 8769b53d1f01c462c66528a74b931659e5577fc3
Merge: 31ed5a8 1e61961
Author: James Antill <james at and.org>
Date:   Fri Apr 20 15:12:45 2012 -0400

    Fix merge failures for end rpmdb versions in load-ts files.

diff --cc cli.py
index afa7447,c1dae95..a0d8886
mode 100755,100644..100755
--- a/cli.py
+++ b/cli.py
@@@ -536,11 -482,23 +536,23 @@@ class YumBaseCli(yum.YumBase, output.Yu
          else:
              self.reportDownloadSize(downloadpkgs, install_only)
          
+         cfr = self.tsInfo._check_future_rpmdbv
+         if (cfr is not None and
+             cfr[0] == self.tsInfo.state_counter and
+             self.tsInfo.futureRpmDBVersion() != cfr[1]):
+             msg = _("future rpmdb ver mismatched saved transaction version,")
+             if cfr[2]:
+                 msg += _(" ignoring, as requested.")
+                 self.logger.critical(_(msg))
+             else:
+                 msg += _(" aborting.")
+                 raise yum.Errors.YumBaseError(msg)
+ 
          # confirm with user
          if self._promptWanted():
 -            if not self.userconfirm():
 +            if self.conf.assumeno or not self.userconfirm():
                  self.verbose_logger.info(_('Exiting on user Command'))
 -                return 1
 +                return -1
  
          self.verbose_logger.log(yum.logginglevels.INFO_2,
              _('Downloading Packages:'))
diff --cc docs/yum.conf.5
index df172fa,0204fd8..9eff4c3
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@@ -647,26 -573,34 +647,51 @@@ See color_list_installed_older for poss
  When removing packages (by removal, update or obsoletion) go through each
  package's dependencies. If any of them are no longer required by any other 
  package then also mark them to be removed.
- Boolean (1, 0, True, False, yes,no) Defaults to False
+ Boolean (1, 0, True, False, yes, no) Defaults to False
  
  .IP
 +\fBupgrade_requirements_on_install \fR
 +When installing/reinstalling/upgrading packages go through each package's
 +installed dependencies and check for an update.
 +Boolean (1, 0, True, False, yes,no) Defaults to False
 +
 +.IP
 +\fBrecheck_installed_requires \fR
 +When upgrading a package do we recheck any requirements that existed in the old
 +package. Turning this on shouldn't do anything but slow yum depsolving down,
 +however using rpm --nodeps etc. can break the rpmdb and then this will help.
 +Boolean (1, 0, True, False, yes,no) Defaults to False
 +
 +.IP
 +\fBreset_nice \fR
 +If set to true then yum will try to reset the nice value to zero, before
 +running an rpm transaction. Defaults to True.
 +
+ \fBexit_on_lock\fR
+ Should the yum client exit immediately when something else has the lock.
+ Boolean (1, 0, True, False, yes, no) Defaults to False
+ 
+ .IP
+ \fBloadts_ignoremissing\fR
+ Should the load-ts command ignore packages that are missing. This includes
+ packages in the TS to be removed, which aren't installed, and packages in the
+ TS to be added, which aren't available.
+ Boolean (1, 0, True, False, yes, no) Defaults to False
+ 
+ .IP
+ \fBloadts_ignorerpm\fR
+ Should the load-ts command ignore the rpmdb version (yum version nogroups) or
+ abort if there is a mismatch between the TS file and the current machine.
+ Boolean (1, 0, True, False, yes, no) Defaults to False
+ 
+ .IP
+ \fBloadts_ignorenewrpm\fR
+ Should the load-ts command ignore the future rpmdb version or
+ abort if there is a mismatch between the TS file and what will happen on the
+ current machine.
+ Note that if loadts_ignorerpm is True, this option does nothing.
+ Boolean (1, 0, True, False, yes, no) Defaults to False
+ 
  
  .SH "[repository] OPTIONS"
  .LP 
diff --cc yum/__init__.py
index c9bc815,3d266e1..33d4d4c
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@@ -6003,13 -5034,11 +6003,17 @@@ class YumBase(depsolve.Depsolve)
          
          msg = "%s\n" % self.rpmdb.simpleVersion(main_only=True)[0]
          msg += "%s\n" % self.ts.getTsFlags()
 -        msg += "%s\n" % (len(self.repos.listEnabled()) + 1)
 -        for r in self.repos.listEnabled():
 -            msg += "%s:%s:%s\n" % (r.id, len(r.sack), r.repoXML.revision)
++
 +        if self.tsInfo._pkgSack is None: # Transactions have pkgSack?
-             msg += "0\n"
++            msg += "1\n"
 +        else:
-             msg += "%s\n" % len(self.repos.listEnabled())
++            msg += "%s\n" % (len(self.repos.listEnabled()) + 1)
 +            for r in self.repos.listEnabled():
 +                msg += "%s:%s:%s\n" % (r.id, len(r.sack), r.repoXML.revision)
 +
+         # Save what we think the future rpmdbv will be.
+         msg += "%s:%s\n" % ('installed', self.tsInfo.futureRpmDBVersion())
++
          msg += "%s\n" % len(self.tsInfo.getMembers())
          for txmbr in self.tsInfo.getMembers():
              msg += txmbr._dump()
@@@ -6024,18 -5053,9 +6028,20 @@@
                  raise Errors.YumBaseError(_("Could not save transaction file %s: %s") % (filename, str(e)))
  
          
-     def load_ts(self, filename, ignorerpm=None, ignoremissing=None):
+     def load_ts(self, filename, ignorerpm=None, ignoremissing=None,
+                 ignorenewrpm=None):
 -        """loads a transaction from a .yumtx file"""
 +        """Load a transaction from a .yumtx file.
 +
 +        :param filename: the name of the file to load the transaction
 +           from
-         :param ignorerpm: whether to ignore messages from rpm
++        :param ignorerpm: whether to ignore starting rpmdb version mismatch.
 +        :param ignoremissing: whether to ignore that there may be
 +           transaction members missing
++        :param ignorenewrpm: whether to ignore ending rpmdb version mismatch.
 +        :return: the members of the loaded transaction
 +        :raises: :class:`yum.Errors.YumBaseError` if there are problems
 +           loading the transaction
 +        """
          # check rpmversion - if not match throw a fit
          # check repoversions  (and repos)- if not match throw a fit
          # load each txmbr - if pkgs being updated don't exist, bail w/error
diff --cc yum/config.py
index 6446a6d,11b42f1..ee5876b
--- a/yum/config.py
+++ b/yum/config.py
@@@ -851,19 -744,9 +851,20 @@@ class YumConf(StartupConf)
      
      loadts_ignoremissing = BoolOption(False)
      loadts_ignorerpm = BoolOption(False)
+     loadts_ignorenewrpm = BoolOption(False)
      
      clean_requirements_on_remove = BoolOption(False)
 +
 +    upgrade_requirements_on_install = BoolOption(False)
 +
 +    history_list_view = SelectionOption('single-user-commands',
 +                                        ('single-user-commands', 'users',
 +                                         'commands'),
 +                                     mapper={'cmds'          : 'commands',
 +                                             'default' :'single-user-commands'})
 +
 +    recheck_installed_requires = BoolOption(False)
 +
      _reposlist = []
  
      def dump(self):
diff --cc yum/transactioninfo.py
index 97de8f0,7dd0036..b584338
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@@ -105,7 -104,9 +105,10 @@@ class TransactionData
          self.depupdated = []
          self.reinstalled = []
          self.downgraded = []
 +        self.failed = []
+ 
+         self._future_rpmdbv = None
+         self._check_future_rpmdbv = None
          
      def __len__(self):
          return len(self.pkgdict)
commit 31ed5a8726cd55619bcdab2af794fd683b128b7e
Author: James Antill <james at and.org>
Date:   Mon Apr 9 14:22:11 2012 -0400

    Don't traceback in hisotry stats, when we have no transactions. BZ 802661

diff --git a/yumcommands.py b/yumcommands.py
index 477d16a..f31d495 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -2593,9 +2593,12 @@ class HistoryCommand(YumCommand):
         print "File        :", base.history._db_file
         num = os.stat(base.history._db_file).st_size
         print "Size        :", locale.format("%d", num, True)
+        trans_N = base.history.last()
+        if trans_N is None:
+            print _("Transactions:"), 0
+            return
         counts = base.history._pkg_stats()
         trans_1 = base.history.old("1")[0]
-        trans_N = base.history.last()
         print _("Transactions:"), trans_N.tid
         print _("Begin time  :"), time.ctime(trans_1.beg_timestamp)
         print _("End time    :"), time.ctime(trans_N.end_timestamp)
commit 1e61961c032473fe8f251714bd189889752f11a5
Author: James Antill <james at and.org>
Date:   Tue Mar 8 12:36:34 2011 -0500

    Add missing configuration option docs. exit_on_lock and loadts*.

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index a535b79..0204fd8 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -573,8 +573,33 @@ See color_list_installed_older for possible values.
 When removing packages (by removal, update or obsoletion) go through each
 package's dependencies. If any of them are no longer required by any other 
 package then also mark them to be removed.
-Boolean (1, 0, True, False, yes,no) Defaults to False
+Boolean (1, 0, True, False, yes, no) Defaults to False
 
+.IP
+\fBexit_on_lock\fR
+Should the yum client exit immediately when something else has the lock.
+Boolean (1, 0, True, False, yes, no) Defaults to False
+
+.IP
+\fBloadts_ignoremissing\fR
+Should the load-ts command ignore packages that are missing. This includes
+packages in the TS to be removed, which aren't installed, and packages in the
+TS to be added, which aren't available.
+Boolean (1, 0, True, False, yes, no) Defaults to False
+
+.IP
+\fBloadts_ignorerpm\fR
+Should the load-ts command ignore the rpmdb version (yum version nogroups) or
+abort if there is a mismatch between the TS file and the current machine.
+Boolean (1, 0, True, False, yes, no) Defaults to False
+
+.IP
+\fBloadts_ignorenewrpm\fR
+Should the load-ts command ignore the future rpmdb version or
+abort if there is a mismatch between the TS file and what will happen on the
+current machine.
+Note that if loadts_ignorerpm is True, this option does nothing.
+Boolean (1, 0, True, False, yes, no) Defaults to False
 
 
 .SH "[repository] OPTIONS"
commit 492651f4fc075815a0134989231073fcc680527f
Author: James Antill <james at and.org>
Date:   Tue Mar 8 12:24:37 2011 -0500

     Add the "future" rpmdb version to the ts file, and check it on load-ts
    so we can pretty much guarantee you have the same transaction happening.
    
     Adds a config. option loadts_ignorenewrpm.
    
     We save the new rpmdb version via. the special repo. "installed" so that
    the new ts files can be loaded by old yum versions. This is a hack,
    AFAIK there is no other way.
    
     Currently all the "API" for this is hidden, because it's only run from
    the cli parts ... and only activated via. load-ts ... may want to make
    this more generic.

diff --git a/cli.py b/cli.py
index a4c7c79..c1dae95 100644
--- a/cli.py
+++ b/cli.py
@@ -482,6 +482,18 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         else:
             self.reportDownloadSize(downloadpkgs, install_only)
         
+        cfr = self.tsInfo._check_future_rpmdbv
+        if (cfr is not None and
+            cfr[0] == self.tsInfo.state_counter and
+            self.tsInfo.futureRpmDBVersion() != cfr[1]):
+            msg = _("future rpmdb ver mismatched saved transaction version,")
+            if cfr[2]:
+                msg += _(" ignoring, as requested.")
+                self.logger.critical(_(msg))
+            else:
+                msg += _(" aborting.")
+                raise yum.Errors.YumBaseError(msg)
+
         # confirm with user
         if self._promptWanted():
             if not self.userconfirm():
diff --git a/yum/__init__.py b/yum/__init__.py
index 5c44245..3d266e1 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -5034,9 +5034,11 @@ class YumBase(depsolve.Depsolve):
         
         msg = "%s\n" % self.rpmdb.simpleVersion(main_only=True)[0]
         msg += "%s\n" % self.ts.getTsFlags()
-        msg += "%s\n" % len(self.repos.listEnabled())
+        msg += "%s\n" % (len(self.repos.listEnabled()) + 1)
         for r in self.repos.listEnabled():
             msg += "%s:%s:%s\n" % (r.id, len(r.sack), r.repoXML.revision)
+        # Save what we think the future rpmdbv will be.
+        msg += "%s:%s\n" % ('installed', self.tsInfo.futureRpmDBVersion())
         msg += "%s\n" % len(self.tsInfo.getMembers())
         for txmbr in self.tsInfo.getMembers():
             msg += txmbr._dump()
@@ -5051,7 +5053,8 @@ class YumBase(depsolve.Depsolve):
                 raise Errors.YumBaseError(_("Could not save transaction file %s: %s") % (filename, str(e)))
 
         
-    def load_ts(self, filename, ignorerpm=None, ignoremissing=None):
+    def load_ts(self, filename, ignorerpm=None, ignoremissing=None,
+                ignorenewrpm=None):
         """loads a transaction from a .yumtx file"""
         # check rpmversion - if not match throw a fit
         # check repoversions  (and repos)- if not match throw a fit
@@ -5067,21 +5070,30 @@ class YumBase(depsolve.Depsolve):
 
         if ignorerpm is None:
             ignorerpm = self.conf.loadts_ignorerpm
+        if ignorenewrpm is None:
+            ignorenewrpm = self.conf.loadts_ignorenewrpm
         if ignoremissing is None:
             ignoremissing = self.conf.loadts_ignoremissing
+
+        #  Inherit this, because for the ending version to match the starting
+        # version must match.
+        if ignorerpm:
+            ignorenewrpm = True
             
         # data format
         # 0 == rpmdb version
         # 1 == tsflags
         # 2 == numrepos
         # 3:numrepos = repos
+        #  -- post 3.2.29 update: 'installed' repo. added with the values as the
+        #                         new rpmdb version.
         # 3+numrepos = num pkgs
         # 3+numrepos+1 -> EOF= txmembers
         
         # rpm db ver
         rpmv = data[0].strip()
         if rpmv != str(self.rpmdb.simpleVersion(main_only=True)[0]):
-            msg = _("rpmdb ver mismatched saved transaction version, ")
+            msg = _("rpmdb ver mismatched saved transaction version,")
             if ignorerpm:
                 msg += _(" ignoring, as requested.")
                 self.logger.critical(_(msg))
@@ -5104,8 +5116,17 @@ class YumBase(depsolve.Depsolve):
         numrepos = int(data[2].strip())
         repos = []
         rindex=3+numrepos
+        future_rpmdbv = None
         for r in data[3:rindex]:
-            repos.append(r.strip().split(':'))
+            repo = r.strip().split(':')
+
+            if repo and repo[0] == 'installed':
+                #  This is an update hack to list the _future_ rpmdb version.
+                # Doing it this way allows older yum's to load newer ts files.
+                future_rpmdbv = "%s:%s" % (repo[1], repo[2])
+                continue
+
+            repos.append(repo)
 
         # pkgs/txmbrs
         numpkgs = int(data[rindex].strip())
@@ -5224,6 +5245,11 @@ class YumBase(depsolve.Depsolve):
                 msg += _(" aborting.")
                 raise Errors.YumBaseError(msg)
             
+        if len(self.tsInfo) != pkgcount:
+            future_rpmdbv = None
+        if future_rpmdbv is not None:
+            self.tsInfo._check_future_rpmdbv = (pkgcount, future_rpmdbv,
+                                                ignorenewrpm)
         return self.tsInfo.getMembers()
 
     def _remove_old_deps(self):
diff --git a/yum/config.py b/yum/config.py
index 9c2db93..11b42f1 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -744,6 +744,7 @@ class YumConf(StartupConf):
     
     loadts_ignoremissing = BoolOption(False)
     loadts_ignorerpm = BoolOption(False)
+    loadts_ignorenewrpm = BoolOption(False)
     
     clean_requirements_on_remove = BoolOption(False)
     _reposlist = []
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 55643ce..7dd0036 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -106,6 +106,7 @@ class TransactionData:
         self.downgraded = []
 
         self._future_rpmdbv = None
+        self._check_future_rpmdbv = None
         
     def __len__(self):
         return len(self.pkgdict)
commit 664580a90bec5f2e256238cf186c6bcf86529de0
Author: James Antill <james at and.org>
Date:   Tue Mar 8 11:49:58 2011 -0500

    Add caching to tsInfo.futureRpmDBVersion().

diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index b0c7ddd..55643ce 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -104,6 +104,8 @@ class TransactionData:
         self.depupdated = []
         self.reinstalled = []
         self.downgraded = []
+
+        self._future_rpmdbv = None
         
     def __len__(self):
         return len(self.pkgdict)
@@ -618,6 +620,12 @@ class TransactionData:
         """ Return a simple version for the future rpmdb. Works like
             rpmdb.simpleVersion(main_only=True)[0], but for the state the rpmdb
             will be in after the transaction. """
+
+        if self._future_rpmdbv is not None:
+            sc, ret = self._future_rpmdbv
+            if sc == self.state_counter:
+                return ret
+
         pkgs = self.rpmdb.returnPackages()
         _reinstalled_pkgtups = {}
         for txmbr in self.getMembersWithState(None, TS_INSTALL_STATES):
@@ -657,6 +665,7 @@ class TransactionData:
 
         self.rpmdb.transactionCachePackageChecksums(pkg_checksum_tups)
 
+        self._future_rpmdbv = (self.state_counter, main)
         return main
     
     def findObsoletedByThisMember(self, txmbr):


More information about the Yum-commits mailing list