[pve-devel] [PATCH container] close #1668: add Devuan support
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Feb 16 08:18:16 CET 2018
On 2/16/18 6:11 AM, Dietmar Maurer wrote:
>
>> 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?
>
Uh sorry, I initially did not intend to use Debain as base,
after discussions with Wolfgang, as Debian will probably adopt
more systemd specific stuff. The base above was left over as
accident from testing - that's also the reason for the strange
setup_network call.
But yeah, probably better for now to just overwrite the constructor,
let the rest handle the Debian class for now and do the split once it
really does become useful, if ever.
Thanks for noticing, I'll send a v2.
More information about the pve-devel
mailing list