summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/BuildBoot.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2018-01-13 17:08:58 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2018-01-14 22:33:21 +0000
commit12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009 (patch)
treec1147ea21b1765f79eb6ebce656ad8385d121b70 /lib/MGA/DrakISO/BuildBoot.pm
parent693b5e844102bced38b08bc13e758e12fd7f6fde (diff)
downloaddrakiso-12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009.tar
drakiso-12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009.tar.gz
drakiso-12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009.tar.bz2
drakiso-12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009.tar.xz
drakiso-12b6a8dc3ce4f5dc0c51b0b36e7b658b60f7a009.zip
draklive: create /dev/null in the chroot when building the initrd.
Diffstat (limited to 'lib/MGA/DrakISO/BuildBoot.pm')
-rw-r--r--lib/MGA/DrakISO/BuildBoot.pm35
1 files changed, 21 insertions, 14 deletions
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;
}
###############################################################################