]> git.proxmox.com Git - dab.git/blobdiff - DAB.pm
debian: future proof mirror selection for trixie and forky
[dab.git] / DAB.pm
diff --git a/DAB.pm b/DAB.pm
index ac1dadbdbea767907be0877a9bb2ea0798abe3b7..2b84c89b4161fd77dfb00083c9aad9621d874bcf 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -220,6 +220,10 @@ my $supported_suites = {
        ostype => "ubuntu-22.04",
        origin => 'ubuntu',
     },
+    'kinetic' => {
+       ostype => "ubuntu-22.10",
+       origin => 'ubuntu',
+    },
 };
 
 sub get_suite_info {
@@ -243,15 +247,12 @@ sub get_suite_info {
 
 sub download {
     my ($self, $url, $path) = @_;
+    my $tmpfn = "$path.tmp$$";
 
     $self->logmsg ("download: $url\n");
-    my $tmpfn = "$path.tmp$$";
-    eval {
-       $self->run_command ("wget -q '$url'  -O '$tmpfn'"); 
-    };
 
-    my $err = $@;
-    if ($err) {
+    eval { $self->run_command ("wget -q '$url'  -O '$tmpfn'") };
+    if (my $err = $@) {
        unlink $tmpfn;
        die $err;
     }
@@ -370,7 +371,7 @@ sub run_command {
     print $writer $input if defined $input;
     close $writer;
 
-    my $select = new IO::Select;
+    my $select = IO::Select->new();
     $select->add ($reader);
     $select->add ($error);
 
@@ -524,24 +525,18 @@ sub new {
     my ($class, $config) = @_;
 
     $class = ref ($class) || $class;
-
-    my $self = {};
-
     $config = read_config ('dab.conf') if !$config;
 
-    $self->{config} = $config;
-
+    my $self = {
+       config => $config,
+    };
     bless $self, $class;
 
     $self->{logfile} = "logfile";
-    $self->{logfd} = IO::File->new (">>$self->{logfile}") ||
-       die "unable to open log file";
-
-    my $arch = $config->{architecture};
-    die "no 'architecture' specified\n" if !$arch;
+    $self->{logfd} = IO::File->new (">>$self->{logfile}") || die "unable to open log file";
 
-    die "unsupported architecture '$arch'\n" 
-       if $arch !~ m/^(i386|amd64)$/;
+    my $arch = $config->{architecture} ||die "no 'architecture' specified\n";
+    die "unsupported architecture '$arch'\n" if $arch !~ m/^(i386|amd64)$/;
 
     my $suite = $config->{suite} || die "no 'suite' specified\n";
 
@@ -550,21 +545,18 @@ sub new {
     $config->{ostype} = $suiteinfo->{ostype};
 
     my $name = $config->{name} || die "no 'name' specified\n";
+    $name =~ m/^[a-z][0-9a-z\-\*\.]+$/ || die "illegal characters in name '$name'\n";
 
-    $name =~ m/^[a-z][0-9a-z\-\*\.]+$/ || 
-       die "illegal characters in name '$name'\n";
-
+    # assert required dab.conf keys exist
+    for my $key (qw(version section headline maintainer)) {
+       die "no '$key' specified\n" if !$config->{$key};
+    }
     my $version = $config->{version};
-    die "no 'version' specified\n" if !$version;
-    die "no 'section' specified\n" if !$config->{section};
-    die "no 'description' specified\n" if !$config->{headline};
-    die "no 'maintainer' specified\n" if !$config->{maintainer};
 
     if ($name =~ m/^$config->{ostype}/) {
        $self->{targetname} = "${name}_${version}_$config->{architecture}";
     } else {
-       $self->{targetname} = "$config->{ostype}-${name}_" .
-           "${version}_$config->{architecture}";
+       $self->{targetname} = "$config->{ostype}-${name}_${version}_$config->{architecture}";
     }
 
     if (!$config->{source}) {
@@ -574,10 +566,10 @@ sub new {
                    'http://ftp.debian.org/debian SUITE main contrib',
                    'http://security.debian.org SUITE/updates main contrib',
                );
-           } elsif ($suite eq 'bullseye' || $suite eq 'bookworm') {
+           } elsif ($suite =~ /^(?:bullseye|bookworm|trixie|forky)$/) {
                push @{$config->{source}}, (
-                   "http://ftp.debian.org/debian SUITE main contrib",
-                   "http://ftp.debian.org/debian SUITE-updates main contrib",
+                   "http://deb.debian.org/debian SUITE main contrib",
+                   "http://deb.debian.org/debian SUITE-updates main contrib",
                    "http://security.debian.org SUITE-security main contrib",
                );
            } else {
@@ -639,26 +631,20 @@ sub new {
            die "syntax error in mirror spezification '$m'\n";
        }
     }
-
     $self->{sources} = $sources;
-
     $self->{infodir} = "info";
 
-    $self->__allocate_ve ();
+    $self->__allocate_ve();
 
     $self->{cachedir} = ($config->{cachedir} || 'cache')  . "/$suite";;
 
     my $incl = [qw (less ssh openssh-server logrotate)];
+    my $excl = [qw (modutils reiserfsprogs ppp pppconfig pppoe pppoeconf nfs-common mtools ntp)];
 
-    my $excl = [qw (modutils reiserfsprogs ppp pppconfig pppoe
-                   pppoeconf nfs-common mtools ntp)];
-
-    # ubuntu has too many dependencies on udev, so
-    # we cannot exclude it (instead we disable udevd)
-
+    # ubuntu has too many dependencies on udev, so we cannot exclude it (instead we disable udevd)
     if (lc($suiteinfo->{origin}) eq 'ubuntu' && $suiteinfo->{flags}->{systemd}) {
        push @$incl, 'isc-dhcp-client';
-       push @$excl, qw(libmodule-build-perl);
+       push @$excl, qw(libmodule-build-perl libdrm-common libdrm2 libplymouth5 plymouth plymouth-theme-ubuntu-text powermgmt-base);
        if ($suite eq 'jammy') {
            push @$excl, qw(fuse); # avoid fuse2 <-> fuse3 conflict
        }
@@ -668,11 +654,10 @@ sub new {
        push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+ ubuntu-standard);
     } elsif ($suite eq 'hardy') {
        push @$excl, qw(kbd);
-       push @$excl, qw(apparmor apparmor-utils ntfs-3g
-                       friendly-recovery);
+       push @$excl, qw(apparmor apparmor-utils ntfs-3g friendly-recovery);
     } elsif ($suite eq 'intrepid' || $suite eq 'jaunty') {
-       push @$excl, qw(apparmor apparmor-utils libapparmor1 libapparmor-perl 
-                       libntfs-3g28 ntfs-3g friendly-recovery);
+       push @$excl, qw(apparmor apparmor-utils libapparmor1 libapparmor-perl libntfs-3g28);
+       push @$excl, qw(ntfs-3g friendly-recovery);
     } elsif ($suite eq 'jessie') {
        push @$incl, 'sysvinit-core'; # avoid systemd and udev
        push @$incl, 'libperl4-corelibs-perl'; # to make lsof happy
@@ -854,14 +839,9 @@ sub finalize {
     $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
 
     unlink "$rootdir/sbin/defenv";
-
     unlink <$rootdir/root/dead.letter*>;
-
     unlink "$rootdir/var/log/init.log";
-
-    unlink "$rootdir/aquota.group";
-
-    unlink "$rootdir/aquota.user";
+    unlink "$rootdir/aquota.group", "$rootdir/aquota.user";
 
     write_file ("", "$rootdir/var/log/syslog");
 
@@ -925,11 +905,11 @@ sub read_installed {
 
     my $pkgfilelist = "$rootdir/var/lib/dpkg/status";
     local $/ = '';
-    open (PKGLST, "<$pkgfilelist") or die "unable to open '$pkgfilelist' - $!";
+    open(my $PKGLST, '<', $pkgfilelist) or die "unable to open '$pkgfilelist' - $!";
 
     my $pkglist = {};
 
-    while (my $rec = <PKGLST>) {
+    while (my $rec = <$PKGLST>) {
        chomp $rec;
        $rec =~ s/\n\s+/ /g;
        $rec .= "\n";
@@ -949,7 +929,7 @@ sub read_installed {
        }
     }
 
-    close (PKGLST);    
+    close ($PKGLST);
 
     return $pkglist;
 }
@@ -1126,17 +1106,16 @@ sub __parse_packages {
     my ($pkginfo, $filename, $src) = @_;
 
     local $/ = '';
-    open (PKGLST, "<$filename") ||
-       die "unable to open '$filename'";
+    open(my $PKGLST, '<', $filename) or die "unable to open '$filename' - $!";
 
-    while (my $rec = <PKGLST>) {
+    while (my $rec = <$PKGLST>) {
        $rec =~ s/\n\s+/ /g;
        chomp $rec;
        $rec .= "\n";
 
        my $res = {};
 
-       while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
+       while ($rec =~ s/^([^:]+):\s+(.*?)\s*\n//) {
            $res->{lc $1} = $2;
        }
 
@@ -1158,7 +1137,7 @@ sub __parse_packages {
        }
     }
 
-    close (PKGLST);    
+    close ($PKGLST);
 }
 
 sub pkginfo {
@@ -1900,15 +1879,35 @@ sub task_php {
 
     my $memlimit = $opts->{memlimit};
     my $rootdir = $self->{rootfs};
+    my $suite = $self->{config}->{suite};
 
-    my $required = $self->compute_required([qw(php php-cli libapache2-mod-php php-gd)]);
+    my $base_set = [qw(php-cli libapache2-mod-php php-gd)];
+    if ($suite =~ /(?:squeeze|wheezy|jessie)$/) {
+       $self->logmsg("WARN: using EOL php release on EOL suite");
+       $base_set = [qw(php5 php5-cli libapache2-mod-php5 php5-gd)];
+    }
+    my $required = $self->compute_required($base_set);
 
     $self->cache_packages ($required);
 
     $self->ve_dpkg ('install', @$required);
 
     if ($memlimit) {
-       $self->run_command ("sed -e 's/^\\s*memory_limit\\s*=.*;/memory_limit = ${memlimit}M;/' -i $rootdir/etc/php5/apache2/php.ini");
+       my $sed_cmd = ['sed', '-e', "s/^\\s*memory_limit\\s*=.*;/memory_limit = ${memlimit}M;/", '-i'];
+       if ($suite =~ /(?:squeeze|wheezy|jessie)$/) {
+           push @$sed_cmd, "$rootdir/etc/php5/apache2/php.ini";
+       } else {
+           my $found = 0;
+           for my $fn (glob("'${rootdir}/etc/php/*/apache2/php.ini'")) {
+               push @$sed_cmd, "$rootdir/$fn";
+               $found = 1;
+           }
+           if (!$found) {
+               warn "WARN: did not found any php.ini to set the memlimit!\n";
+               return;
+           }
+       }
+       $self->run_command($sed_cmd);
     }
 }
 
@@ -1916,7 +1915,7 @@ sub install {
     my ($self, $pkglist, $unpack) = @_;
 
     my $required = $self->compute_required ($pkglist);
-    
+
     $self->cache_packages ($required);
 
     $self->ve_dpkg ($unpack ? 'unpack' : 'install', @$required);