mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2024-12-31 17:17:57 +03:00
fix #4849: download-url: allow download and decompression of compressed ISOs
adds information for how to decompress isos. generates the compressor regex from a list of comression formats (to avoid redundancy) extends the download_url wtih the functionality to handley compression for images Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
This commit is contained in:
parent
57ec06621b
commit
2197ff97dc
@ -578,6 +578,12 @@ __PACKAGE__->register_method({
|
|||||||
requires => 'checksum-algorithm',
|
requires => 'checksum-algorithm',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
},
|
},
|
||||||
|
compression => {
|
||||||
|
description => "Decompress the downloaded file using specified compression algorithm",
|
||||||
|
type => 'string',
|
||||||
|
enum => $PVE::Storage::Plugin::KNOWN_COMPRESSION_FORMATS,
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
'checksum-algorithm' => {
|
'checksum-algorithm' => {
|
||||||
description => "The algorithm to calculate the checksum of the file.",
|
description => "The algorithm to calculate the checksum of the file.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
@ -604,7 +610,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $cfg = PVE::Storage::config();
|
my $cfg = PVE::Storage::config();
|
||||||
|
|
||||||
my ($node, $storage) = $param->@{'node', 'storage'};
|
my ($node, $storage, $compression) = $param->@{'node', 'storage','compression'};
|
||||||
my $scfg = PVE::Storage::storage_check_enabled($cfg, $storage, $node);
|
my $scfg = PVE::Storage::storage_check_enabled($cfg, $storage, $node);
|
||||||
|
|
||||||
die "can't upload to storage type '$scfg->{type}', not a file based storage!\n"
|
die "can't upload to storage type '$scfg->{type}', not a file based storage!\n"
|
||||||
@ -649,6 +655,12 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $worker = sub {
|
my $worker = sub {
|
||||||
|
if ($compression) {
|
||||||
|
die "decompression not supported for $content\n" if $content ne 'iso';
|
||||||
|
my $info = PVE::Storage::decompressor_info('iso', $compression);
|
||||||
|
die "no decompression method found\n" if (! $info->{decompressor});
|
||||||
|
$opts->{decompression_command} = $info->{decompressor};
|
||||||
|
}
|
||||||
PVE::Tools::download_file_from_url("$path/$filename", $url, $opts);
|
PVE::Tools::download_file_from_url("$path/$filename", $url, $opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1531,6 +1531,12 @@ sub decompressor_info {
|
|||||||
lzo => ['lzop', '-d', '-c'],
|
lzo => ['lzop', '-d', '-c'],
|
||||||
zst => ['zstd', '-q', '-d', '-c'],
|
zst => ['zstd', '-q', '-d', '-c'],
|
||||||
},
|
},
|
||||||
|
iso => {
|
||||||
|
# zstd seem to be able to handle .gzip fine. Therefore we dont need additional other tool
|
||||||
|
gz => ['zcat'],
|
||||||
|
lzo => ['lzop', '-d', '-c'],
|
||||||
|
zst => ['zstd', '-q', '-d', '-c'],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
die "ERROR: archive format not defined\n"
|
die "ERROR: archive format not defined\n"
|
||||||
|
@ -19,7 +19,8 @@ use JSON;
|
|||||||
|
|
||||||
use base qw(PVE::SectionConfig);
|
use base qw(PVE::SectionConfig);
|
||||||
|
|
||||||
use constant COMPRESSOR_RE => 'gz|lzo|zst';
|
use constant KNOWN_COMPRESSION_FORMATS => ( 'gz', 'lzo', 'zst');
|
||||||
|
use constant COMPRESSOR_RE => join( '|', KNOWN_COMPRESSION_FORMATS);
|
||||||
|
|
||||||
use constant LOG_EXT => ".log";
|
use constant LOG_EXT => ".log";
|
||||||
use constant NOTES_EXT => ".notes";
|
use constant NOTES_EXT => ".notes";
|
||||||
|
Loading…
Reference in New Issue
Block a user