[pve-devel] [PATCH container] fix os-release mapping for similar flavoured distros

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Aug 18 14:59:33 CEST 2017


This avoid failing the check where the auto detected type differs
from the configs ostype.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index a503461..8be1b90 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -20,13 +20,17 @@ 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 $os_release_vendor_map = {
+    arch => 'archlinux',
+    sles => 'opensuse',
+};
+
 my $autodetect_type = sub {
     my ($self, $rootdir, $os_release) = @_;
 
@@ -76,6 +80,8 @@ sub new {
     } elsif (!defined($type)) {
 	# try to autodetect type
 	$type = &$autodetect_type($self, $rootdir, $os_release);
+	# fixup type if needed, i.e. SLES can be handled by our SUSE class
+	$type = $os_release_vendor_map->{$type} if $os_release_vendor_map->{$type};
 	my $expected_type = $conf->{ostype} || $type;
 
 	die "got unexpected ostype ($type != $expected_type)\n"
-- 
2.11.0





More information about the pve-devel mailing list