summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}
###############################################################################