inet_interfaces = loopback-only
recipient_delimiter = +
+compatibility_level = 2
+
EOD
# produce apt compatible filenames (/var/lib/apt/lists)
return $url;
}
+# defaults:
+# origin: debian
+# flags:
+# systemd: true (except for devuan ostypes)
+my $supported_suites = {
+ 'bookworm' => {
+ ostype => "debian-12",
+ },
+ 'bullseye' => {
+ ostype => "debian-11",
+ },
+ 'buster' => {
+ ostype => "debian-10",
+ },
+ 'stretch' => {
+ ostype => "debian-9.0",
+ },
+ 'jessie' => {
+ 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 (imply systemd = 0 default)
+ 'devuan-jessie' => {
+ suite => 'jessie',
+ ostype => "devuan-1.0",
+ },
+ 'devuan-ascii' => {
+ suite => 'ascii',
+ ostype => "devuan-2.0",
+ },
+ 'ascii' => {
+ ostype => "devuan-2.0",
+ },
+ 'beowulf' => {
+ ostype => "devuan-3.0",
+ },
+ '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',
+ },
+ 'vivid' => {
+ ostype => "ubuntu-15.04",
+ origin => 'ubuntu',
+ },
+ 'wily' => {
+ ostype => "ubuntu-15.10",
+ origin => 'ubuntu',
+ },
+ 'xenial' => {
+ ostype => "ubuntu-16.04",
+ origin => 'ubuntu',
+ },
+ 'yakkety' => {
+ ostype => "ubuntu-16.10",
+ origin => 'ubuntu',
+ },
+ 'zesty' => {
+ ostype => "ubuntu-17.04",
+ origin => 'ubuntu',
+ },
+ 'artful' => {
+ ostype => "ubuntu-17.10",
+ origin => 'ubuntu',
+ },
+ 'bionic' => {
+ ostype => "ubuntu-18.04",
+ origin => 'ubuntu',
+ },
+ 'cosmic' => {
+ ostype => "ubuntu-18.10",
+ origin => 'ubuntu',
+ },
+ 'disco' => {
+ ostype => "ubuntu-19.04",
+ origin => 'ubuntu',
+ },
+ 'eoan' => {
+ ostype => "ubuntu-19.10",
+ origin => 'ubuntu',
+ },
+ 'focal' => {
+ 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 {
+ my ($suite) = @_;
+
+ my $suiteinfo = $supported_suites->{$suite} || die "unsupported suite '$suite'!\n";
+
+ # set defaults
+ $suiteinfo->{origin} //= 'debian';
+ $suiteinfo->{suite} //= $suite;
+
+ $suiteinfo->{flags} //= {};
+ if ($suiteinfo->{ostype} =~ /^devuan/) {
+ $suiteinfo->{flags}->{systemd} //= 0;
+ } else {
+ $suiteinfo->{flags}->{systemd} //= 1;
+ }
+
+ return $suiteinfo;
+}
+
sub download {
my ($self, $url, $path) = @_;
my $ostype = $self->{config}->{ostype};
- if ($ostype =~ m/^debian-/) {
+ if ($ostype =~ m/^de(bi|vu)an-/) {
$data .= "lxc.include = /usr/share/lxc/config/debian.common.conf\n";
} elsif ($ostype =~ m/^ubuntu-/) {
$data .= "lxc.include = /usr/share/lxc/config/ubuntu.common.conf\n";
} else {
die "unknown os type '$ostype'\n";
}
- $data .= "lxc.utsname = localhost\n";
- $data .= "lxc.rootfs = $self->{rootfs}\n";
+ $data .= "lxc.uts.name = localhost\n";
+ $data .= "lxc.rootfs.path = $self->{rootfs}\n";
return $data;
}
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) = @_;
if $arch !~ m/^(i386|amd64)$/;
my $suite = $config->{suite} || die "no 'suite' specified\n";
- if ($suite eq 'jessie') {
- $config->{ostype} = "debian-8.0";
- } elsif ($suite eq 'wheezy') {
- $config->{ostype} = "debian-7.0";
- } elsif ($suite eq 'squeeze') {
- $config->{ostype} = "debian-6.0";
- } elsif ($suite eq 'lenny') {
- $config->{ostype} = "debian-5.0";
- } elsif ($suite eq 'etch') {
- $config->{ostype} = "debian-4.0";
- } elsif ($suite eq 'hardy') {
- $config->{ostype} = "ubuntu-8.04";
- } elsif ($suite eq 'intrepid') {
- $config->{ostype} = "ubuntu-8.10";
- } elsif ($suite eq 'jaunty') {
- $config->{ostype} = "ubuntu-9.04";
- } elsif ($suite eq 'precise') {
- $config->{ostype} = "ubuntu-12.04";
- } elsif ($suite eq 'trusty') {
- $config->{ostype} = "ubuntu-14.04";
- } elsif ($suite eq 'vivid') {
- $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";
- }
+
+ my $suiteinfo = get_suite_info($suite);
+ $suite = $suiteinfo->{suite};
+ $config->{ostype} = $suiteinfo->{ostype};
my $name = $config->{name} || die "no 'name' specified\n";
}
if (!$config->{source}) {
- if ($suite eq 'etch' || $suite eq 'lenny' || $suite eq 'squeeze' ||
- $suite eq 'wheezy' || $suite eq 'jessie' ) {
- push @{$config->{source}}, "http://ftp.debian.org/debian SUITE main contrib";
- push @{$config->{source}}, "http://ftp.debian.org/debian SUITE-updates main contrib"
- 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 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
- $suite eq 'trusty' || $suite eq 'precise') {
+ if (lc($suiteinfo->{origin}) eq 'debian') {
+ if ($suite eq 'etch' || $suite eq 'lenny') {
+ push @{$config->{source}}, (
+ '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",
+ "http://ftp.debian.org/debian SUITE-updates main contrib",
+ "http://security.debian.org SUITE/updates main contrib",
+ );
+ }
+ } elsif (lc($suiteinfo->{origin}) eq 'ubuntu') {
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";
- push @{$config->{source}}, "http://archive.ubuntu.com/ubuntu SUITE-security $comp";
+ push @{$config->{source}}, (
+ "http://archive.ubuntu.com/ubuntu SUITE $comp",
+ "http://archive.ubuntu.com/ubuntu SUITE-updates $comp",
+ "http://archive.ubuntu.com/ubuntu SUITE-security $comp",
+ );
} else {
die "implement me";
}
# 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') {
+ if (lc($suiteinfo->{origin}) eq 'ubuntu' && $suiteinfo->{flags}->{systemd}) {
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);
+ 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;
+ }
+ }
}
}
}
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();
$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";
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 {
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 = {};
$rec .= "\n";
my $res = {};
- while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
+ while ($rec =~ s/^([^:]+):\s+(.*?)\s*\n//) {
$res->{lc $1} = $2;
}
}
}
close($fh);
-
+
return $res;
}
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';
- $self->run_command ($cmd, $input);
+ 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);
}
}
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>)) {
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};
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};
# first, record provided packages
__record_provides ($pkginfo, $closure, $list, 1);
- my $pkgs = {};
+ my $pkghash = {};
+ my $pkglist = [];
# then resolve dependencies
foreach my $pname (@$list) {
- __closure_single ($pkginfo, $closure, $pkgs, $pname, $self->{excl});
+ __closure_single ($pkginfo, $closure, $pkghash, $pkglist, $pname, $self->{excl});
}
- return [ keys %$pkgs ];
+ return $pkglist;
}
sub __closure_single {
- my ($pkginfo, $closure, $pkgs, $pname, $excl) = @_;
+ my ($pkginfo, $closure, $pkghash, $pkglist, $pname, $excl) = @_;
$pname =~ s/^\s+//;
$pname =~ s/\s+$//;
my $url = $info->{url};
$url || die "$pname: no url for package '$pname'";
-
- $pkgs->{$pname} = 1;
+
+ if (!$pkghash->{$pname}) {
+ unshift @$pkglist, $pname;
+ $pkghash->{$pname} = 1;
+ }
__record_provides ($pkginfo, $closure, [$pname]) if $info->{provides};
#printf (STDERR "$pname: $p --> $found\n");
- __closure_single ($pkginfo, $closure, $pkgs, $found, $excl);
+ __closure_single ($pkginfo, $closure, $pkghash, $pkglist, $found, $excl);
}
}
my ($self, $script, $runlevel, $prio) = @_;
my $suite = $self->{config}->{suite};
+ my $suiteinfo = get_suite_info($suite);
my $rootdir = $self->{rootfs};
my $base = basename ($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') {
+ } 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";
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;
my $standard;
my $mta = $opts->{exim} ? 'exim' : 'postfix';
-
if ($mta eq 'postfix') {
push @$important, "postfix";
}
- foreach my $p (keys %$pkginfo) {
+ 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 !$pri;
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};
}
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
# extract required packages first
$self->logmsg ("create basic environment\n");
+
+ if ($self->can_usr_merge()) {
+ $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 -");
+ 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 -");
+ die "unexpected error for $p: no data.tar.{xz,gz,zst} found...";
}
}
# avoid warnings about non-existent resolv.conf
write_file ("", "$rootdir/etc/resolv.conf", 0644);
- if ($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";
write_file ($data, "$rootdir/etc/network/interfaces", 0644);
}
$self->ve_dpkg ('install', 'mawk');
$self->ve_dpkg ('install', 'debconf');
-
+
# unpack required packages
foreach my $p (@$required) {
$self->ve_dpkg ('unpack', $p);
$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");
}
# start loopback
- $self->ve_command ("ifconfig lo up");
+ if (-x "$rootdir/sbin/ifconfig") {
+ $self->ve_command ("ifconfig lo up");
+ } else {
+ $self->ve_command ("ip link set lo up");
+ }
$self->logmsg ("configure important packages\n");
$self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
$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");
}
}
my ($self) = @_;
my $veid = $self->{veid};
+ my $conffile = $self->{veconffile};
my $vestat = $self->ve_status();
}
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 {
my $instpkgs = $self->read_installed ();
my $closure = {};
- __record_provides ($pkginfo, $closure, [keys %$instpkgs]);
+ __record_provides($pkginfo, $closure, [keys $instpkgs->%*]);
return $self->closure ($closure, $pkglist);
}
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};
@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';
+ } elsif ($suite eq 'buster') {
+ @supp = ('11');
+ $pgversion = '11';
+ } elsif ($suite eq 'bullseye') {
+ @supp = ('13');
+ } elsif ($suite eq 'bookworm') {
+ # FIXME: update once froozen
+ @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);
$self->ve_dpkg ('install', @$required);
my $iscript = "postgresql-$pgversion";
- if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie') {
- $iscript = 'postgresql';
+ if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie' ||
+ $suite eq 'stretch') {
+ $iscript = 'postgresql';
}
$self->ve_command ("/etc/init.d/$iscript start") if $opts->{start};
my $rootdir = $self->{rootfs};
my $suite = $self->{config}->{suite};
-
+
my $ver = '5.0';
if ($suite eq 'squeeze') {
$ver = '5.1';
} elsif ($suite eq 'wheezy' || $suite eq 'jessie') {
$ver = '5.5';
+ } else {
+ die "task_mysql: unsupported suite '$suite'";
}
my $required = $self->compute_required (['mysql-common', "mysql-server-$ver"]);
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);