summaryrefslogtreecommitdiffstats
path: root/images/make_boot_img
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-10-19 20:28:31 +0100
committerColin Guthrie <colin@mageia.org>2013-10-29 20:29:07 +0000
commitb5dd85f8099879b701b3bbdb8e7e50ab415fe789 (patch)
tree2cc88371557056305f9f5a78c8e7eefc82e47912 /images/make_boot_img
parent4f1bb300b5488d0d36fafc53ebb0969e51b44b8a (diff)
downloaddrakx-b5dd85f8099879b701b3bbdb8e7e50ab415fe789.tar
drakx-b5dd85f8099879b701b3bbdb8e7e50ab415fe789.tar.gz
drakx-b5dd85f8099879b701b3bbdb8e7e50ab415fe789.tar.bz2
drakx-b5dd85f8099879b701b3bbdb8e7e50ab415fe789.tar.xz
drakx-b5dd85f8099879b701b3bbdb8e7e50ab415fe789.zip
images: Convert image generation to dracut.
This converts the initrd generation from a home grown system to dracut. It uses the upstream modules where possible plus two specially written dracut modules: mgainstaller and mgakadeploy. The initrds are identical for all builds and there are lots of bits that are incomplete and unnecesary. e.g. copying the kernels to a folder and then not using them, and also the module-descriptions file is not included in the initrd itself which it should be. We can probably customise the initrd better for different use cases, e.g. perhaps network stuff is not needed for HD based installs? We may also need to install the mdraid and lvm modules for some HD support. This is the first attempt so I expect various bits need fixing
Diffstat (limited to 'images/make_boot_img')
-rwxr-xr-ximages/make_boot_img59
1 files changed, 41 insertions, 18 deletions
diff --git a/images/make_boot_img b/images/make_boot_img
index 35a00cc30..efd6a2fa2 100755
--- a/images/make_boot_img
+++ b/images/make_boot_img
@@ -62,10 +62,10 @@ foreach my $img (@images) {
} elsif ($img =~ /boot.iso/) {
boot_iso($img, \@kernels);
} elsif ($extension eq 'rdz') {
- initrd($type, $I, "$img-$_") foreach @kernels;
+ initrd($type, $I, "$img-$_", $_) foreach @kernels;
} elsif ($extension eq 'img') {
print STDERR "calling boot_img_$arch for $img\n";
- $::{"boot_img_$arch"}->($type, $I, "$img-$_", "all.kernels/$_/vmlinuz") foreach @kernels;
+ $::{"boot_img_$arch"}->($type, $I, "$img-$_", $_, "all.kernels/$_/vmlinuz") foreach @kernels;
rename("$img-$kernels[0]", $img);
} else {
die "unknown image $img";
@@ -143,7 +143,30 @@ EOF
$header . ($b_gfxboot ? $header_gfxboot : $header_non_gfxboot) . join('', @l);
}
+sub trim {
+ return $_[0] =~ s/^\s+|\s+$//rg;
+}
+
sub initrd {
+ my ($type, $I, $img, $kernel) = @_;
+ my $stage1_binary = $ENV{USE_LOCAL_STAGE1} ? trim(`realpath ../mdk-stage1/stage1`) : "";
+ my $init_binary = $ENV{USE_LOCAL_STAGE1} ? trim(`realpath ../mdk-stage1/init`) : "";
+ my ($ext) = $img =~ /rdz-(.*)/ or die "bad initrd name ($img)";
+ my $modules = " network mgainstaller ";
+
+ if ($ENV{DEBUGSTAGE1} || $ENV{BUILD_KA}) {
+ $modules="$modules busybox ";
+ }
+ $modules="$modules mgakadeploy " if ($ENV{BUILD_KA});
+
+ mkdir_p("build/dracut.conf.d");
+ touch("build/dracut.conf");
+ # TODO if --nofscks and --no-hostonly are switched, dracut gives an error - fix or report upstream
+ __ "DRAKX_STAGE1_BINARY=$stage1_binary DRAKX_INIT_BINARY=$init_binary dracut --conf ./build/dracut.conf --confdir ./build/dracut.conf.d --nofscks --no-hostonly --add ' $modules ' --omit ' dash modsign systemd plymouth btrfs crypt lvm cifs resume rootfs-block biosdevname shutdown ' '$img' '$kernel'"
+}
+
+
+sub initrdold {
my ($type, $I, $img) = @_;
my $stage1_root = $ENV{USE_LOCAL_STAGE1} ? "../mdk-stage1" : "/usr/$lib/drakx-installer-binaries";
my ($ext) = $img =~ /rdz-(.*)/ or die "bad initrd name ($img)";
@@ -252,17 +275,17 @@ sub remove_ending_zero {
}
sub boot_img_i386 {
- my ($type, $I, $img, $kernel) = @_;
+ my ($type, $I, $img, $kernel, $vmlinuz) = @_;
_ "rm -rf $tmp_mnt"; mkdir $tmp_mnt;
- _ "cat $kernel > $tmp_mnt/vmlinuz";
+ _ "cat $vmlinuz > $tmp_mnt/vmlinuz";
output("$tmp_mnt/help.msg", syslinux_msg('help.msg.xml'));
output("$tmp_mnt/advanced.msg", syslinux_msg('advanced.msg.xml'));
(my $rdz = $img) =~ s/\.img/.rdz/;
(my $initrd_type = $type) =~ s/-changedisk//;
- initrd($initrd_type, $I, $rdz);
+ initrd($initrd_type, $I, $rdz, $kernel);
my $short_type = substr($type, 0, 8);
output("$tmp_mnt/syslinux.cfg",
@@ -287,7 +310,7 @@ sub boot_img_i386 {
sub boot_img_x86_64 { &boot_img_i386 }
sub boot_img_alpha {
- my ($type, $I, $img) = @_;
+ my ($type, $I, $img, $kernel, $_vmlinuz) = @_;
__ "$sudo umount $tmp_mnt 2>/dev/null";
_ "dd if=/dev/zero of=$img bs=1k count=1440";
@@ -295,7 +318,7 @@ sub boot_img_alpha {
_ "/sbin/e2writeboot $img /boot/bootlx";
_ "$sudo mount -t ext2 $img $tmp_mnt -o loop";
_ "cp -f vmlinux.gz $tmp_mnt";
- -f "$type.rdz" ? _ "cp -f $type.rdz $tmp_mnt" : initrd($type, $I, "$tmp_mnt/$type.rdz");
+ -f "$type.rdz" ? _ "cp -f $type.rdz $tmp_mnt" : initrd($type, $I, "$tmp_mnt/$type.rdz", $kernel);
mkdir "$tmp_mnt/etc", 0777;
output("$tmp_mnt/etc/aboot.conf",
@@ -307,14 +330,14 @@ sub boot_img_alpha {
}
sub boot_img_ia64 {
- my ($type, $_I, $img, $kernel) = @_;
+ my ($type, $_I, $img, $kernel, $vmlinuz) = @_;
my $rdz = $img; $rdz =~ s/\.img/.rdz/;
__ "$sudo umount $tmp_mnt 2>/dev/null";
_ "dd if=/dev/zero of=$img bs=1k count=16384";
_ "mkdosfs $img";
_ "$sudo mount -t vfat $img $tmp_mnt -o loop,umask=000";
- _ "$sudo cp -f $kernel $tmp_mnt/vmlinux";
+ _ "$sudo cp -f $vmlinuz $tmp_mnt/vmlinux";
_ "cp -f $rdz $tmp_mnt/$type.rdz";
_ "$sudo cp -f tools/ia64/elilo.efi $tmp_mnt";
output("$tmp_mnt/elilo.conf", qq(
@@ -338,7 +361,7 @@ image=vmlinux
}
sub boot_img_sparc {
- my ($type, $I, $_img) = @_;
+ my ($type, $I, $_img, $kernel, $_vmlinuz) = @_;
if ($type =~ /^live(.*)/) {
#- hack to produce directly into /export the needed file for cdrom boot.
my $dir = "/export";
@@ -347,7 +370,7 @@ sub boot_img_sparc {
_ "mkdir -p $dir/$boot";
_ "cp -f /boot/cd.b /boot/second.b $dir/$boot";
_ "cp -f vmlinux$1 $dir/$boot/vmlinux$1";
- -f "live$1.rdz" ? _ "cp -f live$1.rdz $dir/$boot" : initrd($type, $I, "$dir/$boot/live$1.rdz");
+ -f "live$1.rdz" ? _ "cp -f live$1.rdz $dir/$boot" : initrd($type, $I, "$dir/$boot/live$1.rdz", $kernel);
output("$dir/$boot/silo.conf", qq(
partition=1
@@ -427,7 +450,7 @@ To Build a Bootable CD-ROM, try:
my $setarch = $1 ? "sparc64" : "sparc32";
_ "mkdir -p $dir/$boot";
- -f "$type.rdz" or initrd($type, $I, "$type.rdz");
+ -f "$type.rdz" or initrd($type, $I, "$type.rdz", $kernel);
_ "cp -f vmlinux$1.aout $dir/$boot/$type.img";
_ "$setarch kernel$1/src/arch/sparc$1/boot/piggyback $dir/$boot/$type.img kernel$1/boot/System.map $type.rdz";
} elsif ($type =~ /^tftp(.*)/) {
@@ -443,7 +466,7 @@ To Build a Bootable CD-ROM, try:
_ "mkdir -p $dir";
_ "cp -f /boot/fd.b /boot/second.b $dir";
_ "cp -f vmlinuz$I $dir/vmlinux$I.gz";
- -f "$type.rdz" ? _ "cp -f $type.rdz $dir" : initrd($type, $I, "$dir/$type.rdz");
+ -f "$type.rdz" ? _ "cp -f $type.rdz $dir" : initrd($type, $I, "$dir/$type.rdz", $kernel);
output("$dir/boot.msg", "
Welcome to Mageia $ENV{DISTRIB_VERSION}
@@ -474,16 +497,16 @@ image=/vmlinux$I.gz
}
sub boot_img_ppc {
- my ($_type, $I, $_img, $_kernel) = @_;
+ my ($_type, $I, $_img, $kernel, $_vmlinuz) = @_;
foreach (glob("all.kernels/*")) {
my $ext = basename($_);
if ($ext =~ /legacy/) {
- initrd("all", $I, "images/all.rdz-$ext");
+ initrd("all", $I, "images/all.rdz-$ext", $kernel);
_ "mv images/all.rdz-$ext images/all.rdz-legacy";
_ "cp $_/vmlinuz images/vmlinux-legacy";
}
elsif ($ext =~ /2.6/) {
- initrd("all", $I, "images/all.rdz-$ext");
+ initrd("all", $I, "images/all.rdz-$ext", $kernel);
_ "mv images/all.rdz-$ext images/all.rdz";
_ "cp $_/vmlinuz images/vmlinux";
}
@@ -698,7 +721,7 @@ sub syslinux_all_files {
each_index {
mkdir "$dir/alt$::i", 0777;
_ "cp all.kernels/$_/vmlinuz $dir/$arch";
- initrd('all', '', "images/all.rdz-$_");
+ initrd('all', '', "images/all.rdz-$_", $_);
rename("images/all.rdz-$_", "$dir/$arch/all.rdz");
} @$kernels;
@@ -729,7 +752,7 @@ sub xbox_stage1() {
eval { rm_rf($dir) }; mkdir_p($dir);
_ "cp all.kernels/$xbox_kernel/vmlinuz $dir";
- initrd('all', '', "images/all.rdz-$xbox_kernel");
+ initrd('all', '', "images/all.rdz-$xbox_kernel", $xbox_kernel);
rename("images/all.rdz-$xbox_kernel", "$dir/initrd");
_ "cp /usr/share/cromwell/xromwell-installer.xbe $dir/default.xbe";