From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits))
(No client certificate requested)
by lists.proxmox.com (Postfix) with ESMTPS id 22BD46140D
for ; Tue, 25 Jul 2023 16:37:28 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
by firstgate.proxmox.com (Proxmox) with ESMTP id 0C6FE1C15D
for ; Tue, 25 Jul 2023 16:37:28 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
[94.136.29.106])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits))
(No client certificate requested)
by firstgate.proxmox.com (Proxmox) with ESMTPS
for ; Tue, 25 Jul 2023 16:37:27 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3111140A43
for ; Tue, 25 Jul 2023 16:37:27 +0200 (CEST)
From: Philipp Hufnagl
To: pve-devel@lists.proxmox.com
Date: Tue, 25 Jul 2023 16:37:18 +0200
Message-Id: <20230725143720.620577-2-p.hufnagl@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20230725143720.620577-1-p.hufnagl@proxmox.com>
References: <20230725143720.620577-1-p.hufnagl@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results: 0
AWL -0.009 Adjusted score from AWL reputation of From: address
BAYES_00 -1.9 Bayes spam probability is 0 to 1%
DMARC_MISSING 0.1 Missing DMARC policy
KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record
SPF_PASS -0.001 SPF: sender matches SPF record
T_SCC_BODY_TEXT_LINE -0.01 -
URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
information. [status.pm, storage.pm]
Subject: [pve-devel] [PATCH pve-storage 1/2] fix #4849: download-url: allow
download and decompression of compressed ISOs
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
X-List-Received-Date: Tue, 25 Jul 2023 14:37:28 -0000
Signed-off-by: Philipp Hufnagl
---
src/PVE/API2/Storage/Status.pm | 20 ++++++++++++++++++--
src/PVE/Storage.pm | 22 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm
index e4ce698..9ac4660 100644
--- a/src/PVE/API2/Storage/Status.pm
+++ b/src/PVE/API2/Storage/Status.pm
@@ -578,6 +578,11 @@ __PACKAGE__->register_method({
requires => 'checksum-algorithm',
optional => 1,
},
+ compression => {
+ description => "The compression algorithm used to compress",
+ type => 'string',
+ optional => 1,
+ },
'checksum-algorithm' => {
description => "The algorithm to calculate the checksum of the file.",
type => 'string',
@@ -642,14 +647,25 @@ __PACKAGE__->register_method({
http_proxy => $dccfg->{http_proxy},
};
- my ($checksum, $checksum_algorithm) = $param->@{'checksum', 'checksum-algorithm'};
+ my ($checksum, $checksum_algorithm, $compression) = $param->@{'checksum', 'checksum-algorithm', 'compression'};
if ($checksum) {
$opts->{"${checksum_algorithm}sum"} = $checksum;
$opts->{hash_required} = 1;
}
my $worker = sub {
- PVE::Tools::download_file_from_url("$path/$filename", $url, $opts);
+ my $save_to = "$path/$filename";
+ die "refusing to override existing file $save_to \n" if -e $save_to ;
+ $save_to .= ".$compression" if $compression;
+ PVE::Tools::download_file_from_url($save_to, $url, $opts);
+ if($compression)
+ {
+ my $decrypton_error = PVE::Storage::decompress_iso($compression, $save_to);
+ print $decrypton_error if $decrypton_error;
+ unlink $save_to;
+
+
+ }
};
my $worker_id = PVE::Tools::encode_text($filename); # must not pass : or the like as w-ID
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index b99ed35..0c62cc8 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -1532,6 +1532,11 @@ sub decompressor_info {
lzo => ['lzop', '-d', '-c'],
zst => ['zstd', '-q', '-d', '-c'],
},
+ iso => {
+ gz => ['zstd', '-q', '-d'],
+ zst => ['zstd', '-q', '-d'],
+ lzo => ['lzop', '-q', '-d'],
+ },
};
die "ERROR: archive format not defined\n"
@@ -1611,6 +1616,23 @@ sub archive_auxiliaries_remove {
}
}
+sub decompress_iso
+{
+ my ($compression, $file) = @_;
+
+ my $raw = '';
+ my $out = sub {
+ my $output = shift;
+ $raw .= "$output\n";
+ };
+
+ my $info = decompressor_info('iso', $compression);
+ my $decompressor = $info->{decompressor};
+
+ run_command([@$decompressor, $file], outfunc => $out);
+ return wantarray ? ($raw, undef) : $raw;
+}
+
sub extract_vzdump_config_tar {
my ($archive, $conf_re) = @_;
--
2.39.2