]> git.proxmox.com Git - dab.git/blobdiff - DAB.pm
devuan: add future daedalus 5.x release
[dab.git] / DAB.pm
diff --git a/DAB.pm b/DAB.pm
index 6d850beeed9f3c7fb988bf1085d34d476c9bb2d4..4f54e4f01260fdbc79cefb840c622543576aedb9 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -59,6 +59,8 @@ sub __url_to_filename {
 
 # defaults:
 #  origin: debian
+#  flags:
+#    systemd: true (except for devuan ostypes)
 my $supported_suites = {
     'bookworm' => {
        ostype => "debian-12",
@@ -76,19 +78,31 @@ my $supported_suites = {
        ostype => "debian-8.0",
     },
     'wheezy' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "debian-7.0",
     },
     'squeeze' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "debian-6.0",
     },
     'lenny' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "debian-5.0",
     },
     'etch' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "debian-4.0",
     },
 
-# DEVUAN
+# DEVUAN (imply systemd = 0 default)
     'devuan-jessie' => {
        suite => 'jessie',
        ostype => "devuan-1.0",
@@ -106,25 +120,43 @@ my $supported_suites = {
     'chimaera' => {
        ostype => "devuan-4.0",
     },
+    'daedalus' => {
+       ostype => "devuan-5.0",
+    },
 
 # UBUNTU
     'hardy' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "ubuntu-8.04",
        origin => 'ubuntu',
     },
     'intrepid' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "ubuntu-8.10",
        origin => 'ubuntu',
     },
     'jaunty' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "ubuntu-9.04",
        origin => 'ubuntu',
     },
     'precise' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "ubuntu-12.04",
        origin => 'ubuntu',
     },
     'trusty' => {
+       flags => {
+           systemd => 0,
+       },
        ostype => "ubuntu-14.04",
        origin => 'ubuntu',
     },
@@ -195,6 +227,13 @@ sub get_suite_info {
     $suiteinfo->{origin} //= 'debian';
     $suiteinfo->{suite} //= $suite;
 
+    $suiteinfo->{flags} //= {};
+    if ($suiteinfo->{ostype} =~ /^devuan/) {
+       $suiteinfo->{flags}->{systemd} //= 0;
+    } else {
+       $suiteinfo->{flags}->{systemd} //= 1;
+    }
+
     return $suiteinfo;
 }
 
@@ -613,12 +652,7 @@ 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' || $suite eq 'xenial' ||
-       $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful' ||
-       $suite eq 'bionic' || $suite eq 'cosmic' || $suite eq 'disco' ||
-       $suite eq 'eoan' || $suite eq 'focal' || $suite eq 'groovy'
-       || $suite eq 'hirsute' || $suite eq 'impish'
-    ) {
+    if (lc($suiteinfo->{origin}) eq 'ubuntu' && $suiteinfo->{flags}->{systemd}) {
        push @$incl, 'isc-dhcp-client';
        push @$excl, qw(libmodule-build-perl);
     } elsif ($suite eq 'trusty') {
@@ -884,8 +918,7 @@ sub read_installed {
 
     my $pkgfilelist = "$rootdir/var/lib/dpkg/status";
     local $/ = '';
-    open (PKGLST, "<$pkgfilelist") ||
-       die "unable to open '$pkgfilelist'";
+    open (PKGLST, "<$pkgfilelist") or die "unable to open '$pkgfilelist' - $!";
 
     my $pkglist = {};
 
@@ -938,7 +971,7 @@ sub ve_status {
        }
     }
     close($fh);
-    
+
     return $res;
 }
 
@@ -950,9 +983,9 @@ sub ve_command {
 
     if (ref ($cmd) eq 'ARRAY') {
        unshift @$cmd, 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--clear-env', '--', 'defenv';
-       $self->run_command ($cmd, $input);      
+       $self->run_command($cmd, $input);
     } else {
-       $self->run_command ("lxc-attach -n $veid --rcfile $conffile --clear-env -- defenv $cmd", $input);
+       $self->run_command("lxc-attach -n $veid --rcfile $conffile --clear-env -- defenv $cmd", $input);
     }
 }
 
@@ -1340,6 +1373,7 @@ sub install_init_script {
     my ($self, $script, $runlevel, $prio) = @_;
 
     my $suite = $self->{config}->{suite};
+    my $suiteinfo = get_suite_info($suite);
     my $rootdir = $self->{rootfs};
 
     my $base = basename ($script);
@@ -1348,12 +1382,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 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
-            $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful' ||
-            $suite eq 'bionic' || $suite eq 'cosmic' || $suite eq 'disco' ||
-            $suite eq 'eoan' || $suite eq 'focal' || $suite eq 'groovy'
-            || $suite eq 'hirsute' || $suite eq 'impish'
-    ) {
+    } elsif ($suiteinfo->{flags}->{systemd}) {
        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";
@@ -1370,6 +1399,7 @@ sub bootstrap {
     my $pkginfo = $self->pkginfo();
     my $veid = $self->{veid};
     my $suite = $self->{config}->{suite};
+    my $suiteinfo = get_suite_info($suite);
 
     my $important = [ @{$self->{incl}} ];
     my $required;
@@ -1403,12 +1433,11 @@ sub bootstrap {
     }
 
     my $closure = {};
-    $required = $self->closure ($closure, $required);
-    $important = $self->closure ($closure, $important);
+    $required = $self->closure($closure, $required);
+    $important = $self->closure($closure, $important);
 
     if (!$opts->{minimal}) {
-       push @$standard, 'xbase-clients';
-       $standard = $self->closure ($closure, $standard);
+       $standard = $self->closure($closure, $standard);
     }
 
     # test if we have all 'ubuntu-minimal' and 'ubuntu-standard' packages
@@ -1450,14 +1479,24 @@ sub bootstrap {
        $self->setup_usr_merge();
     }
 
+    my $compressor2opt = {
+       'zst' => '--zstd',
+       'gz' => '--gzip',
+       'xz' => '--xz',
+    };
+    my $compressor_re = join('|', keys $compressor2opt->%*);
+
     $self->logmsg ("extract required packages to rootfs\n");
     foreach my $p (@$required) {
        my $filename = $self->getpkgfile ($p);
        my $content = $self->run_command("ar -t '$self->{cachedir}/$filename'", undef, 1);
-       if ($content =~ m/^data.tar.xz$/m) {
-           $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.xz | tar -C '$rootdir' -xJf - --keep-directory-symlink");
+       if ($content =~ m/^(data.tar.($compressor_re))$/m) {
+           my $archive = $1;
+           my $tar_opts = "--keep-directory-symlink $compressor2opt->{$2}";
+
+           $self->run_command("ar -p '$self->{cachedir}/$filename' '$archive' | tar -C '$rootdir' -xf - $tar_opts");
        } else {
-           $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf - --keep-directory-symlink");
+           die "unexpected error for $p: no data.tar.{xz,gz,zst} found...";
        }
     }
 
@@ -1487,15 +1526,9 @@ sub bootstrap {
     # avoid warnings about non-existent resolv.conf
     write_file ("", "$rootdir/etc/resolv.conf", 0644);
 
-    if (
-       $suite eq 'impish' ||
-       $suite eq 'hirsute' || $suite eq 'groovy' || $suite eq 'focal' ||
-       $suite eq 'eoan' || $suite eq 'disco' || $suite eq 'cosmic' ||
-       $suite eq 'bionic' || $suite eq 'artful' ||
-       $suite eq 'zesty' || $suite eq 'yakkety' || $suite eq 'xenial' ||
-       $suite eq 'wily'
-    ) {
+    if (lc($suiteinfo->{origin}) eq 'ubuntu' && $suiteinfo->{flags}->{systemd}) {
        # no need to configure loopback device
+       # FIXME: Debian (systemd based?) too?
     } else {
        $data = "auto lo\niface lo inet loopback\n";
        mkdir "$rootdir/etc/network";
@@ -1565,8 +1598,7 @@ EOD
     $self->ve_divert_add ("/sbin/udevd");
 
     if ($suite eq 'etch') {
-       # disable apache2 startup
-       write_file ("NO_START=1\n", "$rootdir/etc/default/apache2");
+       write_file ("NO_START=1\n", "$rootdir/etc/default/apache2"); # disable apache2 startup
     }
 
     $self->logmsg ("configure required packages\n");
@@ -1748,7 +1780,7 @@ sub compute_required {
     my $instpkgs = $self->read_installed ();
 
     my $closure = {};
-    __record_provides ($pkginfo, $closure, [keys %$instpkgs]);
+    __record_provides($pkginfo, $closure, [keys $instpkgs->%*]);
 
     return $self->closure ($closure, $pkglist);
 }
@@ -1757,7 +1789,7 @@ sub task_postgres {
     my ($self, $opts) = @_;
 
     my @supp = ('7.4', '8.1');
-    my $pgversion = '8.1';
+    my $pgversion; # NOTE: not setting that defaults to the distro default, normally the best choice
 
     my $suite = $self->{config}->{suite};
 
@@ -1768,34 +1800,33 @@ sub task_postgres {
        @supp = ('8.4');
        $pgversion = '8.4';
     } elsif ($suite eq 'wheezy') {
-        @supp = ('9.1');
-        $pgversion = '9.1';
+       @supp = ('9.1');
+       $pgversion = '9.1';
     } elsif ($suite eq 'jessie') {
-        @supp = ('9.4');
-        $pgversion = '9.4';
+       @supp = ('9.4');
+       $pgversion = '9.4';
     } elsif ($suite eq 'stretch') {
-        @supp = ('9.6');
-        $pgversion = '9.6';
+       @supp = ('9.6');
+       $pgversion = '9.6';
     } elsif ($suite eq 'buster') {
-        @supp = ('11');
-        $pgversion = '11';
+       @supp = ('11');
+       $pgversion = '11';
     } elsif ($suite eq 'bullseye') {
        @supp = ('13');
-       $pgversion = '13';
     } elsif ($suite eq 'bookworm') {
        # FIXME: update once froozen
-       @supp = ('13');
-       $pgversion = '13';
+       @supp = ('13', '14');
     }
-
     $pgversion = $opts->{version} if $opts->{version};
 
-    die "unsupported postgres version '$pgversion'\n" 
-       if !grep { $pgversion eq $_; } @supp;
-
-    my $rootdir = $self->{rootfs};
+    my $required;
+    if (defined($pgversion)) {
+       die "unsupported postgres version '$pgversion'\n" if !grep { $pgversion eq $_; } @supp;
 
-    my $required = $self->compute_required (["postgresql-$pgversion"]);
+       $required = $self->compute_required (["postgresql-$pgversion"]);
+    } else {
+       $required = $self->compute_required (["postgresql"]);
+    }
 
     $self->cache_packages ($required);
  
@@ -1817,7 +1848,7 @@ sub task_mysql {
     my $rootdir = $self->{rootfs};
 
     my $suite = $self->{config}->{suite};
-    
+
     my $ver = '5.0';
     if ($suite eq 'squeeze') {
       $ver = '5.1';
@@ -1863,7 +1894,7 @@ sub task_php {
     my $memlimit = $opts->{memlimit};
     my $rootdir = $self->{rootfs};
 
-    my $required = $self->compute_required ([qw (php5 php5-cli libapache2-mod-php5 php5-gd)]);
+    my $required = $self->compute_required([qw(php php-cli libapache2-mod-php php-gd)]);
 
     $self->cache_packages ($required);