# defaults:
# origin: debian
my $supported_suites = {
+ 'bookworm' => {
+ ostype => "debian-12",
+ },
'bullseye' => {
- ostype => "debian-11.0",
+ ostype => "debian-11",
},
'buster' => {
- ostype => "debian-10.0",
+ ostype => "debian-10",
},
'stretch' => {
ostype => "debian-9.0",
'ascii' => {
ostype => "devuan-2.0",
},
+ 'beowulf' => {
+ ostype => "devuan-3.0",
+ },
+ 'chimaera' => {
+ ostype => "devuan-4.0",
+ },
# UBUNTU
'hardy' => {
ostype => "ubuntu-20.04",
origin => 'ubuntu',
},
+ 'groovy' => {
+ ostype => "ubuntu-20.10",
+ origin => 'ubuntu',
+ },
+ 'hirsute' => {
+ ostype => "ubuntu-21.04",
+ origin => 'ubuntu',
+ },
+ 'impish' => {
+ ostype => "ubuntu-21.10",
+ origin => 'ubuntu',
+ },
};
sub get_suite_info {
return $self->{veid};
}
+# just use some simple heuristic for now, merge usr for releases newer than ubuntu 21.x or debian 11
+sub can_usr_merge {
+ my ($self) = @_;
+
+ my $ostype = $self->{config}->{ostype};
+
+ # FIXME: add configuration override posibillity
+
+ if ($ostype =~ m/^debian-(\d+)/) {
+ return int($1) >= 11;
+ } elsif ($ostype =~ m/^ubuntu-(\d+)/) {
+ return int($1) >= 21;
+ }
+ return; # false
+}
+
+sub setup_usr_merge {
+ my ($self) = @_;
+
+ my $rootfs = $self->{rootfs};
+ my $arch = $self->{config}->{architecture};
+
+ # similar to https://salsa.debian.org/installer-team/debootstrap/-/blob/master/functions#L1354
+ my @merged_dirs = qw(bin sbin lib);
+
+ if ($arch eq 'amd64') {
+ push @merged_dirs, qw(lib32 lib64 libx32);
+ } elsif ($arch eq 'i386') {
+ push @merged_dirs, qw(lib64 libx32);
+ }
+
+ $self->logmsg ("setup usr-merge symlinks for '" . join("', '", @merged_dirs) . "'\n");
+
+ for my $dir (@merged_dirs) {
+ symlink("usr/$dir", "$rootfs/$dir") or warn "could not create symlink - $!\n";
+ mkpath "$rootfs/usr/$dir";
+ }
+}
+
sub new {
my ($class, $config) = @_;
'http://ftp.debian.org/debian SUITE main contrib',
'http://security.debian.org SUITE/updates main contrib',
);
+ } elsif ($suite eq 'bullseye' || $suite eq 'bookworm') {
+ push @{$config->{source}}, (
+ "http://ftp.debian.org/debian SUITE main contrib",
+ "http://ftp.debian.org/debian SUITE-updates main contrib",
+ "http://security.debian.org SUITE-security main contrib",
+ );
} else {
push @{$config->{source}}, (
"http://ftp.debian.org/debian SUITE main contrib",
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 'eoan' || $suite eq 'focal' || $suite eq 'groovy'
+ || $suite eq 'hirsute' || $suite eq 'impish'
+ ) {
push @$incl, 'isc-dhcp-client';
push @$excl, qw(libmodule-build-perl);
} elsif ($suite eq 'trusty') {
} elsif ($suite eq 'jessie') {
push @$incl, 'sysvinit-core'; # avoid systemd and udev
push @$incl, 'libperl4-corelibs-perl'; # to make lsof happy
- push @$excl, qw(systemd systemd-sysv udev module-init-tools pciutils hdparm
- memtest86+ parted);
- } elsif ($suite eq 'stretch' || $suite eq 'buster' || $suite eq 'bullseye') {
- push @$excl, qw(module-init-tools pciutils hdparm
- memtest86+ parted);
+ push @$excl, qw(systemd systemd-sysv udev module-init-tools pciutils hdparm memtest86+ parted);
+ } elsif ($suite eq 'stretch' || $suite eq 'buster' || $suite eq 'bullseye' || $suite eq 'bookworm') {
+ push @$excl, qw(module-init-tools pciutils hdparm memtest86+ parted);
} else {
- push @$excl, qw(udev module-init-tools pciutils hdparm
- memtest86+ parted);
+ push @$excl, qw(udev module-init-tools pciutils hdparm memtest86+ parted);
}
$self->{incl} = $incl;
my $logfd = $self->{logfd} = IO::File->new (">$self->{logfile}") ||
die "unable to open log file";
+ my $COMPRESSORS = [
+ {
+ ext => 'xz',
+ decomp => 'xz -d',
+ },
+ {
+ ext => 'gz',
+ decomp => 'gzip -d',
+ },
+ ];
+
foreach my $ss (@{$self->{sources}}) {
my $src = $ss->{mirror} || $ss->{source};
my $path = "dists/$ss->{suite}/Release";
print $logfd $@;
warn "Release info ignored\n";
};
+
foreach my $comp (@{$ss->{comp}}) {
- $path = "dists/$ss->{suite}/$comp/binary-$arch/Packages.gz";
- $target = "$infodir/" . __url_to_filename ("$ss->{source}/$path");
- my $pkgsrc = "$src/$path";
- $self->download ($pkgsrc, $target);
- $self->run_command ("gzip -d '$target'");
+ foreach my $compressor (@$COMPRESSORS) {
+ $path = "dists/$ss->{suite}/$comp/binary-$arch/Packages.$compressor->{ext}";
+ $target = "$infodir/" . __url_to_filename ("$ss->{source}/$path");
+ my $pkgsrc = "$src/$path";
+ eval {
+ $self->download ($pkgsrc, $target);
+ $self->run_command ("$compressor->{decomp} '$target'");
+ };
+ if (my $err = $@) {
+ print $logfd "could not download Packages.$compressor->{ext}\n";
+ } else {
+ last;
+ }
+ }
}
}
}
write_file ("", "$rootdir/var/log/syslog");
- $self->logmsg ("detecting final size: ");
+ my $get_path_size = sub {
+ my ($path) = @_;
+ my $sizestr = $self->run_command ("du -sm $path", undef, 1);
+ if ($sizestr =~ m/^(\d+)\s+\Q$path\E$/) {
+ return int($1);
+ } else {
+ die "unable to detect size for '$path'\n";
+ }
+ };
- my $sizestr = $self->run_command ("du -sm $rootdir", undef, 1);
- my $size;
- if ($sizestr =~ m/^(\d+)\s+\Q$rootdir\E$/) {
- $size = $1;
- } else {
- die "unable to detect size\n";
- }
+ $self->logmsg ("detecting final appliance size: ");
+ my $size = $get_path_size->($rootdir);
$self->logmsg ("$size MB\n");
$self->write_config ("$rootdir/etc/appliance.info", $size);
$self->logmsg ("creating final appliance archive\n");
my $target = "$self->{targetname}.tar";
+
+ my $compressor = $opts->{compressor} // 'gz';
+ 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
+ };
+ my $compressor2ending = {
+ gzip => 'gz',
+ zstd => 'zst',
+ 'zstd-max' => 'zst',
+ };
+ my $compressor_cmd = $compressor2cmd_map->{$compressor};
+ die "unkown compressor '$compressor', use one of: ". join(', ', sort keys %$compressor2cmd_map)
+ if !defined($compressor_cmd);
+
+ my $ending = $compressor2ending->{$compressor} // $compressor;
+ my $final_archive = "${target}.${ending}";
unlink $target;
- unlink "$target.gz";
+ unlink $final_archive;
$self->run_command ("tar cpf $target --numeric-owner -C '$rootdir' ./etc/appliance.info");
$self->run_command ("tar rpf $target --numeric-owner -C '$rootdir' --exclude ./etc/appliance.info .");
- $self->run_command ("gzip $target");
+ $self->run_command ("$compressor_cmd $target");
+
+ $self->logmsg ("detecting final commpressed appliance size: ");
+ $size = $get_path_size->($final_archive);
+ $self->logmsg ("$size MB\n");
+
+ $self->logmsg ("appliance archive: $final_archive\n");
}
sub read_installed {
} 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 'eoan' || $suite eq 'focal' || $suite eq 'groovy'
+ || $suite eq 'hirsute' || $suite eq 'impish'
+ ) {
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";
my $standard;
my $mta = $opts->{exim} ? 'exim' : 'postfix';
-
if ($mta eq 'postfix') {
push @$important, "postfix";
}
+ if ($opts->{include}) {
+ push @$important, split(',', $opts->{include});
+ }
+
+ my $exclude = {};
+ if ($opts->{exclude}) {
+ $exclude->{$_} = 1 for split(',', $opts->{exclude});
+ }
+
foreach my $p (sort keys %$pkginfo) {
next if grep { $p eq $_ } @{$self->{excl}};
my $pri = $pkginfo->{$p}->{priority};
next if $p =~ m/(selinux|semanage|policycoreutils)/;
push @$required, $p if $pri eq 'required';
+ next if $exclude->{$p};
push @$important, $p if $pri eq 'important';
push @$standard, $p if $pri eq 'standard' && !$opts->{minimal};
}
# extract required packages first
$self->logmsg ("create basic environment\n");
+
+ if ($self->can_usr_merge()) {
+ $self->setup_usr_merge();
+ }
+
+ $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 -");
+ $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.xz | tar -C '$rootdir' -xJf - --keep-directory-symlink");
} else {
- $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf -");
+ $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf - --keep-directory-symlink");
}
}
# avoid warnings about non-existent resolv.conf
write_file ("", "$rootdir/etc/resolv.conf", 0644);
- if ($suite eq 'focal' || $suite eq 'eoan' || $suite eq 'disco' || $suite eq 'cosmic' ||
+ 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') {
+ $suite eq 'wily'
+ ) {
# no need to configure loopback device
} else {
$data = "auto lo\niface lo inet loopback\n";
$self->run_command ($cmd);
}
- if ($suite eq 'intrepid') {
+ if ($suite eq 'intrepid' || $suite eq 'jaunty') {
# remove sysctl setup (avoid warnings at startup)
my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
- $filelist .= " $rootdir/etc/sysctl.d/10-process-security.conf";
+ $filelist .= " $rootdir/etc/sysctl.d/10-process-security.conf" if $suite eq 'intrepid';
$filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
$self->run_command ("rm $filelist");
}
- if ($suite eq 'jaunty') {
- # remove sysctl setup (avoid warnings at startup)
- my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
- $filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
- $self->run_command ("rm $filelist");
+
+ if (-e "$rootdir/lib/systemd/system/sys-kernel-config.mount") {
+ $self->ve_command ("ln -s /dev/null /etc/systemd/system/sys-kernel-debug.mount");
}
}
@supp = ('11');
$pgversion = '11';
} elsif ($suite eq 'bullseye') {
- # FIXME update on freeze!
- @supp = ('12');
- $pgversion = '12';
+ @supp = ('13');
+ $pgversion = '13';
+ } elsif ($suite eq 'bookworm') {
+ # FIXME: update once froozen
+ @supp = ('13');
+ $pgversion = '13';
}
$pgversion = $opts->{version} if $opts->{version};