From: Thomas Lamprecht Date: Tue, 25 Aug 2020 19:01:04 +0000 (+0200) Subject: allow compressing final archive with zstd X-Git-Url: https://git.proxmox.com/?p=dab.git;a=commitdiff_plain;h=f06fe8dc8f98cb28ed699b4a8200357da0bd7f0d allow compressing final archive with zstd Signed-off-by: Thomas Lamprecht --- diff --git a/DAB.pm b/DAB.pm index cb04f7e..8dd89ec 100644 --- a/DAB.pm +++ b/DAB.pm @@ -776,13 +776,23 @@ sub finalize { $self->logmsg ("creating final appliance archive\n"); my $target = "$self->{targetname}.tar"; - my $final_archive = "${target}.gz"; + + my $compressor = $opts->{compressor} // 'gz'; + my $compressor2cmd_map = { + gz => 'gzip', + zst => 'zstd', + }; + my $compressor_cmd = $compressor2cmd_map->{$compressor}; + die "unkown compressor '$compressor', use one of: ". join(', ', sort keys %$compressor2cmd_map) + if !defined($compressor_cmd); + + my $final_archive = "${target}.${compressor}"; unlink $target; unlink $final_archive; $self->run_command ("tar cpf $target --numeric-owner -C '$rootdir' ./etc/appliance.info"); $self->run_command ("tar rpf $target --numeric-owner -C '$rootdir' --exclude ./etc/appliance.info ."); - $self->run_command ("gzip $target"); + $self->run_command ("$compressor_cmd $target"); $self->logmsg ("detecting final commpressed appliance size: "); $size = $get_path_size->($final_archive); diff --git a/dab b/dab index 6ca953a..f1f63e8 100755 --- a/dab +++ b/dab @@ -12,7 +12,7 @@ $ENV{'LC_ALL'} = 'C'; my $commands = { 'init' => '', 'bootstrap' => '[--exim] [--minimal]', - 'finalize' => '[--keepmycnf]', + 'finalize' => '[--keepmycnf] [--compressor ]', 'veid' => '', 'basedir' => '', 'packagefile' => '', @@ -93,7 +93,7 @@ eval { } elsif ($cmd eq 'finalize') { my $opts = {}; - if (!GetOptions ($opts, 'keepmycnf')) { + if (!GetOptions ($opts, 'keepmycnf', 'compressor=s')) { print_usage(); exit (-1); }