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

James Antill james at fedoraproject.org
Fri Aug 2 14:54:42 UTC 2013


 Why do you want to add this?


On Fri, 2013-08-02 at 03:56 -0700, Yuri wrote:
> Updated patch:
> 
> ==begin patch==
> 
> --- cli.py	2013-07-31 16:50:21.000000000 -0700
> +++ cli.py	2013-08-01 15:05:42.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)

 Why are all the indents off, are you using tabs instead of spaces ...
don't do that.

> --- rpmUtils/transaction.py	2013-07-31 16:50:21.000000000 -0700
> +++ rpmUtils/transaction.py	2013-08-01 15:04:31.000000000 -0700
> @@ -105,7 +105,7 @@
>   #        curfilter = self.ts.setProbFilter(0)
>   #        self.ts.setProbFilter(cutfilter | filt)
>           
> -    def test(self, cb, conf={}):
> +    def test(self, cb, yum_conf, conf={}):

 You can't add parameters in the middle of an existing API like this,
and/or require them.

> --- yum/misc.py	2013-07-31 16:50:21.000000000 -0700
> +++ yum/misc.py	2013-08-01 14:22:05.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);

 The API name is pretty bad, no need for import in there. Not even sure
it's worth having a function.
 misc. seems like the wrong place for it too, I'd guess just putting
them in rpmUtils.transaction would be fine.

 Prefixing them all with "RPMPROB" is ugly and unnecessary, dito. using
caps. At least some of the above are a _really_ bad idea, like
requires/conflicts. They aren't sticky, and will break yum at some
future point. Also oldpackage is already used "well" via. downgrade, and
that might be a better option for some of the other flags if you want
one/some of them specifically.

 If you do continue to use a function, returning -1 on error seems like
a bad idea ... as that'll turn on all the options if the caller uses the
return value.

> +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

 Raising errors like this is something we generally don't do, see Eg.
how we process the tsflags configuration.

> --- yum/transactioninfo.py	2013-07-31 16:50:21.000000000 -0700
> +++ yum/transactioninfo.py	2013-08-01 15:07:17.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):

 Dito. you can't just add a new parameter without a default, or all old
callers will break.



More information about the Yum-devel mailing list