[Yum-devel] [PATCH] Preserve "reason=dep" across updates and add it for dep. installs.

Tim Lauridsen tim.lauridsen at googlemail.com
Wed Oct 7 12:37:04 UTC 2009


On 10/06/2009 11:15 PM, James Antill wrote:
> ---
>   yum/__init__.py |   21 ++++++++++++---------
>   yum/depsolve.py |    1 +
>   2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/yum/__init__.py b/yum/__init__.py
> index a5b4922..79383a5 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -2932,6 +2932,14 @@ class YumBase(depsolve.Depsolve):
>                   self.tsInfo.remove(txmbr.po.pkgtup)
>           return found
>
> +    def _add_up_txmbr(self, requiringPo, upkg, ipkg):
> +        txmbr = self.tsInfo.addUpdate(upkg, ipkg)
> +        if requiringPo:
> +            txmbr.setAsDep(requiringPo)
> +        if ('reason' in ipkg.yumdb_info and ipkg.yumdb_info.reason == 'dep'):
> +            txmbr.reason = 'dep'
> +        return txmbr
> +
>       def update(self, po=None, requiringPo=None, **kwargs):
>           """try to mark for update the item(s) specified.
>               po is a package object - if that is there, mark it for update,
> @@ -3097,9 +3105,7 @@ class YumBase(depsolve.Depsolve):
>                           self.tsInfo.addObsoleted(obsoletee, po)
>                           tx_return.append(txmbr)
>                   else:
> -                    txmbr = self.tsInfo.addUpdate(po, installed_pkg)
> -                    if requiringPo:
> -                        txmbr.setAsDep(requiringPo)
> +                    txmbr = self._add_up_txmbr(requiringPo, po, installed_pkg)
>                       tx_return.append(txmbr)
>
>           for available_pkg in availpkgs:
> @@ -3122,9 +3128,8 @@ class YumBase(depsolve.Depsolve):
>
>                   else:
>                       updated_pkg =  self.getInstalledPackageObject(updated)
> -                    txmbr = self.tsInfo.addUpdate(available_pkg, updated_pkg)
> -                    if requiringPo:
> -                        txmbr.setAsDep(requiringPo)
> +                    txmbr = self._add_up_txmbr(requiringPo,
> +                                               available_pkg, updated_pkg)
>                       tx_return.append(txmbr)
>
>               # check to see if the pkg we want to install is not _quite_ the newest
> @@ -3147,9 +3152,7 @@ class YumBase(depsolve.Depsolve):
>                       self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s'),
>                                               ipkg.pkgtup)
>                   elif ipkg.verLT(available_pkg):
> -                    txmbr = self.tsInfo.addUpdate(available_pkg, ipkg)
> -                    if requiringPo:
> -                        txmbr.setAsDep(requiringPo)
> +                    txmbr = self._add_up_txmbr(requiringPo, available_pkg, ipkg)
>                       tx_return.append(txmbr)
>
>           return tx_return
> diff --git a/yum/depsolve.py b/yum/depsolve.py
> index c5baacb..8bed47c 100644
> --- a/yum/depsolve.py
> +++ b/yum/depsolve.py
> @@ -584,6 +584,7 @@ class Depsolve(object):
>               # FIXME: Don't we want .install() here, so obsoletes get done?
>               txmbr = self.tsInfo.addInstall(best)
>               txmbr.setAsDep(po=requiringPo)
> +            txmbr.reason = "dep"
>               self._last_req = best
>
>               # if we had other packages with this name.arch that we found

Look fine to me

Tim


More information about the Yum-devel mailing list