Skip to content

Commit

Permalink
mkinitramfs: Make configuration more flexible
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
  • Loading branch information
amluto committed Apr 2, 2014
1 parent ef70529 commit bbafc31
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 7 additions & 3 deletions mkinitramfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ def generate_init():
logfunc=_LOGFUNC))
return out.getvalue().encode('utf-8')

def mkinitramfs(out, modfiles=[]):
class Config:
def __init__(self):
self.modfiles = []

def mkinitramfs(out, config):
cw = cpiowriter.CpioWriter(out)
make_base_layout(cw)
make_dev_nodes(cw)
install_busybox(cw)
install_modprobe(cw)
if modfiles is not None:
install_modules(cw, modfiles)
if config.modfiles is not None:
install_modules(cw, config.modfiles)
cw.write_file(b'init', body=generate_init(), mode=0o755)
cw.write_trailer()
9 changes: 5 additions & 4 deletions virtme-mkinitramfs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import argparse
import modfinder
import virtmods
from mkinitramfs import mkinitramfs
import mkinitramfs

_ARGPARSER = argparse.ArgumentParser(
description='Generate initramfs image for virtme',
Expand All @@ -21,12 +21,13 @@ def main():

args = _ARGPARSER.parse_args()

modfiles = []
config = mkinitramfs.Config()

if args.mod_kversion is not None:
modfiles = modfinder.find_modules_from_install(
config.modfiles = modfinder.find_modules_from_install(
virtmods.MODALIASES, kver=args.mod_kversion)

mkinitramfs(sys.stdout.buffer, modfiles)
mkinitramfs.mkinitramfs(sys.stdout.buffer, config)

return 0

Expand Down
9 changes: 6 additions & 3 deletions virtme-run
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import shutil
import os
import fcntl
import sys
from mkinitramfs import mkinitramfs
import mkinitramfs

uname = os.uname()

Expand Down Expand Up @@ -103,13 +103,16 @@ def main():

qemu = find_qemu()

config = mkinitramfs.Config()

kimg,modfiles,moddir = find_kernel_and_mods(args)
config.modfiles = modfiles

tmpfd,tmpname = tempfile.mkstemp('irfs')
os.unlink(tmpname)
tmpfile = os.fdopen(tmpfd, 'r+b')
mkinitramfs(tmpfile, modfiles=modfiles)

mkinitramfs.mkinitramfs(tmpfile, config)
tmpfile.flush()

qemuargs = [qemu]
Expand Down

0 comments on commit bbafc31

Please sign in to comment.