def resolveVersions(packageList): """The packageDict is a dict of pkgtuple -> PO We return a dict of kernel version -> list of kmod POs where the list contains only one PO for each kmod name""" pdict = {} for po in packageList: kernel = getKernelReqs(po) if len(kernel) == 0: print "Bad kmod package '%s' does not require a kernel" % po continue elif len(kernel) == 1: kernel = kernel[0] else: print "Bad kmod package: Must require only one kernel" continue # Figure out the real name of this kmod name = [] for r in po.prco["provides"]: if r[0].endswith('-kmod'): name.append(r[0]) if len(name) == 0: # Yum bug name = fakeName(po) elif len(name) != 1: print "Non compliant kmod package: %s" % po continue po.kmodName = name[0] if kernel not in pdict: pdict[kernel] = [po] else: sameName = None for tempPo in pdict[kernel]: if po.name == tempPo.name: sameName = tempPo break if sameName and packages.comparePoEVR(sameName, po) < 0: pdict[kernel].remove(sameName) pdict[kernel].append(po) elif sameName is None: pdict[kernel].append(po) return pdict
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 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 runningKernel not in table: 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 prov in table: kmods = [po.kmodName for po in table[prov]] else: kmods = [] if set(kmods) != set(names): c.info(2, "Removing kernel %s from install set" % str(prov)) # XXX: This wants a pkgtuple which will probably change RSN c.getTsInfo().remove(kpo.pkgtup)
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 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 runningKernel not in table: 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 prov in table: kmods = [ po.kmodName for po in table[prov] ] else: kmods = [] if set(kmods) != set(names): c.info(2, "Removing kernel %s from install set" % str(prov)) # XXX: This wants a pkgtuple which will probably change RSN c.getTsInfo().remove(kpo.pkgtup)