]> git.proxmox.com Git - dab.git/blobdiff - DAB.pm
use --rcfile to work with newer lxc
[dab.git] / DAB.pm
diff --git a/DAB.pm b/DAB.pm
index e02cf10fb528e3fc3993d7cb9897d9fc674c2da1..8991084bb0897ec0d3e49574edcefdad78961ce5 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -343,6 +343,8 @@ sub new {
        $config->{ostype} = "ubuntu-15.04";
     } elsif ($suite eq 'wily') {
        $config->{ostype} = "ubuntu-15.10";
+    } elsif ($suite eq 'xenial') {
+       $config->{ostype} = "ubuntu-16.04";
     } else {
        die "unsupported debian suite '$suite'\n";
     }
@@ -373,7 +375,8 @@ sub new {
                if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie');
            push @{$config->{source}}, "http://security.debian.org SUITE/updates main contrib";
        } elsif ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty' ||
-                $suite eq 'wily' || $suite eq 'vivid' || $suite eq 'trusty' || $suite eq 'precise') {
+                $suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
+                $suite eq 'trusty' || $suite eq 'precise') {
            my $comp = "main restricted universe multiverse";
            push @{$config->{source}}, "http://archive.ubuntu.com/ubuntu SUITE $comp"; 
            push @{$config->{source}}, "http://archive.ubuntu.com/ubuntu SUITE-updates $comp"; 
@@ -440,8 +443,9 @@ sub new {
     # ubuntu has too many dependencies on udev, so
     # we cannot exclude it (instead we disable udevd)
 
-    if ($suite eq 'vivid' || $suite eq 'wily') {
+    if ($suite eq 'vivid' || $suite eq 'wily' || $suite eq 'xenial') {
        push @$incl, 'isc-dhcp-client';
+       push @$excl, qw(libmodule-build-perl);
     } elsif ($suite eq 'trusty') {
        push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+);
    } elsif ($suite eq 'precise') {
@@ -544,6 +548,7 @@ sub finalize {
     my $instpkgs = $self->read_installed ();
     my $pkginfo = $self->pkginfo();
     my $veid = $self->{veid};
+    my $conffile = $self->{veconffile};
     my $rootdir = $self->{rootfs};
 
     my $vestat = $self->ve_status();
@@ -609,7 +614,7 @@ sub finalize {
     $self->ve_divert_remove ("/sbin/init"); 
 
     # finally stop the VE
-    $self->run_command ("lxc-stop -n $veid --kill");
+    $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
 
     unlink "$rootdir/sbin/defenv";
 
@@ -716,12 +721,13 @@ sub ve_command {
     my ($self, $cmd, $input) = @_;
 
     my $veid = $self->{veid};
+    my $conffile = $self->{veconffile};
 
     if (ref ($cmd) eq 'ARRAY') {
-       unshift @$cmd, 'lxc-attach', '-n', $veid, '--clear-env', '--', 'defenv';
+       unshift @$cmd, 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--clear-env', '--', 'defenv';
        $self->run_command ($cmd, $input);      
     } else {
-       $self->run_command ("lxc-attach -n $veid --clear-env -- defenv $cmd", $input);
+       $self->run_command ("lxc-attach -n $veid --rcfile $conffile --clear-env -- defenv $cmd", $input);
     }
 }
 
@@ -730,9 +736,10 @@ sub ve_exec {
     my ($self, @cmd) = @_;
 
     my $veid = $self->{veid};
+    my $conffile = $self->{veconffile};
 
     my $reader;
-    my $pid = open2($reader, "<&STDIN", 'lxc-attach', '-n', $veid,  '--',
+    my $pid = open2($reader, "<&STDIN", 'lxc-attach', '-n', $veid,  '--rcfile', $conffile, '--',
                    'defenv', @cmd) || die "unable to exec command";
     
     while (defined (my $line = <$reader>)) {
@@ -812,10 +819,11 @@ sub ve_destroy {
     my ($self) = @_;
 
     my $veid = $self->{veid}; # fixme
+    my $conffile = $self->{veconffile};
 
     my $vestat = $self->ve_status();
     if ($vestat->{running}) {
-       $self->run_command ("lxc-stop -n $veid --kill");
+       $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
     }
 
     rmtree $self->{rootfs};
@@ -826,12 +834,13 @@ sub ve_init {
     my ($self) = @_;
 
     my $veid = $self->{veid};
+    my $conffile = $self->{veconffile};
 
     $self->logmsg ("initialize VE $veid\n");
 
     my $vestat = $self->ve_status();
     if ($vestat->{running}) {
-       $self->run_command ("lxc-stop -n $veid --kill");
+       $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
     } 
 
     rmtree $self->{rootfs};
@@ -1110,7 +1119,7 @@ sub install_init_script {
     $self->run_command ("install -m 0755 '$script' '$target'");
     if ($suite eq 'etch' || $suite eq 'lenny') {
        $self->ve_command ("update-rc.d $base start $prio $runlevel .");
-    } elsif ($suite eq 'wily' || $suite eq 'vivid') {
+    } elsif ($suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid') {
        die "unable to install init script (system uses systemd)\n";
     } elsif ($suite eq 'trusty' || $suite eq 'precise') {
        die "unable to install init script (system uses upstart)\n";
@@ -1229,8 +1238,12 @@ sub bootstrap {
     # avoid warnings about non-existent resolv.conf
     write_file ("", "$rootdir/etc/resolv.conf", 0644);
 
-    $data = "auto lo\niface lo inet loopback\n";
-    write_file ($data, "$rootdir/etc/network/interfaces", 0644);
+    if ($suite eq 'xenial' || $suite eq 'wily') {
+       # no need to configure loopback device
+    } else {
+       $data = "auto lo\niface lo inet loopback\n";
+       write_file ($data, "$rootdir/etc/network/interfaces", 0644);
+    }
 
     # setup devices
     $self->run_command ("tar xzf '$devicetar' -C '$rootdir'");
@@ -1421,6 +1434,7 @@ sub enter {
     my ($self) = @_;
 
     my $veid = $self->{veid};
+    my $conffile = $self->{veconffile};
 
     my $vestat = $self->ve_status();
 
@@ -1430,10 +1444,10 @@ sub enter {
     }
 
     if (!$vestat->{running}) {
-       $self->run_command ("lxc-start -n $veid -f $self->{veconffile}");
+       $self->run_command ("lxc-start -n $veid -f $conffile");
     }
 
-    system ("lxc-attach -n $veid --clear-env");
+    system ("lxc-attach -n $veid --rcfile $conffile --clear-env");
 }
 
 sub ve_mysql_command {