[Yum-devel] [patch] Adding the ability to pass rpm ignoreset options from yum.conf to rpm

Yuri yuri at rawbw.com
Thu Aug 1 21:10:33 UTC 2013


Updated patch:

==begin patch==

--- cli.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ cli.py	2013-08-01 12:36:04.000000000 -0700
@@ -552,7 +552,7 @@
          self.ts.clean() # release memory not needed beyond this point
          
          testcb = RPMTransaction(self, test=True)
-        tserrors = self.ts.test(testcb)
+        tserrors = self.ts.test(testcb, self.conf)
          del testcb
  
          if len(tserrors) > 0:
--- docs/yum.conf.5.orig	2013-07-31 16:50:21.000000000 -0700
+++ docs/yum.conf.5	2013-08-01 12:14:12.000000000 -0700
@@ -62,6 +62,13 @@
  options are: 'critical', 'emergency', 'error', 'warn' and 'debug'.
  
  .IP
+\fBrpmignoreset\fR
+The default set of rpm ignore options. Yum may add some additional
+options for particular rpm operations. Empty set is the default, other
+options include 'RPMPROB_BADARCH', 'RPMPROB_BADOS',
+'RPMPROB_PKG_INSTALLED', 'RPMPROB_DISKSPACE'.
+
+.IP
  \fBprotected_packages\fR
  This is a list of packages that yum should never completely remove. They are
  protected via. Obsoletes as well as user/plugin removals.
--- rpmUtils/transaction.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ rpmUtils/transaction.py	2013-08-01 12:37:11.000000000 -0700
@@ -13,6 +13,7 @@
  
  import rpm
  import miscutils
+import misc
  
  read_ts = None
  ts = None
@@ -105,7 +106,7 @@
  #        curfilter = self.ts.setProbFilter(0)
  #        self.ts.setProbFilter(cutfilter | filt)
          
-    def test(self, cb, conf={}):
+    def test(self, cb, conf):
          """tests the ts we've setup, takes a callback function and a conf dict
             for flags and what not"""
      
@@ -114,7 +115,7 @@
          # FIXME GARBAGE - remove once this is reimplemented elsehwere
          # KEEPING FOR API COMPLIANCE ONLY
          if conf.get('diskspacecheck') == 0:
-            self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
+            self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE|misc.importRpmIgnoreSet(conf.rpmignoreset))
          tserrors = self.ts.run(cb.callback, '')
          self.ts.setFlags(origflags)
      
--- yum/__init__.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ yum/__init__.py	2013-08-01 11:56:22.000000000 -0700
@@ -222,7 +222,7 @@
  
      def _transactionDataFactory(self):
          """Factory method returning TransactionData object"""
-        return transactioninfo.TransactionData()
+        return transactioninfo.TransactionData(self._conf)
  
      def doGenericSetup(self, cache=0):
          """do a default setup for all the normal/necessary yum components,
--- yum/config.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ yum/config.py	2013-08-01 12:09:25.000000000 -0700
@@ -736,6 +736,8 @@
      history_record_packages = ListOption(['yum', 'rpm'])
  
      rpmverbosity = Option('info')
+    rpmignoreset = ListOption([])
+
  
      protected_packages = ListOption("yum, glob:/usr/local/etc/yum/protected.d/*.conf",
                                      parse_default=True)
--- yum/misc.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ yum/misc.py	2013-08-01 12:16:29.000000000 -0700
@@ -21,6 +21,7 @@
  import bz2
  import gzip
  import shutil
+import rpm
  _available_compression = ['gz', 'bz2']
  try:
      import lzma
@@ -1175,3 +1176,28 @@
      """ Lazily load/run: cElementTree.parse """
      _cElementTree_import()
      return __cached_cElementTree.parse(filename)
+
+def importRpmIgnoreOption(ignore_option):
+    return {
+        "RPMPROB_BADARCH":           rpm.RPMPROB_BADARCH,
+        "RPMPROB_BADOS":             rpm.RPMPROB_BADOS,
+        "RPMPROB_PKG_INSTALLED":     rpm.RPMPROB_PKG_INSTALLED,
+        "RPMPROB_BADRELOCATE":       rpm.RPMPROB_BADRELOCATE,
+        "RPMPROB_REQUIRES":          rpm.RPMPROB_REQUIRES,
+        "RPMPROB_CONFLICT":          rpm.RPMPROB_CONFLICT,
+        "RPMPROB_NEW_FILE_CONFLICT": rpm.RPMPROB_NEW_FILE_CONFLICT,
+        "RPMPROB_FILE_CONFLICT":     rpm.RPMPROB_FILE_CONFLICT,
+        "RPMPROB_OLDPACKAGE":        rpm.RPMPROB_OLDPACKAGE,
+        "RPMPROB_DISKSPACE":         rpm.RPMPROB_DISKSPACE,
+        "RPMPROB_DISKNODES":         rpm.RPMPROB_DISKNODES,
+        "RPMPROB_OBSOLETES":         rpm.RPMPROB_OBSOLETES,
+      }.get(ignore_option, -1);
+
+def importRpmIgnoreSet(ignoreset):
+    oset = []
+    for	opt_str in ignoreset:
+        opt_rpm = importRpmIgnoreOption(opt_str)
+        if opt_rpm==-1:
+            raise ValueError('Error parsing RPMPROB ignoreset option %s' % (opt_str))
+        oset.append(opt_rpm)
+    return oset
--- yum/transactioninfo.py.orig	2013-07-31 16:50:21.000000000 -0700
+++ yum/transactioninfo.py	2013-08-01 12:09:51.000000000 -0700
@@ -72,10 +72,10 @@
  
  class TransactionData:
      """Data Structure designed to hold information on a yum Transaction Set"""
-    def __init__(self):
+    def __init__(self,conf):
          self.flags = []
          self.vsflags = []
-        self.probFilterFlags = []
+        self.probFilterFlags = misc.importRpmIgnoreSet(conf.rpmignoreset)
          self.root = '/'
          self.pkgdict = {} # key = pkgtup, val = list of TransactionMember obj
          self._namedict = {} # name -> list of TransactionMember obj

==end patch==
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20130801/881c7b5c/attachment.html>


More information about the Yum-devel mailing list