11 use POSIX qw
(LONG_MAX
);
15 # fixme: lock container ?
17 my $dablibdir = "/usr/lib/dab";
18 my $devicetar = "$dablibdir/devices.tar.gz";
19 my $default_env = "$dablibdir/scripts/defenv";
20 my $fake_init = "$dablibdir/scripts/init.pl";
21 my $script_ssh_init = "$dablibdir/scripts/ssh_gen_host_keys";
22 my $script_mysql_randompw = "$dablibdir/scripts/mysql_randompw";
23 my $script_init_urandom = "$dablibdir/scripts/init_urandom";
25 my $postfix_main_cf = <<EOD;
26 # See /usr/share/postfix/main.cf.dist for a commented, more complete version
28 smtpd_banner = \$myhostname ESMTP \$mail_name (Debian/GNU)
31 # appending .domain is the MUA's job.
32 append_dot_mydomain = no
34 # Uncomment the next line to generate "delayed mail" warnings
35 #delay_warning_time = 4h
37 alias_maps = hash:/etc/aliases
38 alias_database = hash:/etc/aliases
39 mydestination = \$myhostname, localhost.\$mydomain, localhost
41 mynetworks = 127.0.0.0/8
42 inet_interfaces = loopback-only
43 recipient_delimiter = +
47 # produce apt compatible filenames (/var/lib/apt/lists)
48 sub __url_to_filename
{
59 my ($self, $url, $path) = @_;
61 $self->logmsg ("download: $url\n");
62 my $tmpfn = "$path.tmp$$";
64 $self->run_command ("wget -q '$url' -O '$tmpfn'");
73 rename ($tmpfn, $path);
77 my ($data, $file, $perm) = @_;
79 die "no filename" if !$file;
83 my $fh = IO
::File-
>new ($file, O_WRONLY
| O_CREAT
, $perm) ||
84 die "unable to open file '$file'";
94 die "no filename" if !$file;
96 my $fh = IO
::File-
>new ($file) ||
97 die "unable to open file '$file'";
99 local $/; # slurp mode
113 my $fh = IO
::File-
>new ("<$filename") || return $res;
116 while (defined (my $line = <$fh>)) {
117 next if $line =~ m/^\#/;
118 next if $line =~ m/^\s*$/;
128 if ($rec =~ s/^Description:\s*([^\n]*)(\n\s+.*)*$//si) {
129 $res->{headline
} = $1;
130 chomp $res->{headline
};
133 $res->{description
} = $long;
134 chomp $res->{description
};
135 } elsif ($rec =~ s/^([^:]+):\s*(.*\S)\s*\n//) {
136 my ($key, $value) = (lc ($1), $2);
137 if ($key eq 'source' || $key eq 'mirror') {
138 push @{$res->{$key}}, $value;
140 die "duplicate key '$key'\n" if defined ($res->{$key});
141 $res->{$key} = $value;
144 die "unable to parse config file: $rec";
148 die "unable to parse config file" if $rec;
154 my ($self, $cmd, $input, $getoutput) = @_;
156 my $reader = IO
::File-
>new();
157 my $writer = IO
::File-
>new();
158 my $error = IO
::File-
>new();
162 my $cmdstr = ref ($cmd) eq 'ARRAY' ?
join (' ', @$cmd) : $cmd;
166 if (ref ($cmd) eq 'ARRAY') {
167 $pid = open3
($writer, $reader, $error, @$cmd) || die $!;
169 $pid = open3
($writer, $reader, $error, $cmdstr) || die $!;
176 if ($orig_pid != $$) {
177 $self->logmsg ("ERROR: command '$cmdstr' failed - fork failed\n");
184 print $writer $input if defined $input;
187 my $select = new IO
::Select
;
188 $select->add ($reader);
189 $select->add ($error);
192 my $logfd = $self->{logfd
};
194 while ($select->count) {
195 my @handles = $select->can_read ();
197 foreach my $h (@handles) {
199 my $count = sysread ($h, $buf, 4096);
200 if (!defined ($count)) {
202 die "command '$cmdstr' failed: $!";
204 $select->remove ($h) if !$count;
208 $res .= $buf if $getoutput;
215 die "command '$cmdstr' failed with exit code $ec\n" if $ec;
223 $self->writelog (@_);
228 my $fd = $self->{logfd
};
232 sub __sample_config
{
236 my $arch = $self->{config
}->{architecture
};
238 my $ostype = $self->{config
}->{ostype
};
240 if ($ostype =~ m/^debian-/) {
241 $data .= "lxc.include = /usr/share/lxc/config/debian.common.conf\n";
242 } elsif ($ostype =~ m/^ubuntu-/) {
243 $data .= "lxc.include = /usr/share/lxc/config/ubuntu.common.conf\n";
245 die "unknown os type '$ostype'\n";
247 $data .= "lxc.utsname = localhost\n";
248 $data .= "lxc.rootfs = $self->{rootfs}\n";
257 if (my $fd = IO
::File-
>new (".veid")) {
264 $self->{working_dir
} = getcwd
;
265 $self->{veconffile
} = "$self->{working_dir}/config";
266 $self->{rootfs
} = "$self->{working_dir}/rootfs";
269 $self->{veid
} = $cid;
275 UUID
::generate
($uuid);
276 UUID
::unparse
($uuid, $uuid_str);
277 $self->{veid
} = $uuid_str;
279 my $fd = IO
::File-
>new (">.veid") ||
280 die "unable to write '.veid'\n";
281 print $fd "$self->{veid}\n";
284 my $cdata = $self->__sample_config();
286 my $fh = IO
::File-
>new ($self->{veconffile
}, O_WRONLY
|O_CREAT
|O_EXCL
) ||
287 die "unable to write lxc config file '$self->{veconffile}' - $!";
291 mkdir $self->{rootfs
} || die "unable to create rootfs - $!";
293 $self->logmsg ("allocated VE $self->{veid}\n");
295 return $self->{veid
};
299 my ($class, $config) = @_;
301 $class = ref ($class) || $class;
305 $config = read_config
('dab.conf') if !$config;
307 $self->{config
} = $config;
311 $self->{logfile
} = "logfile";
312 $self->{logfd
} = IO
::File-
>new (">>$self->{logfile}") ||
313 die "unable to open log file";
315 my $arch = $config->{architecture
};
316 die "no 'architecture' specified\n" if !$arch;
318 die "unsupported architecture '$arch'\n"
319 if $arch !~ m/^(i386|amd64)$/;
321 my $suite = $config->{suite
} || die "no 'suite' specified\n";
322 if ($suite eq 'stretch') {
323 $config->{ostype
} = "debian-9.0";
324 } elsif ($suite eq 'jessie') {
325 $config->{ostype
} = "debian-8.0";
326 } elsif ($suite eq 'wheezy') {
327 $config->{ostype
} = "debian-7.0";
328 } elsif ($suite eq 'squeeze') {
329 $config->{ostype
} = "debian-6.0";
330 } elsif ($suite eq 'lenny') {
331 $config->{ostype
} = "debian-5.0";
332 } elsif ($suite eq 'etch') {
333 $config->{ostype
} = "debian-4.0";
334 } elsif ($suite eq 'hardy') {
335 $config->{ostype
} = "ubuntu-8.04";
336 } elsif ($suite eq 'intrepid') {
337 $config->{ostype
} = "ubuntu-8.10";
338 } elsif ($suite eq 'jaunty') {
339 $config->{ostype
} = "ubuntu-9.04";
340 } elsif ($suite eq 'precise') {
341 $config->{ostype
} = "ubuntu-12.04";
342 } elsif ($suite eq 'trusty') {
343 $config->{ostype
} = "ubuntu-14.04";
344 } elsif ($suite eq 'vivid') {
345 $config->{ostype
} = "ubuntu-15.04";
346 } elsif ($suite eq 'wily') {
347 $config->{ostype
} = "ubuntu-15.10";
348 } elsif ($suite eq 'xenial') {
349 $config->{ostype
} = "ubuntu-16.04";
350 } elsif ($suite eq 'yakkety') {
351 $config->{ostype
} = "ubuntu-16.10";
352 } elsif ($suite eq 'zesty') {
353 $config->{ostype
} = "ubuntu-17.04";
354 } elsif ($suite eq 'artful') {
355 $config->{ostype
} = "ubuntu-17.10";
357 die "unsupported debian suite '$suite'\n";
360 my $name = $config->{name
} || die "no 'name' specified\n";
362 $name =~ m/^[a-z][0-9a-z\-\*\.]+$/ ||
363 die "illegal characters in name '$name'\n";
365 my $version = $config->{version
};
366 die "no 'version' specified\n" if !$version;
367 die "no 'section' specified\n" if !$config->{section
};
368 die "no 'description' specified\n" if !$config->{headline
};
369 die "no 'maintainer' specified\n" if !$config->{maintainer
};
371 if ($name =~ m/^$config->{ostype}/) {
372 $self->{targetname
} = "${name}_${version}_$config->{architecture}";
374 $self->{targetname
} = "$config->{ostype}-${name}_" .
375 "${version}_$config->{architecture}";
378 if (!$config->{source
}) {
379 if ($suite eq 'etch' || $suite eq 'lenny') {
380 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE main contrib";
381 push @{$config->{source
}}, "http://security.debian.org SUITE/updates main contrib";
382 } elsif ($suite eq 'squeeze' || $suite eq 'wheezy' ||
383 $suite eq 'jessie' || $suite eq 'stretch' ) {
384 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE main contrib";
385 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE-updates main contrib";
386 push @{$config->{source
}}, "http://security.debian.org SUITE/updates main contrib";
387 } elsif ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty' ||
388 $suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
389 $suite eq 'trusty' || $suite eq 'precise' || $suite eq 'yakkety' ||
390 $suite eq 'zesty' || $suite eq 'artful' ) {
391 my $comp = "main restricted universe multiverse";
392 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE $comp";
393 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE-updates $comp";
394 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE-security $comp";
402 foreach my $s (@{$config->{source
}}) {
403 if ($s =~ m
@^\s*((http
|ftp
)://\S
+)\s
+(\S
+)((\s
+(\S
+))+)$@) {
404 my ($url, $su, $components) = ($1, $3, $4);
405 $su =~ s/SUITE/$suite/;
406 $components =~ s/^\s+//;
407 $components =~ s/\s+$//;
409 foreach my $co (split (/\s+/, $components)) {
412 $ca = ['main'] if !$ca;
420 die "syntax error in source spezification '$s'\n";
424 foreach my $m (@{$config->{mirror
}}) {
425 if ($m =~ m
@^\s*((http
|ftp
)://\S
+)\s
*=>\s
*((http
|ftp
)://\S
+)\s
*$@) {
426 my ($ms, $md) = ($1, $3);
428 foreach my $ss (@$sources) {
429 if ($ss->{source
} eq $ms) {
435 die "unusable mirror $ms\n" if !$found;
437 die "syntax error in mirror spezification '$m'\n";
441 $self->{sources
} = $sources;
443 $self->{infodir
} = "info";
445 $self->__allocate_ve ();
447 $self->{cachedir
} = ($config->{cachedir
} || 'cache') . "/$suite";;
449 my $incl = [qw
(less ssh openssh-server logrotate
)];
451 my $excl = [qw
(modutils reiserfsprogs ppp pppconfig pppoe
452 pppoeconf nfs-common mtools ntp
)];
454 # ubuntu has too many dependencies on udev, so
455 # we cannot exclude it (instead we disable udevd)
457 if ($suite eq 'vivid' || $suite eq 'wily' || $suite eq 'xenial' ||
458 $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful') {
459 push @$incl, 'isc-dhcp-client';
460 push @$excl, qw(libmodule-build-perl);
461 } elsif ($suite eq 'trusty') {
462 push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+);
463 } elsif ($suite eq 'precise') {
464 push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+ ubuntu-standard);
465 } elsif ($suite eq 'hardy') {
466 push @$excl, qw(kbd);
467 push @$excl, qw(apparmor apparmor-utils ntfs-3g
469 } elsif ($suite eq 'intrepid' || $suite eq 'jaunty') {
470 push @$excl, qw(apparmor apparmor-utils libapparmor1 libapparmor-perl
471 libntfs-3g28 ntfs-3g friendly-recovery);
472 } elsif ($suite eq 'jessie') {
473 push @$incl, 'sysvinit-core'; # avoid systemd and udev
474 push @$incl, 'libperl4-corelibs-perl'; # to make lsof happy
475 push @$excl, qw(systemd systemd-sysv udev module-init-tools pciutils hdparm
477 } elsif ($suite eq 'stretch') {
478 push @$excl, qw(module-init-tools pciutils hdparm
481 push @$excl, qw(udev module-init-tools pciutils hdparm
485 $self->{incl
} = $incl;
486 $self->{excl
} = $excl;
494 my $infodir = $self->{infodir
};
495 my $arch = $self->{config
}->{architecture
};
501 my $logfd = $self->{logfd
} = IO
::File-
>new (">$self->{logfile}") ||
502 die "unable to open log file";
504 foreach my $ss (@{$self->{sources
}}) {
505 my $src = $ss->{mirror
} || $ss->{source
};
506 my $path = "dists/$ss->{suite}/Release";
507 my $url = "$src/$path";
508 my $target = __url_to_filename
("$ss->{source}/$path");
510 $self->download ($url, "$infodir/$target");
511 $self->download ("$url.gpg", "$infodir/$target.gpg");
512 # fixme: impl. verify (needs --keyring option)
516 warn "Release info ignored\n";
518 foreach my $comp (@{$ss->{comp
}}) {
519 $path = "dists/$ss->{suite}/$comp/binary-$arch/Packages.gz";
520 $target = "$infodir/" . __url_to_filename
("$ss->{source}/$path");
521 my $pkgsrc = "$src/$path";
522 $self->download ($pkgsrc, $target);
523 $self->run_command ("gzip -d '$target'");
529 my ($self, $filename, $size) = @_;
531 my $config = $self->{config
};
535 $data .= "Name: $config->{name}\n";
536 $data .= "Version: $config->{version}\n";
537 $data .= "Type: lxc\n";
538 $data .= "OS: $config->{ostype}\n";
539 $data .= "Section: $config->{section}\n";
540 $data .= "Maintainer: $config->{maintainer}\n";
541 $data .= "Architecture: $config->{architecture}\n";
542 $data .= "Installed-Size: $size\n";
545 $data .= "Infopage: $config->{infopage}\n" if $config->{infopage
};
546 $data .= "ManageUrl: $config->{manageurl}\n" if $config->{manageurl
};
547 $data .= "Certified: $config->{certified}\n" if $config->{certified
};
550 $data .= "Description: $config->{headline}\n";
551 $data .= "$config->{description}\n" if $config->{description
};
553 write_file
($data, $filename, 0644);
557 my ($self, $opts) = @_;
559 my $suite = $self->{config
}->{suite
};
560 my $infodir = $self->{infodir
};
561 my $arch = $self->{config
}->{architecture
};
563 my $instpkgs = $self->read_installed ();
564 my $pkginfo = $self->pkginfo();
565 my $veid = $self->{veid
};
566 my $conffile = $self->{veconffile
};
567 my $rootdir = $self->{rootfs
};
569 my $vestat = $self->ve_status();
570 die "ve not running - unable to finalize\n" if !$vestat->{running
};
573 if (-f
"$rootdir/etc/init.d/mysql") {
574 $self->ve_command ("/etc/init.d/mysql stop");
577 if (!($opts->{keepmycnf
} || (-f
"$rootdir/etc/init.d/mysql_randompw"))) {
578 unlink "$rootdir/root/.my.cnf";
581 if ($suite eq 'etch') {
582 # enable apache2 startup
583 if ($instpkgs->{apache2
}) {
584 write_file
("NO_START=0\n", "$rootdir/etc/default/apache2");
586 unlink "$rootdir/etc/default/apache2";
589 $self->logmsg ("cleanup package status\n");
590 # prevent auto selection of all standard, required or important
591 # packages which are not installed
592 foreach my $pkg (keys %$pkginfo) {
593 my $pri = $pkginfo->{$pkg}->{priority
};
594 if ($pri && ($pri eq 'required' || $pri eq 'important'
595 || $pri eq 'standard')) {
596 if (!$instpkgs->{$pkg}) {
597 $self->ve_dpkg_set_selection ($pkg, 'purge');
602 $self->ve_command ("apt-get clean");
604 $self->logmsg ("update available package list\n");
606 $self->ve_command ("dpkg --clear-avail");
607 foreach my $ss (@{$self->{sources
}}) {
608 my $relsrc = __url_to_filename
("$ss->{source}/dists/$ss->{suite}/Release");
609 if (-f
"$infodir/$relsrc" && -f
"$infodir/$relsrc.gpg") {
610 $self->run_command ("cp '$infodir/$relsrc' '$rootdir/var/lib/apt/lists/$relsrc'");
611 $self->run_command ("cp '$infodir/$relsrc.gpg' '$rootdir/var/lib/apt/lists/$relsrc.gpg'");
613 foreach my $comp (@{$ss->{comp
}}) {
614 my $src = __url_to_filename
("$ss->{source}/dists/$ss->{suite}/" .
615 "$comp/binary-$arch/Packages");
616 my $target = "/var/lib/apt/lists/$src";
617 $self->run_command ("cp '$infodir/$src' '$rootdir/$target'");
618 $self->ve_command ("dpkg --merge-avail '$target'");
622 # set dselect default method
623 write_file
("apt apt\n", "$rootdir/var/lib/dpkg/cmethopt");
625 $self->ve_divert_remove ("/usr/sbin/policy-rc.d");
627 $self->ve_divert_remove ("/sbin/start-stop-daemon");
629 $self->ve_divert_remove ("/sbin/init");
631 # finally stop the VE
632 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
634 unlink "$rootdir/sbin/defenv";
636 unlink <$rootdir/root/dead.letter
*>;
638 unlink "$rootdir/var/log/init.log";
640 unlink "$rootdir/aquota.group";
642 unlink "$rootdir/aquota.user";
644 write_file
("", "$rootdir/var/log/syslog");
646 $self->logmsg ("detecting final size: ");
648 my $sizestr = $self->run_command ("du -sm $rootdir", undef, 1);
650 if ($sizestr =~ m/^(\d+)\s+\Q$rootdir\E$/) {
653 die "unable to detect size\n";
655 $self->logmsg ("$size MB\n");
657 $self->write_config ("$rootdir/etc/appliance.info", $size);
659 $self->logmsg ("creating final appliance archive\n");
661 my $target = "$self->{targetname}.tar";
665 $self->run_command ("tar cpf $target --numeric-owner -C '$rootdir' ./etc/appliance.info");
666 $self->run_command ("tar rpf $target --numeric-owner -C '$rootdir' --exclude ./etc/appliance.info .");
667 $self->run_command ("gzip $target");
673 my $rootdir = $self->{rootfs
};
675 my $pkgfilelist = "$rootdir/var/lib/dpkg/status";
677 open (PKGLST
, "<$pkgfilelist") ||
678 die "unable to open '$pkgfilelist'";
682 while (my $rec = <PKGLST
>) {
688 while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
692 my $pkg = $res->{'package'};
693 if (my $status = $res->{status
}) {
694 my @sa = split (/\s+/, $status);
696 if ($stat && ($stat ne 'purge')) {
697 $pkglist->{$pkg} = $res;
710 my $veid = $self->{veid
};
712 my $res = { running
=> 0 };
714 $res->{exist
} = 1 if -d
"$self->{rootfs}/usr";
716 my $filename = "/proc/net/unix";
718 # similar test is used by lcxcontainers.c: list_active_containers
719 my $fh = IO
::File-
>new ($filename, "r");
722 while (defined(my $line = <$fh>)) {
723 if ($line =~ m/^[a-f0-9]+:\s\S+\s\S+\s\S+\s\S+\s\S+\s\d+\s(\S+)$/) {
725 if ($path =~ m!^@/\S+/$veid/command$!) {
736 my ($self, $cmd, $input) = @_;
738 my $veid = $self->{veid
};
739 my $conffile = $self->{veconffile
};
741 if (ref ($cmd) eq 'ARRAY') {
742 unshift @$cmd, 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--clear-env', '--', 'defenv';
743 $self->run_command ($cmd, $input);
745 $self->run_command ("lxc-attach -n $veid --rcfile $conffile --clear-env -- defenv $cmd", $input);
749 # like ve_command, but pipes stdin correctly
751 my ($self, @cmd) = @_;
753 my $veid = $self->{veid
};
754 my $conffile = $self->{veconffile
};
757 my $pid = open2
($reader, "<&STDIN", 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--',
758 'defenv', @cmd) || die "unable to exec command";
760 while (defined (my $line = <$reader>)) {
761 $self->logmsg ($line);
767 die "ve_exec failed - status $rc\n" if $rc != 0;
771 my ($self, $filename) = @_;
773 $self->ve_command ("dpkg-divert --add --divert '$filename.distrib' " .
774 "--rename '$filename'");
776 sub ve_divert_remove
{
777 my ($self, $filename) = @_;
779 my $rootdir = $self->{rootfs
};
781 unlink "$rootdir/$filename";
782 $self->ve_command ("dpkg-divert --remove --rename '$filename'");
785 sub ve_debconfig_set
{
786 my ($self, $dcdata) = @_;
788 my $rootdir = $self->{rootfs
};
789 my $cfgfile = "/tmp/debconf.txt";
790 write_file
($dcdata, "$rootdir/$cfgfile");
791 $self->ve_command ("debconf-set-selections $cfgfile");
792 unlink "$rootdir/$cfgfile";
795 sub ve_dpkg_set_selection
{
796 my ($self, $pkg, $status) = @_;
798 $self->ve_command ("dpkg --set-selections", "$pkg $status");
802 my ($self, $cmd, @pkglist) = @_;
804 return if !scalar (@pkglist);
806 my $pkginfo = $self->pkginfo();
808 my $rootdir = $self->{rootfs
};
809 my $cachedir = $self->{cachedir
};
813 foreach my $pkg (@pkglist) {
814 my $filename = $self->getpkgfile ($pkg);
815 $self->run_command ("cp '$cachedir/$filename' '$rootdir/$filename'");
816 push @files, "/$filename";
817 $self->logmsg ("$cmd: $pkg\n");
820 my $fl = join (' ', @files);
822 if ($cmd eq 'install') {
823 $self->ve_command ("dpkg --force-depends --force-confold --install $fl");
824 } elsif ($cmd eq 'unpack') {
825 $self->ve_command ("dpkg --force-depends --unpack $fl");
827 die "internal error";
830 foreach my $fn (@files) { unlink "$rootdir$fn"; }
836 my $veid = $self->{veid
}; # fixme
837 my $conffile = $self->{veconffile
};
839 my $vestat = $self->ve_status();
840 if ($vestat->{running
}) {
841 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
844 rmtree
$self->{rootfs
};
845 unlink $self->{veconffile
};
851 my $veid = $self->{veid
};
852 my $conffile = $self->{veconffile
};
854 $self->logmsg ("initialize VE $veid\n");
856 my $vestat = $self->ve_status();
857 if ($vestat->{running
}) {
858 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
861 rmtree
$self->{rootfs
};
862 mkpath
$self->{rootfs
};
865 sub __deb_version_cmp
{
866 my ($cur, $op, $new) = @_;
868 if (system("dpkg", "--compare-versions", $cur, $op, $new) == 0) {
875 sub __parse_packages
{
876 my ($pkginfo, $filename, $src) = @_;
879 open (PKGLST
, "<$filename") ||
880 die "unable to open '$filename'";
882 while (my $rec = <PKGLST
>) {
889 while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
893 my $pkg = $res->{'package'};
894 if ($pkg && $res->{'filename'}) {
896 if (my $info = $pkginfo->{$pkg}) {
897 $cur = $info->{version
};
899 my $new = $res->{version
};
900 if (!$cur || __deb_version_cmp
($cur, 'lt', $new)) {
902 $res->{url
} = "$src/$res->{'filename'}";
904 die "no url for package '$pkg'" if !$res->{url
};
906 $pkginfo->{$pkg} = $res;
917 return $self->{pkginfo
} if $self->{pkginfo
};
919 my $infodir = $self->{infodir
};
920 my $arch = $self->{config
}->{architecture
};
922 my $availfn = "$infodir/available";
927 # reading 'available' is faster, because it only contains latest version
928 # (no need to do slow version compares)
930 __parse_packages
($pkginfo, $availfn);
931 $self->{pkginfo
} = $pkginfo;
935 $self->logmsg ("generating available package list\n");
937 foreach my $ss (@{$self->{sources
}}) {
938 foreach my $comp (@{$ss->{comp
}}) {
939 my $url = "$ss->{source}/dists/$ss->{suite}/$comp/binary-$arch/Packages";
940 my $pkgfilelist = "$infodir/" . __url_to_filename
($url);
942 my $src = $ss->{mirror
} || $ss->{source
};
944 __parse_packages
($pkginfo, $pkgfilelist, $src);
948 if (my $dep = $self->{config
}->{depends
}) {
949 foreach my $d (split (/,/, $dep)) {
950 if ($d =~ m/^\s*(\S+)\s*(\((\S+)\s+(\S+)\)\s*)?$/) {
951 my ($pkg, $op, $rver) = ($1, $3, $4);
952 $self->logmsg ("checking dependencies: $d\n");
953 my $info = $pkginfo->{$pkg};
954 die "package '$pkg' not available\n" if !$info;
956 my $cver = $info->{version
};
957 if (!__deb_version_cmp
($cver, $op, $rver)) {
958 die "detected wrong version '$cver'\n";
962 die "syntax error in depends field";
967 $self->{pkginfo
} = $pkginfo;
969 my $tmpfn = "$availfn.tmp$$";
970 my $fd = IO
::File-
>new (">$tmpfn");
971 foreach my $pkg (sort keys %$pkginfo) {
972 my $info = $pkginfo->{$pkg};
973 print $fd "package: $pkg\n";
974 foreach my $k (sort keys %$info) {
975 next if $k eq 'description';
976 next if $k eq 'package';
978 print $fd "$k: $v\n" if $v;
980 print $fd "description: $info->{description}\n" if $info->{description
};
985 rename ($tmpfn, $availfn);
990 sub __record_provides
{
991 my ($pkginfo, $closure, $list, $skipself) = @_;
993 foreach my $pname (@$list) {
994 my $info = $pkginfo->{$pname};
995 # fixme: if someone install packages directly using dpkg, there
996 # is no entry in 'available', only in 'status'. In that case, we
997 # should extract info from $instpkgs
999 warn "hint: ignoring provides for '$pname' - package not in 'available' list.\n";
1002 if (my $prov = $info->{provides
}) {
1003 my @pl = split (',', $prov);
1004 foreach my $p (@pl) {
1006 if (!($skipself && (grep { $1 eq $_ } @$list))) {
1011 $closure->{$pname} = 1 if !$skipself;
1016 my ($self, $closure, $list) = @_;
1018 my $pkginfo = $self->pkginfo();
1020 # first, record provided packages
1021 __record_provides
($pkginfo, $closure, $list, 1);
1026 # then resolve dependencies
1027 foreach my $pname (@$list) {
1028 __closure_single
($pkginfo, $closure, $pkghash, $pkglist, $pname, $self->{excl
});
1034 sub __closure_single
{
1035 my ($pkginfo, $closure, $pkghash, $pkglist, $pname, $excl) = @_;
1039 $pname =~ s/:any$//;
1041 return if $closure->{$pname};
1043 my $info = $pkginfo->{$pname} || die "no such package '$pname'";
1045 my $dep = $info->{depends
};
1046 my $predep = $info->{'pre-depends'};
1048 my $size = $info->{size
};
1049 my $url = $info->{url
};
1051 $url || die "$pname: no url for package '$pname'";
1053 if (!$pkghash->{$pname}) {
1054 unshift @$pkglist, $pname;
1055 $pkghash->{$pname} = 1;
1058 __record_provides
($pkginfo, $closure, [$pname]) if $info->{provides
};
1060 $closure->{$pname} = 1;
1066 push @l, split (/,/, $predep) if $predep;
1067 push @l, split (/,/, $dep) if $dep;
1069 DEPEND
: foreach my $p (@l) {
1070 my @l1 = split (/\|/, $p);
1071 foreach my $p1 (@l1) {
1072 if ($p1 =~ m/^\s*(\S+).*/) {
1073 #printf (STDERR "$pname: $p --> $1\n");
1074 if ($closure->{$1}) {
1075 next DEPEND
; # dependency already met
1079 # search for non-excluded alternative
1081 foreach my $p1 (@l1) {
1082 if ($p1 =~ m/^\s*(\S+).*/) {
1083 next if grep { $1 eq $_ } @$excl;
1088 die "package '$pname' depends on exclusion '$p'\n" if !$found;
1090 #printf (STDERR "$pname: $p --> $found\n");
1092 __closure_single
($pkginfo, $closure, $pkghash, $pkglist, $found, $excl);
1096 sub cache_packages
{
1097 my ($self, $pkglist) = @_;
1099 foreach my $pkg (@$pkglist) {
1100 $self->getpkgfile ($pkg);
1105 my ($self, $pkg) = @_;
1107 my $pkginfo = $self->pkginfo();
1108 my $info = $pkginfo->{$pkg} || die "no such package '$pkg'";
1109 my $cachedir = $self->{cachedir
};
1111 my $url = $info->{url
};
1114 if ($url =~ m
|/([^/]+.deb
)$|) {
1117 die "internal error";
1120 return $filename if -f
"$cachedir/$filename";
1124 $self->download ($url, "$cachedir/$filename");
1129 sub install_init_script
{
1130 my ($self, $script, $runlevel, $prio) = @_;
1132 my $suite = $self->{config
}->{suite
};
1133 my $rootdir = $self->{rootfs
};
1135 my $base = basename
($script);
1136 my $target = "$rootdir/etc/init.d/$base";
1138 $self->run_command ("install -m 0755 '$script' '$target'");
1139 if ($suite eq 'etch' || $suite eq 'lenny') {
1140 $self->ve_command ("update-rc.d $base start $prio $runlevel .");
1141 } elsif ($suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
1142 $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful') {
1143 die "unable to install init script (system uses systemd)\n";
1144 } elsif ($suite eq 'trusty' || $suite eq 'precise') {
1145 die "unable to install init script (system uses upstart)\n";
1147 $self->ve_command ("insserv $base");
1154 my ($self, $opts) = @_;
1156 my $pkginfo = $self->pkginfo();
1157 my $veid = $self->{veid
};
1158 my $suite = $self->{config
}->{suite
};
1160 my $important = [ @{$self->{incl
}} ];
1164 my $mta = $opts->{exim
} ?
'exim' : 'postfix';
1166 if ($mta eq 'postfix') {
1167 push @$important, "postfix";
1170 foreach my $p (sort keys %$pkginfo) {
1171 next if grep { $p eq $_ } @{$self->{excl
}};
1172 my $pri = $pkginfo->{$p}->{priority
};
1174 next if $mta ne 'exim' && $p =~ m/exim/;
1175 next if $p =~ m/(selinux|semanage|policycoreutils)/;
1177 push @$required, $p if $pri eq 'required';
1178 push @$important, $p if $pri eq 'important';
1179 push @$standard, $p if $pri eq 'standard' && !$opts->{minimal
};
1183 $required = $self->closure ($closure, $required);
1184 $important = $self->closure ($closure, $important);
1186 if (!$opts->{minimal
}) {
1187 push @$standard, 'xbase-clients';
1188 $standard = $self->closure ($closure, $standard);
1191 # test if we have all 'ubuntu-minimal' and 'ubuntu-standard' packages
1192 # except those explicitly excluded
1193 if ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1194 my $mdeps = $pkginfo->{'ubuntu-minimal'}->{depends
};
1195 foreach my $d (split (/,/, $mdeps)) {
1196 if ($d =~ m/^\s*(\S+)$/) {
1198 next if $closure->{$pkg};
1199 next if grep { $pkg eq $_ } @{$self->{excl
}};
1200 die "missing ubuntu-minimal package '$pkg'\n";
1203 if (!$opts->{minimal
}) {
1204 $mdeps = $pkginfo->{'ubuntu-standard'}->{depends
};
1205 foreach my $d (split (/,/, $mdeps)) {
1206 if ($d =~ m/^\s*(\S+)$/) {
1208 next if $closure->{$pkg};
1209 next if grep { $pkg eq $_ } @{$self->{excl
}};
1210 die "missing ubuntu-standard package '$pkg'\n";
1216 # download/cache all files first
1217 $self->cache_packages ($required);
1218 $self->cache_packages ($important);
1219 $self->cache_packages ($standard);
1221 my $rootdir = $self->{rootfs
};
1223 # extract required packages first
1224 $self->logmsg ("create basic environment\n");
1225 foreach my $p (@$required) {
1226 my $filename = $self->getpkgfile ($p);
1227 my $content = $self->run_command("ar -t '$self->{cachedir}/$filename'", undef, 1);
1228 if ($content =~ m/^data.tar.xz$/m) {
1229 $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.xz | tar -C '$rootdir' -xJf -");
1231 $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf -");
1236 my $data = "Package: dpkg\n" .
1237 "Version: $pkginfo->{dpkg}->{version}\n" .
1238 "Status: install ok installed\n";
1240 write_file
($data, "$rootdir/var/lib/dpkg/status");
1241 write_file
("", "$rootdir/var/lib/dpkg/info/dpkg.list");
1242 write_file
("", "$rootdir/var/lib/dpkg/available");
1245 foreach my $ss (@{$self->{sources
}}) {
1246 my $url = $ss->{source
};
1247 my $comp = join (' ', @{$ss->{comp
}});
1248 $data .= "deb $url $ss->{suite} $comp\n\n";
1251 write_file
($data, "$rootdir/etc/apt/sources.list");
1253 $data = "# UNCONFIGURED FSTAB FOR BASE SYSTEM\n";
1254 write_file
($data, "$rootdir/etc/fstab", 0644);
1256 write_file
("localhost\n", "$rootdir/etc/hostname", 0644);
1258 # avoid warnings about non-existent resolv.conf
1259 write_file
("", "$rootdir/etc/resolv.conf", 0644);
1261 if ($suite eq 'artful' || $suite eq 'zesty' || $suite eq 'yakkety' ||
1262 $suite eq 'xenial' || $suite eq 'wily') {
1263 # no need to configure loopback device
1265 $data = "auto lo\niface lo inet loopback\n";
1266 mkdir "$rootdir/etc/network";
1267 write_file
($data, "$rootdir/etc/network/interfaces", 0644);
1271 $self->run_command ("tar xzf '$devicetar' -C '$rootdir'");
1273 # avoid warnings about missing default locale
1274 write_file
("LANG=\"C\"\n", "$rootdir/etc/default/locale", 0644);
1277 rename ("$rootdir/sbin/init", "$rootdir/sbin/init.org");
1278 $self->run_command ("cp '$fake_init' '$rootdir/sbin/init'");
1280 $self->run_command ("cp '$default_env' '$rootdir/sbin/defenv'");
1282 $self->run_command ("lxc-start -n $veid -f $self->{veconffile}");
1284 $self->logmsg ("initialize ld cache\n");
1285 $self->ve_command ("/sbin/ldconfig");
1286 $self->run_command ("ln -sf mawk '$rootdir/usr/bin/awk'");
1288 $self->logmsg ("installing packages\n");
1290 $self->ve_dpkg ('install', 'base-files', 'base-passwd');
1292 $self->ve_dpkg ('install', 'dpkg');
1294 $self->run_command ("ln -sf /usr/share/zoneinfo/UTC '$rootdir/etc/localtime'");
1296 $self->run_command ("ln -sf bash '$rootdir/bin/sh'");
1298 $self->ve_dpkg ('install', 'libc6');
1299 $self->ve_dpkg ('install', 'perl-base');
1301 unlink "$rootdir/usr/bin/awk";
1303 $self->ve_dpkg ('install', 'mawk');
1304 $self->ve_dpkg ('install', 'debconf');
1306 # unpack required packages
1307 foreach my $p (@$required) {
1308 $self->ve_dpkg ('unpack', $p);
1311 rename ("$rootdir/sbin/init.org", "$rootdir/sbin/init");
1312 $self->ve_divert_add ("/sbin/init");
1313 $self->run_command ("cp '$fake_init' '$rootdir/sbin/init'");
1315 # disable service activation
1316 $self->ve_divert_add ("/usr/sbin/policy-rc.d");
1317 $data = "#!/bin/sh\nexit 101\n";
1318 write_file
($data, "$rootdir/usr/sbin/policy-rc.d", 755);
1320 # disable start-stop-daemon
1321 $self->ve_divert_add ("/sbin/start-stop-daemon");
1325 echo \"Warning: Fake start-stop-daemon called, doing nothing\"
1327 write_file
($data, "$rootdir/sbin/start-stop-daemon", 0755);
1330 $self->ve_divert_add ("/sbin/udevd");
1332 if ($suite eq 'etch') {
1333 # disable apache2 startup
1334 write_file
("NO_START=1\n", "$rootdir/etc/default/apache2");
1337 $self->logmsg ("configure required packages\n");
1338 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1340 # set postfix defaults
1341 if ($mta eq 'postfix') {
1342 $data = "postfix postfix/main_mailer_type select Local only\n";
1343 $self->ve_debconfig_set ($data);
1345 $data = "postmaster: root\nwebmaster: root\n";
1346 write_file
($data, "$rootdir/etc/aliases");
1349 if ($suite eq 'jaunty') {
1350 # jaunty does not create /var/run/network, so network startup fails.
1351 # so we do not use tmpfs for /var/run and /var/lock
1352 $self->run_command ("sed -e 's/RAMRUN=yes/RAMRUN=no/' -e 's/RAMLOCK=yes/RAMLOCK=no/' -i $rootdir/etc/default/rcS");
1353 # and create the directory here
1354 $self->run_command ("mkdir $rootdir/var/run/network");
1357 # unpack base packages
1358 foreach my $p (@$important) {
1359 $self->ve_dpkg ('unpack', $p);
1363 if (-x
"$rootdir/sbin/ifconfig") {
1364 $self->ve_command ("ifconfig lo up");
1366 $self->ve_command ("ip link set lo up");
1369 $self->logmsg ("configure important packages\n");
1370 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1372 if (-d
"$rootdir/etc/event.d") {
1373 unlink <$rootdir/etc/event.d
/tty
*>;
1376 if (-f
"$rootdir/etc/inittab") {
1377 $self->run_command ("sed -i -e '/getty\\s38400\\stty[23456]/d' '$rootdir/etc/inittab'");
1380 # Link /etc/mtab to /proc/mounts, so df and friends will work:
1381 unlink "$rootdir/etc/mtab";
1382 $self->ve_command ("ln -s /proc/mounts /etc/mtab");
1385 $self->ve_command ("usermod -L root");
1387 if ($mta eq 'postfix') {
1388 $data = "postfix postfix/main_mailer_type select No configuration\n";
1389 $self->ve_debconfig_set ($data);
1391 unlink "$rootdir/etc/mailname";
1392 write_file
($postfix_main_cf, "$rootdir/etc/postfix/main.cf");
1395 if (!$opts->{minimal
}) {
1396 # unpack standard packages
1397 foreach my $p (@$standard) {
1398 $self->ve_dpkg ('unpack', $p);
1401 $self->logmsg ("configure standard packages\n");
1402 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1405 # disable HWCLOCK access
1406 $self->run_command ("echo 'HWCLOCKACCESS=no' >> '$rootdir/etc/default/rcS'");
1409 $self->ve_divert_add ("/usr/sbin/hald");
1411 # disable /dev/urandom init
1412 $self->run_command ("install -m 0755 '$script_init_urandom' '$rootdir/etc/init.d/urandom'");
1414 if ($suite eq 'etch' || $suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1416 $self->ve_divert_add ("/sbin/klogd");
1419 # remove unnecessays sysctl entries to avoid warnings
1421 $cmd .= ' -e \'s/^\(kernel\.printk.*\)/#\1/\'';
1422 $cmd .= ' -e \'s/^\(kernel\.maps_protect.*\)/#\1/\'';
1423 $cmd .= ' -e \'s/^\(fs\.inotify\.max_user_watches.*\)/#\1/\'';
1424 $cmd .= ' -e \'s/^\(vm\.mmap_min_addr.*\)/#\1/\'';
1425 $cmd .= " -i '$rootdir/etc/sysctl.conf'";
1426 $self->run_command ($cmd);
1428 my $bindv6only = "$rootdir/etc/sysctl.d/bindv6only.conf";
1429 if (-f
$bindv6only) {
1431 $cmd .= ' -e \'s/^\(net\.ipv6\.bindv6only.*\)/#\1/\'';
1432 $cmd .= " -i '$bindv6only'";
1433 $self->run_command ($cmd);
1436 if ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1437 # disable tty init (console-setup)
1439 $cmd .= ' -e \'s/^\(ACTIVE_CONSOLES=.*\)/ACTIVE_CONSOLES=/\'';
1440 $cmd .= " -i '$rootdir/etc/default/console-setup'";
1441 $self->run_command ($cmd);
1444 if ($suite eq 'intrepid') {
1445 # remove sysctl setup (avoid warnings at startup)
1446 my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
1447 $filelist .= " $rootdir/etc/sysctl.d/10-process-security.conf";
1448 $filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
1449 $self->run_command ("rm $filelist");
1451 if ($suite eq 'jaunty') {
1452 # remove sysctl setup (avoid warnings at startup)
1453 my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
1454 $filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
1455 $self->run_command ("rm $filelist");
1462 my $veid = $self->{veid
};
1463 my $conffile = $self->{veconffile
};
1465 my $vestat = $self->ve_status();
1467 if (!$vestat->{exist
}) {
1468 $self->logmsg ("Please create the appliance first (bootstrap)");
1472 if (!$vestat->{running
}) {
1473 $self->run_command ("lxc-start -n $veid -f $conffile");
1476 system ("lxc-attach -n $veid --rcfile $conffile --clear-env");
1479 sub ve_mysql_command
{
1480 my ($self, $sql, $password) = @_;
1482 #my $bootstrap = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables " .
1483 #"--skip-bdb --skip-innodb --skip-ndbcluster";
1485 $self->ve_command ("mysql", $sql);
1488 sub ve_mysql_bootstrap
{
1489 my ($self, $sql, $password) = @_;
1493 my $suite = $self->{config
}->{suite
};
1495 if ($suite eq 'jessie') {
1496 my $rootdir = $self->{rootfs
};
1497 $self->run_command ("sed -e 's/^key_buffer\\s*=/key_buffer_size =/' -i $rootdir/etc/mysql/my.cnf");
1500 if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie') {
1501 $cmd = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables";
1504 $cmd = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables " .
1505 "--skip-bdb --skip-innodb --skip-ndbcluster";
1508 $self->ve_command ($cmd, $sql);
1511 sub compute_required
{
1512 my ($self, $pkglist) = @_;
1514 my $pkginfo = $self->pkginfo();
1515 my $instpkgs = $self->read_installed ();
1518 __record_provides
($pkginfo, $closure, [keys %$instpkgs]);
1520 return $self->closure ($closure, $pkglist);
1524 my ($self, $opts) = @_;
1526 my @supp = ('7.4', '8.1');
1527 my $pgversion = '8.1';
1529 my $suite = $self->{config
}->{suite
};
1531 if ($suite eq 'lenny' || $suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1534 } elsif ($suite eq 'squeeze') {
1537 } elsif ($suite eq 'wheezy') {
1540 } elsif ($suite eq 'jessie') {
1543 } elsif ($suite eq 'stretch') {
1548 $pgversion = $opts->{version
} if $opts->{version
};
1550 die "unsupported postgres version '$pgversion'\n"
1551 if !grep { $pgversion eq $_; } @supp;
1553 my $rootdir = $self->{rootfs
};
1555 my $required = $self->compute_required (["postgresql-$pgversion"]);
1557 $self->cache_packages ($required);
1559 $self->ve_dpkg ('install', @$required);
1561 my $iscript = "postgresql-$pgversion";
1562 if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie' ||
1563 $suite eq 'stretch') {
1564 $iscript = 'postgresql';
1567 $self->ve_command ("/etc/init.d/$iscript start") if $opts->{start
};
1571 my ($self, $opts) = @_;
1573 my $password = $opts->{password
};
1574 my $rootdir = $self->{rootfs
};
1576 my $suite = $self->{config
}->{suite
};
1579 if ($suite eq 'squeeze') {
1581 } elsif ($suite eq 'wheezy' || $suite eq 'jessie') {
1584 die "task_mysql: unsupported suite '$suite'";
1587 my $required = $self->compute_required (['mysql-common', "mysql-server-$ver"]);
1589 $self->cache_packages ($required);
1591 $self->ve_dpkg ('install', @$required);
1593 # fix security (see /usr/bin/mysql_secure_installation)
1594 my $sql = "DELETE FROM mysql.user WHERE User='';\n" .
1595 "DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';\n" .
1596 "FLUSH PRIVILEGES;\n";
1597 $self->ve_mysql_bootstrap ($sql);
1601 my $rpw = $password eq 'random' ?
'admin' : $password;
1603 my $sql = "USE mysql;\n" .
1604 "UPDATE user SET password=PASSWORD(\"$rpw\") WHERE user
='root';\n" .
1605 "FLUSH PRIVILEGES
;\n";
1606 $self->ve_mysql_bootstrap ($sql);
1608 write_file ("[client
]\nuser
=root
\npassword
=\"$rpw\"\n", "$rootdir/root/.my.cnf", 0600);
1609 if ($password eq 'random') {
1610 $self->install_init_script ($script_mysql_randompw, 2, 20);
1614 $self->ve_command ("/etc/init.d/mysql start") if $opts->{start
};
1618 my ($self, $opts) = @_;
1620 my $memlimit = $opts->{memlimit
};
1621 my $rootdir = $self->{rootfs
};
1623 my $required = $self->compute_required ([qw
(php5 php5-cli libapache2-mod-php5 php5-gd
)]);
1625 $self->cache_packages ($required);
1627 $self->ve_dpkg ('install', @$required);
1630 $self->run_command ("sed -e 's/^\\s*memory_limit\\s*=.*;/memory_limit = ${memlimit}M;/' -i $rootdir/etc/php5/apache2/php.ini");
1635 my ($self, $pkglist, $unpack) = @_;
1637 my $required = $self->compute_required ($pkglist);
1639 $self->cache_packages ($required);
1641 $self->ve_dpkg ($unpack ?
'unpack' : 'install', @$required);
1645 my ($self, $distclean) = @_;
1647 unlink $self->{logfile
};
1648 unlink "$self->{targetname}.tar";
1649 unlink "$self->{targetname}.tar.gz";
1651 $self->ve_destroy ();
1654 rmtree
$self->{cachedir
} if $distclean && !$self->{config
}->{cachedir
};
1656 rmtree
$self->{infodir
};