]> git.proxmox.com Git - dab.git/blobdiff - DAB.pm
constructor: factor out getting the target name
[dab.git] / DAB.pm
diff --git a/DAB.pm b/DAB.pm
index 668a044ce8b183f4be788164de7217740b5c8e79..b85d0a60a87ec7373a8c008c35573142f621cdb4 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -521,28 +521,34 @@ sub setup_usr_merge {
     }
 }
 
+sub get_target_name {
+    my ($config) = @_;
+
+    my $name = $config->{name} || die "no 'name' specified\n";
+    $name =~ m/^[a-z][0-9a-z\-\*\.]+$/ || die "illegal characters in name '$name'\n";
+
+    my ($version, $arch, $ostype) = $config->@{'version', 'architecture', 'ostype'};
+    $name = "${ostype}-${name}" if $name !~ m/^$ostype/;
+
+    return "${name}_${version}_${arch}"
+}
+
 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,24 +556,13 @@ sub new {
     $suite = $suiteinfo->{suite};
     $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";
-
-    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}";
+    # assert required dab.conf keys exist
+    for my $key (qw(version section headline maintainer)) {
+       die "no '$key' specified\n" if !$config->{$key};
     }
 
+    $self->{targetname} = get_target_name($config);
+
     if (!$config->{source}) {
        if (lc($suiteinfo->{origin}) eq 'debian') {
            if ($suite eq 'etch' || $suite eq 'lenny') {
@@ -575,10 +570,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 {
@@ -640,9 +635,7 @@ sub new {
            die "syntax error in mirror spezification '$m'\n";
        }
     }
-
     $self->{sources} = $sources;
-
     $self->{infodir} = "info";
 
     $self->__allocate_ve();
@@ -650,12 +643,9 @@ sub new {
     $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)];
 
-    # 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 libdrm-common libdrm2 libplymouth5 plymouth plymouth-theme-ubuntu-text powermgmt-base);
@@ -883,9 +873,9 @@ sub finalize {
     my $compressor2cmd_map = {
        gz => 'gzip',
        gzip => 'gzip',
-       zst => 'zstd -9',
-       zstd => 'zstd -9',
-       'zstd-max' => 'zstd -19 -T0', # maximal level where the decompressor can still run efficiently
+       zst => 'zstd --rm -9',
+       zstd => 'zstd --rm -9',
+       'zstd-max' => 'zstd --rm -19 -T0', # maximal level where the decompressor can still run efficiently
     };
     my $compressor2ending = {
        gzip => 'gz',