mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-08-28 17:46:40 +00:00
fix(mknb): compress the genesis image with xz when lzma is absent
The genesis image goes into a file whose name ends with .lzma. The plugin writes that file only when /usr/bin/lzma is there, and it falls back to gzip when it is not. Red Hat ships no lzma binary. On AlmaLinux 9 and on AlmaLinux 10 that test fails, the plugin falls back to gzip, and it gives no message that says why. The image is larger on each run of mknb. Debian and Ubuntu ship lzma as a second name for xz, so those systems still get the smaller image. Ask xz for the same container when lzma is absent. The command "xz --format=lzma" writes the same bytes as "lzma", so the file keeps its name, its container and its size. Keep the gzip fallback for a system that has neither program. Recovered from the lenovobuild branch, which asked xz for the xz container. That container is not the lzma container, and the name of the file says lzma.
This commit is contained in:
@@ -246,6 +246,13 @@ sub _install_prebuilt_genesis {
|
||||
return ("$destination_dir/genesis.fs.$arch.gz", undef);
|
||||
}
|
||||
|
||||
sub genesis_lzma_command {
|
||||
my ($have_lzma, $have_xz) = @_;
|
||||
return 'lzma -C crc32 -9' if $have_lzma;
|
||||
return 'xz --format=lzma -C crc32 -9' if $have_xz;
|
||||
return;
|
||||
}
|
||||
|
||||
sub process_request {
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
@@ -484,9 +491,10 @@ sub process_request {
|
||||
# place, so concurrent mknb runs sharing $tftpdir cannot read or clobber
|
||||
# a half-written genesis.fs.
|
||||
my $suffix = xCAT::Utils::genpassword(24);
|
||||
if (-x "/usr/bin/lzma") { #let's reclaim some of that size...
|
||||
my $lzma_command = genesis_lzma_command(-x "/usr/bin/lzma", -x "/usr/bin/xz");
|
||||
if ($lzma_command) { #let's reclaim some of that size...
|
||||
$callback->({ data => ["Creating genesis.fs.$arch.lzma in $tftpdir/xcat"] });
|
||||
system("cd $tempdir; find . | cpio -o -H newc | lzma -C crc32 -9 > $tftpdir/xcat/genesis.fs.$arch.lzma.$suffix");
|
||||
system("cd $tempdir; find . | cpio -o -H newc | $lzma_command > $tftpdir/xcat/genesis.fs.$arch.lzma.$suffix");
|
||||
$lzma_exit_value = $? >> 8;
|
||||
if ($lzma_exit_value) {
|
||||
$callback->({ data => ["Creating genesis.fs.$arch.lzma in $tftpdir/xcat failed, falling back to gzip"] });
|
||||
|
||||
Reference in New Issue
Block a user