[pve-devel] [PATCH container] close #1668: add Devuan support
Dietmar Maurer
dietmar at proxmox.com
Fri Feb 16 06:11:13 CET 2018
> diff --git a/src/PVE/LXC/Setup/Devuan.pm b/src/PVE/LXC/Setup/Devuan.pm
> new file mode 100644
> index 0000000..2f35de6
> --- /dev/null
> +++ b/src/PVE/LXC/Setup/Devuan.pm
> @@ -0,0 +1,73 @@
> +package PVE::LXC::Setup::Devuan;
> +
> +use strict;
> +use warnings;
> +
> +use PVE::Tools qw($IPV6RE);
> +use PVE::LXC;
> +use PVE::Network;
> +use File::Path;
> +
> +use PVE::LXC::Setup::Base;
> +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;
> +}
> +
> +# Devuan doesn't support the /dev/lxc/ subdirectory.
> +sub devttydir {
> + return '';
> +}
> +
> +sub setup_init {
> + my ($self, $conf) = @_;
> +
> + my $filename = "/etc/inittab";
> + return if !$self->ct_file_exists($filename);
> +
> + my $ttycount = PVE::LXC::Config->get_tty_count($conf);
> + my $inittab = $self->ct_file_get_contents($filename);
> +
> + my @lines = grep {
> + # remove getty lines
> + !/^\s*\d+:\d*:[^:]*:.*getty/ &&
> + # remove power lines
> + !/^\s*p[fno0]:/
> + } split(/\n/, $inittab);
> +
> + $inittab = join("\n", @lines) . "\n";
> +
> + $inittab .= "p0::powerfail:/sbin/init 0\n";
> +
> + for (my $id = 1; $id <= $ttycount; $id++) {
> + next if $id == 7; # reserved for X11
> + my $levels = ($id == 1) ? '2345' : '23';
> + $inittab .= "$id:$levels:respawn:/sbin/getty --noclear 38400 tty$id\n";
> + }
> +
> + $self->ct_file_set_contents($filename, $inittab);
> +}
> +
> +sub setup_network {
> + my ($self, $conf) = @_;
> +
> + PVE::LXC::Setup::Debian::setup_network($self, $conf);
> +}
> +
> +1;
why do you duplicate setup_network and setup_init and devttydir here? Base
class implementation work perfectly, so there is no need to copy that code?
More information about the pve-devel
mailing list