[yum-cvs] yum/yum __init__.py, 1.334, 1.335 config.py, 1.121, 1.122 misc.py, 1.26, 1.27
Seth Vidal
skvidal at linux.duke.edu
Mon Jun 25 18:46:54 UTC 2007
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv15100/yum
Modified Files:
__init__.py config.py misc.py
Log Message:
merge functionality of 'installonlyn' plugin into yum core.
options installonly_limit in yum.conf. Setting to 0 disables it. Defaults to
0.
Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.334
retrieving revision 1.335
diff -u -r1.334 -r1.335
--- __init__.py 21 Jun 2007 18:01:20 -0000 1.334
+++ __init__.py 25 Jun 2007 18:46:52 -0000 1.335
@@ -526,7 +526,8 @@
self.plugins.run('preresolve')
(rescode, restring) = self.resolveDeps()
self.plugins.run('postresolve', rescode=rescode, restring=restring)
-
+ self._limit_installonly_pkgs()
+
if self.tsInfo.changed:
(rescode, restring) = self.resolveDeps()
@@ -2099,4 +2100,28 @@
if result != 0:
self.logger.info("Import of key(s) didn't help, wrong key(s)?")
raise Errors.YumBaseError, errmsg
-
+ def _limit_installonly_pkgs(self):
+ if self.conf.installonly_limit < 1 :
+ return
+
+ toremove = []
+ for instpkg in self.conf.installonlypkgs:
+ for m in self.tsInfo.getMembers():
+ if (m.name == instpkg or instpkg in m.po.provides_names) \
+ and m.ts_state in ('i', 'u'):
+ installed = self.rpmdb.searchNevra(name=m.name)
+ if len(installed) >= self.conf.installonly_limit - 1: # since we're adding one
+ numleft = len(installed) - self.conf.installonly_limit + 1
+ (curv, curr) = misc.get_running_kernel_version_release()
+
+ installed.sort(packages.comparePoEVR)
+ for po in installed:
+ if (po.version, po.release) == (curv, curr):
+ # don't remove running
+ continue
+ if numleft == 0:
+ break
+ toremove.append(po)
+ numleft -= 1
+
+ map(lambda x: self.tsInfo.addErase(x), toremove)
Index: config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- config.py 4 Jun 2007 07:05:35 -0000 1.121
+++ config.py 25 Jun 2007 18:46:52 -0000 1.122
@@ -489,7 +489,8 @@
proxy_password = Option()
installonlypkgs = ListOption(['kernel', 'kernel-bigmem',
'kernel-enterprise','kernel-smp', 'kernel-modules', 'kernel-debug',
- 'kernel-unsupported', 'kernel-source', 'kernel-devel'])
+ 'kernel-unsupported', 'kernel-source', 'kernel-devel'])
+ installonly_limit = IntOption(0)
kernelpkgnames = ListOption(['kernel','kernel-smp', 'kernel-enterprise',
'kernel-bigmem', 'kernel-BOOT'])
exactarchlist = ListOption(['kernel', 'kernel-smp', 'glibc',
Index: misc.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/misc.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- misc.py 14 Feb 2007 17:07:23 -0000 1.26
+++ misc.py 25 Jun 2007 18:46:52 -0000 1.27
@@ -354,4 +354,18 @@
destination.close()
s_fn.close()
+def get_running_kernel_version_release():
+ """This takes the output of uname and figures out the (version, release)
+ tuple for the running kernel."""
+ ver = os.uname()[2]
+ # FIXME this should probably get passed this list from somewhere in config
+ # possibly from the kernelpkgnames option
+ for s in ("bigmem", "enterprise", "smp", "hugemem", "PAE", "rt",
+ "guest", "hypervisor", "xen0", "xenU", "xen", "debug"):
+ if ver.endswith(s):
+ ver = ver.replace(s, "")
+ if ver.find("-") != -1:
+ (v, r) = ver.split("-", 1)
+ return (v, r)
+ return (None, None)
More information about the Yum-cvs-commits
mailing list