This avoid failing the check where the auto detected type differs from the configs ostype.
Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com> --- changes v1 -> v2: * replace regex with simple checks to already available info, this moves the fixup into "autodetect_type" where it fits better * warn not die on the check, dying here does not gains anything for the user - Inform him that something maybe wrong. Allows situtations where a user wants a unmanaged CT but autodetect_type would still detect a known one in it. src/PVE/LXC/Setup.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm index a503461..9b91539 100644 --- a/src/PVE/LXC/Setup.pm +++ b/src/PVE/LXC/Setup.pm @@ -20,18 +20,23 @@ my $plugins = { centos => 'PVE::LXC::Setup::CentOS', fedora => 'PVE::LXC::Setup::Fedora', opensuse => 'PVE::LXC::Setup::SUSE', - sles => 'PVE::LXC::Setup::SUSE', archlinux => 'PVE::LXC::Setup::ArchLinux', - arch => 'PVE::LXC::Setup::ArchLinux', alpine => 'PVE::LXC::Setup::Alpine', gentoo => 'PVE::LXC::Setup::Gentoo', }; +# a map to allow supporting related distro flavours +my $plugin_alias = { + arch => 'archlinux', + sles => 'opensuse', +}; + my $autodetect_type = sub { my ($self, $rootdir, $os_release) = @_; if (my $id = $os_release->{ID}) { - return $id if $id =~ /^(?:alpine|arch|centos|debian|fedora|gentoo|opensuse|sles|ubuntu)$/; + return $id if $plugins->{$id}; + return $plugin_alias->{$id} if $plugin_alias->{$id}; } # fallback compatibility checks @@ -78,7 +83,7 @@ sub new { $type = &$autodetect_type($self, $rootdir, $os_release); my $expected_type = $conf->{ostype} || $type; - die "got unexpected ostype ($type != $expected_type)\n" + warn "got unexpected ostype ($type != $expected_type)\n" if $type ne $expected_type; } -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel