summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2008-03-26 10:35:48 -0400
committerJeremy Katz <katzj@redhat.com>2008-03-26 16:42:33 -0400
commitf36f680bcdd5209765106322c4c87881e60991e4 (patch)
tree1b350c3e980036675b43314d761824e42d6b1b5a
parentff43517869813269ff802aa031e75895bebc4375 (diff)
downloadanaconda-f36f680bcdd5209765106322c4c87881e60991e4.tar.gz
anaconda-f36f680bcdd5209765106322c4c87881e60991e4.tar.xz
anaconda-f36f680bcdd5209765106322c4c87881e60991e4.zip
Handle kernel variants a little better at install time too
Make our handling of kernel variants a little bit more flexible, allowing for the fact that uname -r might not match version-release exactly. This also makes it so we don't have a hard-coded list of kernel variants
-rw-r--r--livecd.py21
-rw-r--r--packages.py43
-rw-r--r--yuminstall.py24
3 files changed, 48 insertions, 40 deletions
diff --git a/livecd.py b/livecd.py
index f209558c5..922af8d28 100644
--- a/livecd.py
+++ b/livecd.py
@@ -339,26 +339,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
pass
def kernelVersionList(self, rootPath = "/"):
- versions = []
-
- # FIXME: we should understand more types of kernel versions and not
- # be tied to rpm...
- import rpm
- ts = rpm.TransactionSet(rootPath)
-
- # FIXME: and make sure that the rpmdb doesn't have stale locks :/
- for rpmfile in ["__db.000", "__db.001", "__db.002", "__db.003"]:
- try:
- os.unlink("%s/var/lib/rpm/%s" %(rootPath, rpmfile))
- except:
- log.debug("failed to unlink /var/lib/rpm/%s" %(rpmfile,))
-
- mi = ts.dbMatch('name', 'kernel')
- for h in mi:
- v = "%s-%s" %(h['version'], h['release'])
- versions.append( (v, h['arch'], "base") )
-
- return versions
+ return packages.rpmKernelVersionList(rootPath)
def doInitialSetup(self, anaconda):
pass
diff --git a/packages.py b/packages.py
index 36e268913..a6a8a1598 100644
--- a/packages.py
+++ b/packages.py
@@ -253,6 +253,49 @@ def setFileCons(anaconda):
return
+# FIXME: using rpm directly here is kind of lame, but in the yum backend
+# we don't want to use the metadata as the info we need would require
+# the filelists. and since we only ever call this after an install is
+# done, we can be guaranteed this will work. put here because it's also
+# used for livecd installs
+def rpmKernelVersionList(rootPath = "/"):
+ import rpm
+
+ def get_version(header):
+ for f in header['filenames']:
+ if f.startswith('/boot/vmlinuz-'):
+ return f[14:]
+ return ""
+
+ def get_tag(header):
+ if header['name'] == "kernel":
+ return "base"
+ elif header['name'].startswith("kernel-"):
+ return header['name'][7:]
+ return ""
+
+ versions = []
+
+ ts = rpm.TransactionSet(rootPath)
+
+ # FIXME: and make sure that the rpmdb doesn't have stale locks :/
+ for rpmfile in ["__db.000", "__db.001", "__db.002", "__db.003"]:
+ try:
+ os.unlink("%s/var/lib/rpm/%s" %(rootPath, rpmfile))
+ except:
+ log.debug("failed to unlink /var/lib/rpm/%s" %(rpmfile,))
+
+ mi = ts.dbMatch('provides', 'kernel')
+ for h in mi:
+ v = get_version(h)
+ tag = get_tag(h)
+ if v == "" or tag == "":
+ log.warning("Unable to determine kernel type/version for %s-%s-%s.%s" %(h['name'], h['version'], h['release'], h['arch']))
+ continue
+ versions.append( (v, h['arch'], tag) )
+
+ return versions
+
#Recreate initrd for use when driver disks add modules
def recreateInitrd (kernelTag, instRoot):
log.info("recreating initrd for %s" % (kernelTag,))
diff --git a/yuminstall.py b/yuminstall.py
index cb6d5f877..be7318313 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -45,6 +45,7 @@ from product import productName, productStamp
from sortedtransaction import SplitMediaTransactionData
from constants import *
from image import *
+import packages
from rhpl.translate import _
# specspo stuff
@@ -1552,26 +1553,9 @@ class YumBackend(AnacondaBackend):
w.pop()
def kernelVersionList(self, rootPath="/"):
- kernelVersions = []
-
- # nick is used to generate the lilo name
- for (ktag, nick) in [ ('kernel-smp', 'smp'),
- ('kernel-xen0', 'xen0'),
- ('kernel-xenU', 'xenU'),
- ('kernel-xen', 'xen'),
- ('kernel-PAE', 'pae') ]:
- tag = ktag.rsplit('-', 1)[1]
- for tsmbr in filter(lambda p: p.output_state in TS_INSTALL_STATES,
- self.ayum.tsInfo.matchNaevr(name=ktag)):
- version = ( tsmbr.version + '-' + tsmbr.release + tag)
- kernelVersions.append((version, tsmbr.arch, nick))
-
- for tsmbr in filter(lambda p: p.output_state in TS_INSTALL_STATES,
- self.ayum.tsInfo.matchNaevr(name='kernel')):
- version = ( tsmbr.version + '-' + tsmbr.release)
- kernelVersions.append((version, tsmbr.arch, 'base'))
-
- return kernelVersions
+ # FIXME: using rpm here is a little lame, but otherwise, we'd
+ # be pulling in filelists
+ return packages.rpmKernelVersionList(rootPath)
def __getGroupId(self, group):
"""Get the groupid for the given name (english or translated)."""