]> git.proxmox.com Git - dab.git/commitdiff
bootstrap: extract: make compressor detection generic
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 12 Oct 2021 12:34:31 +0000 (14:34 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 12 Oct 2021 12:34:31 +0000 (14:34 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
DAB.pm

diff --git a/DAB.pm b/DAB.pm
index f0d025fc6196bd4033bfe21875527d4d3ef3b57e..6c804c2f4d246fadc7bb24d995724e6cd2ab9abf 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -1449,14 +1449,23 @@ sub bootstrap {
        $self->setup_usr_merge();
     }
 
+    my $compressor2opt = {
+       'gz' => '--gzip',
+       'xz' => '--xz',
+    };
+    my $compressor_re = join('|', keys $compressor2opt->%*);
+
     $self->logmsg ("extract required packages to rootfs\n");
     foreach my $p (@$required) {
        my $filename = $self->getpkgfile ($p);
        my $content = $self->run_command("ar -t '$self->{cachedir}/$filename'", undef, 1);
-       if ($content =~ m/^data.tar.xz$/m) {
-           $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.xz | tar -C '$rootdir' -xJf - --keep-directory-symlink");
+       if ($content =~ m/^(data.tar.($compressor_re))$/m) {
+           my $archive = $1;
+           my $tar_opts = "--keep-directory-symlink $compressor2opt->{$2}";
+
+           $self->run_command("ar -p '$self->{cachedir}/$filename' '$archive' | tar -C '$rootdir' -xf - $tar_opts");
        } else {
-           $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf - --keep-directory-symlink");
+           die "unexpected error for $p: no data.tar.{xz,gz,zst} found...";
        }
     }