[pve-devel] [PATCH container 1/2] fix #5720: add setup support for openEuler

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Nov 8 14:18:29 CET 2024


openEuler is centOS-derived Linux distribution. the LXC project builds a
template for it that mostly works out of the box.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---

Notes:
    did some basic smoke testing using
    openeuler-24.09-default_20241028_amd64.tar.xz from images.linuxcontainers.org

 src/PVE/LXC/Setup.pm           |  5 +++++
 src/PVE/LXC/Setup/Makefile     |  1 +
 src/PVE/LXC/Setup/OpenEuler.pm | 35 ++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 src/PVE/LXC/Setup/OpenEuler.pm

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 3a937a9..dc58990 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -18,6 +18,7 @@ use PVE::LXC::Setup::Gentoo;
 use PVE::LXC::Setup::SUSE;
 use PVE::LXC::Setup::Ubuntu;
 use PVE::LXC::Setup::NixOS;
+use PVE::LXC::Setup::OpenEuler;
 use PVE::LXC::Setup::Unmanaged;
 
 my $plugins = {
@@ -28,6 +29,7 @@ my $plugins = {
     devuan    => 'PVE::LXC::Setup::Devuan',
     fedora    => 'PVE::LXC::Setup::Fedora',
     gentoo    => 'PVE::LXC::Setup::Gentoo',
+    openeuler => 'PVE::LXC::Setup::OpenEuler',
     opensuse  => 'PVE::LXC::Setup::SUSE',
     ubuntu    => 'PVE::LXC::Setup::Ubuntu',
     nixos     => 'PVE::LXC::Setup::NixOS',
@@ -39,6 +41,7 @@ my $plugin_alias = {
     'opensuse-leap' => 'opensuse',
     'opensuse-tumbleweed' => 'opensuse',
     'opensuse-slowroll' => 'opensuse',
+    'openEuler' => 'openeuler',
     arch => 'archlinux',
     sles => 'opensuse',
 };
@@ -80,6 +83,8 @@ my $autodetect_type = sub {
 	return "gentoo";
     } elsif (-d  "$rootdir/nix/store") {
 	return "nixos";
+    } elsif (-f "$rootdir/etc/openEuler-release") {
+	return "openeuler";
     } elsif (-f "$rootdir/etc/os-release") {
 	die "unable to detect OS distribution\n";
     } else {
diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile
index df1cf97..688b547 100644
--- a/src/PVE/LXC/Setup/Makefile
+++ b/src/PVE/LXC/Setup/Makefile
@@ -11,6 +11,7 @@ SOURCES=\
     SUSE.pm		\
     Ubuntu.pm		\
     NixOS.pm		\
+    OpenEuler.pm	\
     Unmanaged.pm	\
 
 .PHONY: install
diff --git a/src/PVE/LXC/Setup/OpenEuler.pm b/src/PVE/LXC/Setup/OpenEuler.pm
new file mode 100644
index 0000000..b34b957
--- /dev/null
+++ b/src/PVE/LXC/Setup/OpenEuler.pm
@@ -0,0 +1,35 @@
+package PVE::LXC::Setup::OpenEuler;
+
+use strict;
+use warnings;
+
+use PVE::LXC::Setup::CentOS;
+use base qw(PVE::LXC::Setup::CentOS);
+
+sub new {
+    my ($class, $conf, $rootdir, $os_release) = @_;
+
+    my $version = $os_release->{VERSION_ID};
+    # we cannot really win anything by actively dying on newer versions so only check lower boundary.
+    die "unsupported openEuler release '$version'\n" if !defined($version) || $version < 24;
+
+    my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+
+    $conf->{ostype} = "openeuler";
+
+    return bless $self, $class;
+}
+
+sub template_fixup {
+    my ($self, $conf) = @_;
+
+    $self->remove_lxc_name_from_etc_hosts();
+}
+
+sub setup_init {
+    my ($self, $conf) = @_;
+    $self->setup_container_getty_service($conf);
+    $self->setup_systemd_preset();
+}
+
+1;
-- 
2.39.5





More information about the pve-devel mailing list