[yum-git] 2 commits - plugins/fedorakmod

Jack Neely slack at linux.duke.edu
Wed Mar 12 19:43:31 UTC 2008


 plugins/fedorakmod/README        |   30 +++++++++++++++++++++++-------
 plugins/fedorakmod/fedorakmod.py |   35 ++++++++++++++++++++++++++---------
 2 files changed, 49 insertions(+), 16 deletions(-)

New commits:
commit 62d2461798498faf056fe8e773403a46b55dd455
Merge: 162c50a... e76f4ed...
Author: Jack Neely <jjneely at ncsu.edu>
Date:   Wed Mar 12 15:43:21 2008 -0400

    Merge branch 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils

commit 162c50a51a579f948e54d7c54fdb5721a3c95486
Author: Jack Neely <jjneely at ncsu.edu>
Date:   Wed Mar 12 15:42:55 2008 -0400

    The pinKernels functionality fails pretty badly if it can't match your
    running kernel with a kernel package that it knows about.  In this case
    we grab the highest EVR kernel that we know about and attempt to mimic
    the kernel modules setup for that kernel.  This is handy in the %post
    of a kickstart as kernel pinning was always broken there or when some
    body erases your kernel.

diff --git a/plugins/fedorakmod/README b/plugins/fedorakmod/README
index 93efb7f..3e56214 100644
--- a/plugins/fedorakmod/README
+++ b/plugins/fedorakmod/README
@@ -1,14 +1,30 @@
+Fedorakmod - Yum Plugin for Kernel Modules
+==========================================
+
 Plugin for Yum to handle kernel modules as described by the Fedora Extras
-packaging standards.
+packaging standards.  (Now obsolete as Fedora no longer includes kernel
+module packages.)
+
+    http://fedoraproject.org/wiki/Obsolete/KernelModules
+
+We can install a kmod for all installed kernel versions/variants.  Set
+
+    installforallkernels = 1
 
-    http://www.fedoraproject.org/wiki/Extras/KernelModuleProposal
+in the conf file.  The default is to turn this feature on.  Set to 0
+to disable.
+
+We can delay instalation of a new kernel until the needed kmods are 
+available based on the kmods installed for the running kernel.  Set
+
+    pinkernels = 1
+
+in the conf file.  Any other value or a missing pinkernels line defaults
+to turn this functionality off.
 
 To Do
 =====
-   *) Remove kernel modules if matching kernel is removed.
-
-Folks, feel free to patch and add suggestions.  It will only help FE kernel
-module infrastructure develop faster.
+Hopefully nothing.
 
-Jack Neely <jjneely at ncsu.edu> -- 01/24/2007
+Jack Neely <jjneely at ncsu.edu> -- 03/12/2008
 
diff --git a/plugins/fedorakmod/fedorakmod.py b/plugins/fedorakmod/fedorakmod.py
index 0478aa8..b381448 100644
--- a/plugins/fedorakmod/fedorakmod.py
+++ b/plugins/fedorakmod/fedorakmod.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
-# fedorakmod.py - Fedora Extras Yum Kernel Module Support
-# Copyright 2006 - 2007 NC State University
+# fedorakmod.py - Fedora Kmod -- Yum Kernel Module Support
+# Copyright 2006 - 2008 NC State University
 # Written by Jack Neely <jjneely at ncsu.edu>
 #
 # SDG
@@ -44,9 +44,9 @@ def getRunningKernel():
     """This takes the output of uname and figures out the (version, release)
     tuple for the running kernel."""
     ver = os.uname()[2]
-    for s in kernelVariants:
-        if ver.endswith(s):
-            ver = ver.replace(s, "")
+    #for s in kernelVariants:
+    #    if ver.endswith(s):
+    #        ver = ver.replace(s, "")
     if ver.find("-") != -1:
         (v, r) = ver.split("-", 1)
         # XXX: Gah, this assumes epoch
@@ -183,21 +183,37 @@ def installKernelModules(c, newModules, installedModules):
                            (po, modpo))
                     break
 
-def pinKernels(c, newKernels, modules):
+def pinKernels(c, newKernels, installedKernels, modules):
     """If we are using kernel modules, do not upgrade/install a new 
        kernel until matching modules are available."""
     
     runningKernel = getRunningKernel()
     if runningKernel is None:
-        c.error(2, "Could not parsing running kernel version.")
+        c.error(2, "Could not parse running kernel version.")
         return
 
+    iKernels = [ getKernelProvides(p)[0] for p in installedKernels ]
+    if runningKernel not in iKernels:
+        # We have no knowledge of the running kernel -- its not installed
+        # perhaps this is the anaconda %post environment or somebody
+        # rpm -e'd the currently running kernel.  Choose a reasonable
+        # kernel to go with.  IE, the greatest EVR we see.
+        topkpo = None
+        for p in installedKernels:
+            if topkpo is None or packages.comparePoEVR(topkpo, p) < 0:
+                topkpo = p
+        runningKernel = getKernelProvides(topkpo)[0]
+        c.info(2, "Unknown running kernel.  Using %s instead." % \
+               str(runningKernel))
+
     table = resolveVersions(modules)
     if not table.has_key(runningKernel):
-        # The current kernel has no modules installed
+        c.info(2, "Trying to mimic %s which has no kernel modules installed" \
+               % str(runningKernel))
         return
         
     names = [ p.kmodName for p in table[runningKernel] ]
+    c.info(2, "kmods in %s: %s" % (str(runningKernel), str(names)))
     for kpo in newKernels:
         prov = getKernelProvides(kpo)[0]
         if table.has_key(prov):
@@ -285,7 +301,8 @@ def postresolve_hook(c):
 
     # Pin kernels
     if c.confInt('main', 'pinkernels', default=0) != 0:
-        pinKernels(c, newKernels, newModules + installedModules)
+        pinKernels(c, newKernels, installedKernels, 
+                   newModules + installedModules)
 
     # Upgrade/Install kernel modules
     installKernelModules(c, newModules, installedModules)



More information about the Yum-cvs-commits mailing list