Add TreeBuilder.generate_module_data() for depmod/module-info

generate_module_data() runs depmod for each kernel module in the install
root, then generates the (anaconda-specific) module-info files.
This commit is contained in:
Will Woods 2011-06-27 14:46:47 -04:00
parent c7200e2aa8
commit 9ac7db8cb1
4 changed files with 35 additions and 8 deletions

View File

@ -76,7 +76,7 @@ arch/x86/kvm
%for kmodpath in removekmods: %for kmodpath in removekmods:
remove /modules/*/kernel/${kmodpath} remove /modules/*/kernel/${kmodpath}
%endfor %endfor
## FIXME: run depmod, generate module-info remove /modules/*/{build,source,*.map}
## Clean up systemd ## Clean up systemd
removefrom ConsoleKit /lib/systemd/* removefrom ConsoleKit /lib/systemd/*

View File

@ -96,10 +96,3 @@ symlink ../firmware lib/firmware
## create_depmod_conf() ## create_depmod_conf()
append etc/depmod.d/dd.conf "search updates built-in" append etc/depmod.d/dd.conf "search updates built-in"
## TODO: cleanup_kernel_modules(), then depmod
## TODO: depmod -a -F ${root}/boot/System.map-${kver} -b ${root} ${kver}
%for moddir in glob("modules/*"):
remove ${moddir}/*.map ${moddir}/build ${moddir}/source
## FIXME: generate magical anaconda 'module-info' files
%endfor

View File

@ -183,6 +183,7 @@ class Lorax(BaseLoraxClass):
logger.debug("product data: %s" % product) logger.debug("product data: %s" % product)
templatedir = self.conf.get("lorax", "sharedir") templatedir = self.conf.get("lorax", "sharedir")
# NOTE: rb.root = ybo.conf.installroot (== self.inroot)
rb = RuntimeBuilder(product=self.product, arch=self.arch, rb = RuntimeBuilder(product=self.product, arch=self.arch,
yum=ybo, templatedir=templatedir) yum=ybo, templatedir=templatedir)
@ -228,6 +229,9 @@ class Lorax(BaseLoraxClass):
inroot=installroot, outroot=self.outputdir, inroot=installroot, outroot=self.outputdir,
runtime=runtime, templatedir=templatedir) runtime=runtime, templatedir=templatedir)
logger.info("generating kernel module metadata")
treebuilder.generate_module_data()
logger.info("rebuilding initramfs images") logger.info("rebuilding initramfs images")
treebuilder.rebuild_initrds(add_args=["--xz"]) treebuilder.rebuild_initrds(add_args=["--xz"])

View File

@ -64,6 +64,28 @@ def findkernels(root="/", kdir="boot"):
return kernels return kernels
def generate_module_info(moddir, outfile=None):
logger.info("reading module data in %s", moddir)
def module_desc(mod):
return check_output(["modinfo", "-F", "description", mod]).strip()
def read_module_set(name):
return set(l.strip() for l in open(join(moddir,name)) if ".ko" in l)
modsets = {'scsi':read_module_set("modules.block"),
'eth':read_module_set("modules.networking")}
modinfo = list()
for root, dirs, files in os.walk(moddir):
for modtype, modset in modsets.items():
for mod in modset.intersection(files): # modules in this dir
(name, ext) = os.path.splitext(mod) # foo.ko -> (foo, .ko)
desc = module_desc(join(root,mod)) or "%s driver" % name
modinfo.append(dict(name=name, type=modtype, desc=desc))
out = open(outfile or join(moddir,"module-info"), "w")
logger.info("writing %s", out.name)
for mod in sorted(modinfo, key=lambda m: m.get('name')):
out.write('{name}\n\t{type}\n\t"{desc:.65}"\n'.format(**mod))
def brace_expand(s): def brace_expand(s):
if not ('{' in s and ',' in s and '}' in s): if not ('{' in s and ',' in s and '}' in s):
yield s yield s
@ -179,6 +201,14 @@ class TreeBuilder(object):
self.treeinfo_data = runner.results.treeinfo self.treeinfo_data = runner.results.treeinfo
self.implantisomd5() self.implantisomd5()
def generate_module_data(self):
inroot = self.vars.inroot
for kernel in self.kernels:
kver = kernel.version
ksyms = joinpaths(inroot, "boot/System.map-%s" % kver)
check_call(["depmod", "-a", "-F", ksyms, "-b", inroot, kver])
generate_module_info(joinpaths(inroot, "modules", kver))
def rebuild_initrds(self, add_args=[], backup=""): def rebuild_initrds(self, add_args=[], backup=""):
'''Rebuild all the initrds in the tree. If backup is specified, each '''Rebuild all the initrds in the tree. If backup is specified, each
initrd will be renamed with backup as a suffix before rebuilding. initrd will be renamed with backup as a suffix before rebuilding.