[pve-devel] [PATCH pve-container] added Setup::Fedora

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Nov 24 09:48:24 CET 2015


For now only Fedora 22 is tested. The setup routines from
the Redhat base can be kept, so the only difference for now
is the version scheme and 'ostype'.
---
 src/PVE/LXC.pm              |  2 +-
 src/PVE/LXC/Setup.pm        |  4 ++++
 src/PVE/LXC/Setup/Fedora.pm | 33 +++++++++++++++++++++++++++++++++
 src/PVE/LXC/Setup/Makefile  |  2 +-
 4 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 src/PVE/LXC/Setup/Fedora.pm

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 3c23948..0bbbda1 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1060,7 +1060,7 @@ sub update_lxc_config {
     my $custom_idmap = grep { $_->[0] eq 'lxc.id_map' } @{$conf->{lxc}};
 
     my $ostype = $conf->{ostype} || die "missing 'ostype' - internal error";
-    if ($ostype =~ /^(?:debian | ubuntu | centos | archlinux)$/x) {
+    if ($ostype =~ /^(?:debian | ubuntu | centos | fedora | archlinux)$/x) {
 	$raw .= "lxc.include = /usr/share/lxc/config/$ostype.common.conf\n";
 	if ($unprivileged || $custom_idmap) {
 	    $raw .= "lxc.include = /usr/share/lxc/config/$ostype.userns.conf\n"
diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 9fb52ab..eaa4e2c 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -8,12 +8,14 @@ use PVE::Tools;
 use PVE::LXC::Setup::Debian;
 use PVE::LXC::Setup::Ubuntu;
 use PVE::LXC::Setup::Redhat;
+use PVE::LXC::Setup::Fedora;
 use PVE::LXC::Setup::ArchLinux;
 
 my $plugins = {
     debian    => 'PVE::LXC::Setup::Debian',
     ubuntu    => 'PVE::LXC::Setup::Ubuntu',
     redhat    => 'PVE::LXC::Setup::Redhat',
+    fedora    => 'PVE::LXC::Setup::Fedora',
     archlinux => 'PVE::LXC::Setup::ArchLinux',
 };
 
@@ -30,6 +32,8 @@ my $autodetect_type = sub {
 
     if (-f "$rootdir/etc/debian_version") {
 	return "debian";
+    } elsif (-f  "$rootdir/etc/fedora-release") {
+	return "fedora";
     } elsif (-f  "$rootdir/etc/redhat-release") {
 	return "redhat";
     } elsif (-f  "$rootdir/etc/arch-release") {
diff --git a/src/PVE/LXC/Setup/Fedora.pm b/src/PVE/LXC/Setup/Fedora.pm
new file mode 100644
index 0000000..2507e26
--- /dev/null
+++ b/src/PVE/LXC/Setup/Fedora.pm
@@ -0,0 +1,33 @@
+package PVE::LXC::Setup::Fedora;
+
+use strict;
+use warnings;
+
+use PVE::LXC::Setup::Redhat;
+
+use base qw(PVE::LXC::Setup::Redhat);
+
+sub new {
+    my ($class, $conf, $rootdir) = @_;
+
+    my $release = PVE::Tools::file_read_firstline("$rootdir/etc/fedora-release");
+    die "unable to read version info\n" if !defined($release);
+
+    my $version;
+
+    if ($release =~ m/release\s+(\d+(?:\.\d+)?)(\.\d+)?/) {
+	if ($1 >= 22 && $1 < 23) {
+	    $version = $1;
+	}
+    }
+
+    die "unsupported fedora release '$release'\n" if !$version;
+
+    my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+
+    $conf->{ostype} = "fedora";
+
+    return bless $self, $class;
+}
+
+1;
diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile
index 802fde3..1b5f6a2 100644
--- a/src/PVE/LXC/Setup/Makefile
+++ b/src/PVE/LXC/Setup/Makefile
@@ -1,4 +1,4 @@
-SOURCES=Base.pm Debian.pm Ubuntu.pm Redhat.pm ArchLinux.pm
+SOURCES=Base.pm Debian.pm Ubuntu.pm Redhat.pm Fedora.pm ArchLinux.pm
 
 .PHONY: install
 install:
-- 
2.1.4





More information about the pve-devel mailing list