From 12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 13 Jan 2018 17:08:58 +0000 Subject: draklive: create /dev/null in the chroot when building the initrd. --- lib/MGA/DrakISO/BuildBoot.pm | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'lib/MGA/DrakISO/BuildBoot.pm') diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm index 2572099..0e35c4c 100644 --- a/lib/MGA/DrakISO/BuildBoot.pm +++ b/lib/MGA/DrakISO/BuildBoot.pm @@ -32,6 +32,7 @@ use MDK::Common; use common; use File::Copy qw(mv); +use Try::Tiny; use MGA::DrakISO::LiveBuild; use MGA::DrakISO::Utils; @@ -67,20 +68,26 @@ sub prepare_live_system_boot { -e $root . $vmlinuz or die "ERROR: cannot find kernel $kernel->{version} in root system\n"; cp_f($root . $vmlinuz, $boot_dir . '/vmlinuz'); - # Build an initrd suitable for Live boot. - my $initrd = '/boot/' . $build->get_initrd_name; - run_in_root($root, undef, 'mkinitrd', '-f', if_($::verbose < 3, '-q'), $initrd, $kernel->{version}) - or die "ERROR: cannot create initrd\n"; - run_as_root('chmod', '644', $root . $initrd) - or die "ERROR: cannot chmod initrd\n"; - - # Move the initrd into the build directory. - run_as_root('mv', $root . $initrd, $boot_dir . '/initrd.gz') - or die "ERROR: cannot move initrd\n"; - - # Remove anything written to /dev/null. We haven't mounted the /dev - # filesystem, so this will just be an ordinary file. - run_as_root('rm', $root . '/dev/null') if -f $root . '/dev/null'; + my $error_message; + try { + mk_dev_null($root); + + # Build an initrd suitable for Live boot. + my $initrd = '/boot/' . $build->get_initrd_name; + run_in_root($root, undef, 'mkinitrd', '-f', if_($::verbose < 3, '-q'), $initrd, $kernel->{version}) + or die "ERROR: cannot create initrd\n"; + run_as_root('chmod', '644', $root . $initrd) + or die "ERROR: cannot chmod initrd\n"; + + # Move the initrd into the build directory. + run_as_root('mv', $root . $initrd, $boot_dir . '/initrd.gz') + or die "ERROR: cannot move initrd\n"; + } catch { + $error_message = $_; + } finally { + rm_dev_null($root); + }; + defined $error_message && die $error_message; } ############################################################################### -- cgit v1.2.1