[pve-devel] [PATCH container v2] close #1668: add Devuan support

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 16 08:40:48 CET 2018


Add separate Plugin as the Debian Plugin will get more systemd
specific stuff in the future, while this here is as anti-systemd as
it gets, so make the split from the start.

But only overwrite the plugin constructor for now, the rest is still
backward compatible.
---

changes v1 -> v2:
* just use Debian base plugin, besides constructor
* add additional test to ensure that changes to the Debian plugin do not
  easily break the Devuan one

 src/PVE/LXC/Setup.pm                               |  4 +++
 src/PVE/LXC/Setup/Devuan.pm                        | 31 ++++++++++++++++++++++
 src/PVE/LXC/Setup/Makefile                         |  2 +-
 src/test/test-devuan-001/config                    |  4 +++
 src/test/test-devuan-001/etc/devuan_version        |  1 +
 src/test/test-devuan-001/etc/hostname.exp          |  1 +
 src/test/test-devuan-001/etc/hosts.exp             |  5 ++++
 .../test-devuan-001/etc/network/interfaces.exp     | 18 +++++++++++++
 src/test/test-devuan-001/etc/os-release            |  8 ++++++
 .../test-devuan-001/root/.ssh/authorized_keys.exp  |  3 +++
 src/test/test-devuan-002/config                    |  9 +++++++
 src/test/test-devuan-002/etc/devuan_version        |  1 +
 src/test/test-devuan-002/etc/hostname.exp          |  1 +
 src/test/test-devuan-002/etc/hosts                 |  2 ++
 src/test/test-devuan-002/etc/hosts.exp             |  6 +++++
 src/test/test-devuan-002/etc/network/interfaces    |  2 ++
 .../test-devuan-002/etc/network/interfaces.exp     |  9 +++++++
 src/test/test-devuan-002/etc/resolv.conf           |  8 ++++++
 src/test/test-devuan-002/etc/resolv.conf.exp       | 10 +++++++
 .../test-devuan-002/root/.ssh/authorized_keys.exp  |  3 +++
 20 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/LXC/Setup/Devuan.pm
 create mode 100644 src/test/test-devuan-001/config
 create mode 100644 src/test/test-devuan-001/etc/devuan_version
 create mode 100644 src/test/test-devuan-001/etc/hostname.exp
 create mode 100644 src/test/test-devuan-001/etc/hosts.exp
 create mode 100644 src/test/test-devuan-001/etc/network/interfaces.exp
 create mode 100644 src/test/test-devuan-001/etc/os-release
 create mode 100644 src/test/test-devuan-001/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-devuan-002/config
 create mode 100644 src/test/test-devuan-002/etc/devuan_version
 create mode 100644 src/test/test-devuan-002/etc/hostname.exp
 create mode 100644 src/test/test-devuan-002/etc/hosts
 create mode 100644 src/test/test-devuan-002/etc/hosts.exp
 create mode 100644 src/test/test-devuan-002/etc/network/interfaces
 create mode 100644 src/test/test-devuan-002/etc/network/interfaces.exp
 create mode 100644 src/test/test-devuan-002/etc/resolv.conf
 create mode 100644 src/test/test-devuan-002/etc/resolv.conf.exp
 create mode 100644 src/test/test-devuan-002/root/.ssh/authorized_keys.exp

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 9b91539..ea0d415 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -13,9 +13,11 @@ use PVE::LXC::Setup::SUSE;
 use PVE::LXC::Setup::ArchLinux;
 use PVE::LXC::Setup::Alpine;
 use PVE::LXC::Setup::Gentoo;
+use PVE::LXC::Setup::Devuan;
 
 my $plugins = {
     debian    => 'PVE::LXC::Setup::Debian',
+    devuan    => 'PVE::LXC::Setup::Devuan',
     ubuntu    => 'PVE::LXC::Setup::Ubuntu',
     centos    => 'PVE::LXC::Setup::CentOS',
     fedora    => 'PVE::LXC::Setup::Fedora',
@@ -51,6 +53,8 @@ my $autodetect_type = sub {
 
     if (-f "$rootdir/etc/debian_version") {
 	return "debian";
+    } elsif (-f "$rootdir/etc/devuan_version") {
+	return "devuan";
     } elsif (-f  "$rootdir/etc/SuSE-brand" || -f "$rootdir/etc/SuSE-release") {
 	return "opensuse";
     } elsif (-f  "$rootdir/etc/fedora-release") {
diff --git a/src/PVE/LXC/Setup/Devuan.pm b/src/PVE/LXC/Setup/Devuan.pm
new file mode 100644
index 0000000..db8c8fe
--- /dev/null
+++ b/src/PVE/LXC/Setup/Devuan.pm
@@ -0,0 +1,31 @@
+package PVE::LXC::Setup::Devuan;
+
+use strict;
+use warnings;
+
+use PVE::Tools qw($IPV6RE);
+
+use PVE::LXC::Setup::Debian;
+use base qw(PVE::LXC::Setup::Debian);
+
+sub new {
+    my ($class, $conf, $rootdir) = @_;
+
+    my $version = PVE::Tools::file_read_firstline("$rootdir/etc/devuan_version");
+
+    die "unable to read version info\n" if !defined($version);
+
+    die "unsupported Devuan version '$version'\n"
+	if $version !~ /jessie|ascii/;
+
+    my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+
+    $conf->{ostype} = "devuan";
+
+    return bless $self, $class;
+}
+
+# the rest gets handled by the Debian plugin, which is compatible with older
+# non-systemd Debian versions for now.
+
+1;
diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile
index f971e0b..df0faff 100644
--- a/src/PVE/LXC/Setup/Makefile
+++ b/src/PVE/LXC/Setup/Makefile
@@ -1,4 +1,4 @@
-SOURCES=Base.pm Debian.pm Ubuntu.pm CentOS.pm Fedora.pm SUSE.pm ArchLinux.pm Alpine.pm Gentoo.pm
+SOURCES=Base.pm Debian.pm Ubuntu.pm CentOS.pm Fedora.pm SUSE.pm ArchLinux.pm Alpine.pm Gentoo.pm Devuan.pm
 
 .PHONY: install
 install:
diff --git a/src/test/test-devuan-001/config b/src/test/test-devuan-001/config
new file mode 100644
index 0000000..5191092
--- /dev/null
+++ b/src/test/test-devuan-001/config
@@ -0,0 +1,4 @@
+hostname: test1
+net0: bridge=vmbr0,name=eth0,ip=1.2.3.4/24,gw=1.2.3.1
+net1: bridge=vmbr0,name=eth1,ip=10.2.3.4/24
+net2: bridge=vmbr0,name=eth2,ip=manual
diff --git a/src/test/test-devuan-001/etc/devuan_version b/src/test/test-devuan-001/etc/devuan_version
new file mode 100644
index 0000000..dc797ba
--- /dev/null
+++ b/src/test/test-devuan-001/etc/devuan_version
@@ -0,0 +1 @@
+jessie
diff --git a/src/test/test-devuan-001/etc/hostname.exp b/src/test/test-devuan-001/etc/hostname.exp
new file mode 100644
index 0000000..a5bce3f
--- /dev/null
+++ b/src/test/test-devuan-001/etc/hostname.exp
@@ -0,0 +1 @@
+test1
diff --git a/src/test/test-devuan-001/etc/hosts.exp b/src/test/test-devuan-001/etc/hosts.exp
new file mode 100644
index 0000000..01ac197
--- /dev/null
+++ b/src/test/test-devuan-001/etc/hosts.exp
@@ -0,0 +1,5 @@
+# --- BEGIN PVE ---
+127.0.0.1 localhost.localnet localhost
+::1 localhost.localnet localhost
+1.2.3.4 test1.proxmox.com test1
+# --- END PVE ---
diff --git a/src/test/test-devuan-001/etc/network/interfaces.exp b/src/test/test-devuan-001/etc/network/interfaces.exp
new file mode 100644
index 0000000..0c7dae1
--- /dev/null
+++ b/src/test/test-devuan-001/etc/network/interfaces.exp
@@ -0,0 +1,18 @@
+auto lo
+iface lo inet loopback
+iface lo inet6 loopback
+
+auto eth0
+iface eth0 inet static
+	address 1.2.3.4
+	netmask 255.255.255.0
+	gateway 1.2.3.1
+
+auto eth1
+iface eth1 inet static
+	address 10.2.3.4
+	netmask 255.255.255.0
+
+auto eth2
+iface eth2 inet manual
+
diff --git a/src/test/test-devuan-001/etc/os-release b/src/test/test-devuan-001/etc/os-release
new file mode 100644
index 0000000..7a10aca
--- /dev/null
+++ b/src/test/test-devuan-001/etc/os-release
@@ -0,0 +1,8 @@
+PRETTY_NAME="Devuan GNU/Linux 1 (jessie)"
+NAME="Devuan GNU/Linux"
+VERSION_ID="1"
+VERSION="1 (jessie)"
+ID=devuan
+HOME_URL="http://www.devuan.org/"
+SUPPORT_URL="http://www.devuan.org/support/"
+BUG_REPORT_URL="https://bugs.devuan.org/"
\ No newline at end of file
diff --git a/src/test/test-devuan-001/root/.ssh/authorized_keys.exp b/src/test/test-devuan-001/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-devuan-001/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-devuan-002/config b/src/test/test-devuan-002/config
new file mode 100644
index 0000000..dd187fc
--- /dev/null
+++ b/src/test/test-devuan-002/config
@@ -0,0 +1,9 @@
+arch: i386
+cpulimit: 1
+memory: 512
+swap: 512
+ostype: devuan
+hostname: CT102
+nameserver: 8.8.8.8,8.8.8.9
+searchdomain: proxmox.com
+net0: bridge=vmbr0,name=eth0,hwaddr=2A:31:01:D5:A4:BF,ip=192.168.3.102/20,gw=192.168.2.1
diff --git a/src/test/test-devuan-002/etc/devuan_version b/src/test/test-devuan-002/etc/devuan_version
new file mode 100644
index 0000000..c9c3825
--- /dev/null
+++ b/src/test/test-devuan-002/etc/devuan_version
@@ -0,0 +1 @@
+ascii
diff --git a/src/test/test-devuan-002/etc/hostname.exp b/src/test/test-devuan-002/etc/hostname.exp
new file mode 100644
index 0000000..473d65d
--- /dev/null
+++ b/src/test/test-devuan-002/etc/hostname.exp
@@ -0,0 +1 @@
+CT102
diff --git a/src/test/test-devuan-002/etc/hosts b/src/test/test-devuan-002/etc/hosts
new file mode 100644
index 0000000..e7bce03
--- /dev/null
+++ b/src/test/test-devuan-002/etc/hosts
@@ -0,0 +1,2 @@
+127.0.0.1 localhost.localdomain localhost
+127.0.1.1 CT102
diff --git a/src/test/test-devuan-002/etc/hosts.exp b/src/test/test-devuan-002/etc/hosts.exp
new file mode 100644
index 0000000..7f540b4
--- /dev/null
+++ b/src/test/test-devuan-002/etc/hosts.exp
@@ -0,0 +1,6 @@
+127.0.0.1 localhost.localdomain localhost
+127.0.1.1 CT102
+# --- BEGIN PVE ---
+::1 localhost.localnet localhost
+192.168.3.102 CT102.proxmox.com CT102
+# --- END PVE ---
diff --git a/src/test/test-devuan-002/etc/network/interfaces b/src/test/test-devuan-002/etc/network/interfaces
new file mode 100644
index 0000000..f1bd92e
--- /dev/null
+++ b/src/test/test-devuan-002/etc/network/interfaces
@@ -0,0 +1,2 @@
+auto lo
+iface lo inet loopback
diff --git a/src/test/test-devuan-002/etc/network/interfaces.exp b/src/test/test-devuan-002/etc/network/interfaces.exp
new file mode 100644
index 0000000..b5ce7f8
--- /dev/null
+++ b/src/test/test-devuan-002/etc/network/interfaces.exp
@@ -0,0 +1,9 @@
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+	address 192.168.3.102
+	netmask 255.255.240.0
+	gateway 192.168.2.1
+
diff --git a/src/test/test-devuan-002/etc/resolv.conf b/src/test/test-devuan-002/etc/resolv.conf
new file mode 100644
index 0000000..c5c5a1c
--- /dev/null
+++ b/src/test/test-devuan-002/etc/resolv.conf
@@ -0,0 +1,8 @@
+# Existing data
+# Will be kept because there's a PVE section to be replaced
+
+# --- BEGIN PVE ---
+# Stuff gets filled here
+# --- END PVE ---
+
+# This will be kept, too
diff --git a/src/test/test-devuan-002/etc/resolv.conf.exp b/src/test/test-devuan-002/etc/resolv.conf.exp
new file mode 100644
index 0000000..b50943a
--- /dev/null
+++ b/src/test/test-devuan-002/etc/resolv.conf.exp
@@ -0,0 +1,10 @@
+# Existing data
+# Will be kept because there's a PVE section to be replaced
+
+# --- BEGIN PVE ---
+search proxmox.com
+nameserver 8.8.8.8
+nameserver 8.8.8.9
+# --- END PVE ---
+
+# This will be kept, too
diff --git a/src/test/test-devuan-002/root/.ssh/authorized_keys.exp b/src/test/test-devuan-002/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-devuan-002/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
-- 
2.14.2





More information about the pve-devel mailing list