mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-23 02:42:17 +00:00
fix(ubuntu): publish the kernel and ramdisks of genimage together
genimage copied the kernel to the image directory before it built the initial ramdisks. When dracut failed for either ramdisk, a new kernel stayed next to the old ramdisks, and nodeset copied that set. The legacy ramdisk ignored a failed cpio pipeline and published what the compressor wrote. genimage now builds the kernel and both ramdisks in a staging directory in the image directory. It publishes them together with publish_staged_boot_files after both ramdisks are built, and writes the root image check and UFTP markers after that. A failure leaves the previous kernel and ramdisks in place.
This commit is contained in:
@@ -732,16 +732,20 @@ chomp($kernelver);
|
||||
|
||||
#$updates{'kernelver'} = $kernelver if ($tempfile);
|
||||
|
||||
# copy the kernel to $destdir
|
||||
# The kernel and the initial ramdisks wait here until genimage publishes them together.
|
||||
my $native_bootdir = File::Temp->newdir('.genimage-boot.XXXXXX', DIR => $destdir, CLEANUP => 1);
|
||||
my $stateless_uftp_receiver;
|
||||
my $kernel_copy;
|
||||
if (-e "$rootimg_dir/boot/vmlinux-$kernelver") {
|
||||
cp("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/vmlinux-$kernelver", "$native_bootdir/kernel");
|
||||
} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") {
|
||||
cp("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/vmlinuz-$kernelver", "$native_bootdir/kernel");
|
||||
} elsif (-e "$rootimg_dir/boot/image-$kernelver") {
|
||||
cp("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/image-$kernelver", "$native_bootdir/kernel");
|
||||
} else {
|
||||
xdie("couldn't find the kernel file matched $kernelver in $rootimg_dir/boot");
|
||||
}
|
||||
die("Error: failed to copy the kernel to $native_bootdir: $!\n") unless $kernel_copy;
|
||||
|
||||
# Load driver update disk, and copy them to the root image
|
||||
my @dd_drivers = &load_dd();
|
||||
@@ -938,6 +942,11 @@ if ($dracutmode) {
|
||||
push @ndrivers, @drivers;
|
||||
mkinitrd("stateless");
|
||||
}
|
||||
eval { imgutils::publish_staged_boot_files($native_bootdir, $destdir, 'statelite', 'stateless') } or die($@);
|
||||
if ($dracutmode) {
|
||||
mark_rootimg_check('stateless');
|
||||
imgutils::mark_uftp_receiver("$destdir/initrd-stateless.gz", $stateless_uftp_receiver);
|
||||
}
|
||||
|
||||
sub getlibs {
|
||||
my $file = shift;
|
||||
@@ -1061,10 +1070,9 @@ sub mkinitrd_dracut {
|
||||
or die("Error: failed to generate the initial ramdisk for $mode.\n");
|
||||
eval { imgutils::check_uftp_initrd($rootimg_dir, "/tmp/initrd.$$.gz", $mode) } or xdie($@) if $uftp_receiver;
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
if (move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz")) {
|
||||
mark_rootimg_check($mode);
|
||||
imgutils::mark_uftp_receiver("$destdir/initrd-$mode.gz", $uftp_receiver) if $mode eq 'stateless';
|
||||
}
|
||||
move("$rootimg_dir/tmp/initrd.$$.gz", "$native_bootdir/initrd-$mode.gz")
|
||||
or die("Error: failed to stage the initial ramdisk for $mode: $!\n");
|
||||
$stateless_uftp_receiver = $uftp_receiver if $mode eq 'stateless';
|
||||
}
|
||||
|
||||
# nodeset warns unless this marker says that the stateless initial ramdisk checks the root image checksum.
|
||||
@@ -1884,9 +1892,11 @@ EOMS
|
||||
}
|
||||
|
||||
#copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_");
|
||||
print "\ncd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz \n";
|
||||
system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz");
|
||||
my $initrd = "$native_bootdir/initrd-$mode.gz";
|
||||
print "\ncd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $initrd \n";
|
||||
my $rc = system('bash', '-c', "set -o pipefail; cd /tmp/xcatinitrd.$$ && find . | cpio -H newc -o | $compress -9 -c - > $initrd");
|
||||
system("rm -rf /tmp/xcatinitrd.$$");
|
||||
die("Error: failed to generate the initial ramdisk for $mode.\n") if $rc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user