[Yum-devel] [PATCH] Alternative specification of 'installonlypkgs'. BZ 748054
Zdeněk Pavlas
zpavlas at redhat.com
Tue Dec 13 07:07:03 UTC 2011
Include 'glob:/etc/yum/installonly.d/*.conf' in the default
installonlypkgs option so it's possible to extend the list
without copy-pasting the list of kernel packages.
Also, provide an optional syntax to specify the per-package
installonly_limit and honour it in _limit_installonly_pkgs.
---
docs/yum.conf.5 | 6 ++++--
yum/__init__.py | 8 ++++++--
yum/config.py | 20 ++++++++++++++++----
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index d6fe824..3cf33ae 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -164,10 +164,12 @@ an i686 package to update an i386 package. Default is `1'.
List of package provides that should only ever be installed, never updated.
Kernels in particular fall into this category. Defaults to kernel,
kernel-bigmem, kernel-enterprise, kernel-smp, kernel-modules, kernel-debug,
-kernel-unsupported, kernel-source, kernel-devel, kernel-PAE, kernel-PAE-debug.
+kernel-unsupported, kernel-source, kernel-devel, kernel-PAE, kernel-PAE-debug
+and glob:/etc/yum/installonly.d/*.conf.
Note that because these are provides, and not just package names, kernel-devel
-will also apply to kernel-debug-devel, etc.
+will also apply to kernel-debug-devel, etc. It's possible to append `:N' to
+the package name to override the global installonly_limit.
.IP
\fBinstallonly_limit \fR
diff --git a/yum/__init__.py b/yum/__init__.py
index 9163ad0..6248fa6 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -5427,12 +5427,16 @@ class YumBase(depsolve.Depsolve):
if not po_names.intersection(install_only_names):
continue
+ # use explicit install limits of this package
+ limit = filter(None, map(self.conf.installonlypkgs_limit.get, po_names))
+ limit = limit and max(limit) or self.conf.installonly_limit
+
installed = self.rpmdb.searchNevra(name=m.name)
installed = _sort_and_filter_installonly(installed)
- if len(installed) < self.conf.installonly_limit - 1:
+ if len(installed) < limit - 1:
continue # we're adding one
- numleft = len(installed) - self.conf.installonly_limit + 1
+ numleft = len(installed) - limit + 1
for po in installed:
if (po.version, po.release) == (cur_kernel_v, cur_kernel_r):
# don't remove running
diff --git a/yum/config.py b/yum/config.py
index 6c09ee9..5ed0a98 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -739,10 +739,13 @@ class YumConf(StartupConf):
proxy_password = Option()
username = Option()
password = Option()
- installonlypkgs = ListOption(['kernel', 'kernel-bigmem',
- 'kernel-enterprise','kernel-smp', 'kernel-modules', 'kernel-debug',
- 'kernel-unsupported', 'kernel-source', 'kernel-devel', 'kernel-PAE',
- 'kernel-PAE-debug'])
+ installonlypkgs = ListOption('''
+ kernel kernel-bigmem kernel-enterprise kernel-smp kernel-modules
+ kernel-debug kernel-unsupported kernel-source kernel-devel
+ kernel-PAE kernel-PAE-debug
+ glob:/etc/yum/installonly.d/*.conf
+ ''', parse_default = True)
+
# NOTE: If you set this to 2, then because it keeps the current kernel it
# means if you ever install an "old" kernel it'll get rid of the newest one
# so you probably want to use 3 as a minimum ... if you turn it on.
@@ -1064,6 +1067,15 @@ def readMainConfig(startupconf):
yumconf.debuglevel = startupconf.debuglevel
yumconf.errorlevel = startupconf.errorlevel
+ # parse 'installonlypkgs' entries
+ yumconf.installonlypkgs_limit = {}
+ def parse(pkg):
+ if ':' in pkg:
+ pkg, limit = pkg.split(':', 1)
+ yumconf.installonlypkgs_limit[pkg] = int(limit)
+ return pkg
+ yumconf.installonlypkgs = map(parse, yumconf.installonlypkgs)
+
return yumconf
def readVersionGroupsConfig(configfile="/etc/yum/version-groups.conf"):
--
1.7.4.4
More information about the Yum-devel
mailing list