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/^de(bi|vu)an-/) {
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.uts.name = localhost\n";
248 $data .= "lxc.rootfs.path = $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 'devuan-jessie') {
336 $config->{ostype
} = "devuan-1.0";
337 } elsif ($suite eq 'devuan-ascii' || $suite eq 'ascii') {
339 $config->{ostype
} = "devuan-2.0";
340 } elsif ($suite eq 'hardy') {
341 $config->{ostype
} = "ubuntu-8.04";
342 } elsif ($suite eq 'intrepid') {
343 $config->{ostype
} = "ubuntu-8.10";
344 } elsif ($suite eq 'jaunty') {
345 $config->{ostype
} = "ubuntu-9.04";
346 } elsif ($suite eq 'precise') {
347 $config->{ostype
} = "ubuntu-12.04";
348 } elsif ($suite eq 'trusty') {
349 $config->{ostype
} = "ubuntu-14.04";
350 } elsif ($suite eq 'vivid') {
351 $config->{ostype
} = "ubuntu-15.04";
352 } elsif ($suite eq 'wily') {
353 $config->{ostype
} = "ubuntu-15.10";
354 } elsif ($suite eq 'xenial') {
355 $config->{ostype
} = "ubuntu-16.04";
356 } elsif ($suite eq 'yakkety') {
357 $config->{ostype
} = "ubuntu-16.10";
358 } elsif ($suite eq 'zesty') {
359 $config->{ostype
} = "ubuntu-17.04";
360 } elsif ($suite eq 'artful') {
361 $config->{ostype
} = "ubuntu-17.10";
362 } elsif ($suite eq 'bionic') {
363 $config->{ostype
} = "ubuntu-18.04";
365 die "unsupported debian suite '$suite'\n";
368 my $name = $config->{name
} || die "no 'name' specified\n";
370 $name =~ m/^[a-z][0-9a-z\-\*\.]+$/ ||
371 die "illegal characters in name '$name'\n";
373 my $version = $config->{version
};
374 die "no 'version' specified\n" if !$version;
375 die "no 'section' specified\n" if !$config->{section
};
376 die "no 'description' specified\n" if !$config->{headline
};
377 die "no 'maintainer' specified\n" if !$config->{maintainer
};
379 if ($name =~ m/^$config->{ostype}/) {
380 $self->{targetname
} = "${name}_${version}_$config->{architecture}";
382 $self->{targetname
} = "$config->{ostype}-${name}_" .
383 "${version}_$config->{architecture}";
386 if (!$config->{source
}) {
387 if ($suite eq 'etch' || $suite eq 'lenny') {
388 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE main contrib";
389 push @{$config->{source
}}, "http://security.debian.org SUITE/updates main contrib";
390 } elsif ($suite eq 'squeeze' || $suite eq 'wheezy' ||
391 $suite eq 'jessie' || $suite eq 'stretch' ) {
392 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE main contrib";
393 push @{$config->{source
}}, "http://ftp.debian.org/debian SUITE-updates main contrib";
394 push @{$config->{source
}}, "http://security.debian.org SUITE/updates main contrib";
395 } elsif ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty' ||
396 $suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
397 $suite eq 'trusty' || $suite eq 'precise' || $suite eq 'yakkety' ||
398 $suite eq 'zesty' || $suite eq 'artful' || $suite eq 'bionic') {
399 my $comp = "main restricted universe multiverse";
400 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE $comp";
401 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE-updates $comp";
402 push @{$config->{source
}}, "http://archive.ubuntu.com/ubuntu SUITE-security $comp";
410 foreach my $s (@{$config->{source
}}) {
411 if ($s =~ m
@^\s*((http
|ftp
)://\S
+)\s
+(\S
+)((\s
+(\S
+))+)$@) {
412 my ($url, $su, $components) = ($1, $3, $4);
413 $su =~ s/SUITE/$suite/;
414 $components =~ s/^\s+//;
415 $components =~ s/\s+$//;
417 foreach my $co (split (/\s+/, $components)) {
420 $ca = ['main'] if !$ca;
428 die "syntax error in source spezification '$s'\n";
432 foreach my $m (@{$config->{mirror
}}) {
433 if ($m =~ m
@^\s*((http
|ftp
)://\S
+)\s
*=>\s
*((http
|ftp
)://\S
+)\s
*$@) {
434 my ($ms, $md) = ($1, $3);
436 foreach my $ss (@$sources) {
437 if ($ss->{source
} eq $ms) {
443 die "unusable mirror $ms\n" if !$found;
445 die "syntax error in mirror spezification '$m'\n";
449 $self->{sources
} = $sources;
451 $self->{infodir
} = "info";
453 $self->__allocate_ve ();
455 $self->{cachedir
} = ($config->{cachedir
} || 'cache') . "/$suite";;
457 my $incl = [qw
(less ssh openssh-server logrotate
)];
459 my $excl = [qw
(modutils reiserfsprogs ppp pppconfig pppoe
460 pppoeconf nfs-common mtools ntp
)];
462 # ubuntu has too many dependencies on udev, so
463 # we cannot exclude it (instead we disable udevd)
465 if ($suite eq 'vivid' || $suite eq 'wily' || $suite eq 'xenial' ||
466 $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful' ||
467 $suite eq 'bionic') {
468 push @$incl, 'isc-dhcp-client';
469 push @$excl, qw(libmodule-build-perl);
470 } elsif ($suite eq 'trusty') {
471 push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+);
472 } elsif ($suite eq 'precise') {
473 push @$excl, qw(systemd systemd-services libpam-systemd libsystemd-daemon0 memtest86+ ubuntu-standard);
474 } elsif ($suite eq 'hardy') {
475 push @$excl, qw(kbd);
476 push @$excl, qw(apparmor apparmor-utils ntfs-3g
478 } elsif ($suite eq 'intrepid' || $suite eq 'jaunty') {
479 push @$excl, qw(apparmor apparmor-utils libapparmor1 libapparmor-perl
480 libntfs-3g28 ntfs-3g friendly-recovery);
481 } elsif ($suite eq 'jessie') {
482 push @$incl, 'sysvinit-core'; # avoid systemd and udev
483 push @$incl, 'libperl4-corelibs-perl'; # to make lsof happy
484 push @$excl, qw(systemd systemd-sysv udev module-init-tools pciutils hdparm
486 } elsif ($suite eq 'stretch') {
487 push @$excl, qw(module-init-tools pciutils hdparm
490 push @$excl, qw(udev module-init-tools pciutils hdparm
494 $self->{incl
} = $incl;
495 $self->{excl
} = $excl;
503 my $infodir = $self->{infodir
};
504 my $arch = $self->{config
}->{architecture
};
510 my $logfd = $self->{logfd
} = IO
::File-
>new (">$self->{logfile}") ||
511 die "unable to open log file";
513 foreach my $ss (@{$self->{sources
}}) {
514 my $src = $ss->{mirror
} || $ss->{source
};
515 my $path = "dists/$ss->{suite}/Release";
516 my $url = "$src/$path";
517 my $target = __url_to_filename
("$ss->{source}/$path");
519 $self->download ($url, "$infodir/$target");
520 $self->download ("$url.gpg", "$infodir/$target.gpg");
521 # fixme: impl. verify (needs --keyring option)
525 warn "Release info ignored\n";
527 foreach my $comp (@{$ss->{comp
}}) {
528 $path = "dists/$ss->{suite}/$comp/binary-$arch/Packages.gz";
529 $target = "$infodir/" . __url_to_filename
("$ss->{source}/$path");
530 my $pkgsrc = "$src/$path";
531 $self->download ($pkgsrc, $target);
532 $self->run_command ("gzip -d '$target'");
538 my ($self, $filename, $size) = @_;
540 my $config = $self->{config
};
544 $data .= "Name: $config->{name}\n";
545 $data .= "Version: $config->{version}\n";
546 $data .= "Type: lxc\n";
547 $data .= "OS: $config->{ostype}\n";
548 $data .= "Section: $config->{section}\n";
549 $data .= "Maintainer: $config->{maintainer}\n";
550 $data .= "Architecture: $config->{architecture}\n";
551 $data .= "Installed-Size: $size\n";
554 $data .= "Infopage: $config->{infopage}\n" if $config->{infopage
};
555 $data .= "ManageUrl: $config->{manageurl}\n" if $config->{manageurl
};
556 $data .= "Certified: $config->{certified}\n" if $config->{certified
};
559 $data .= "Description: $config->{headline}\n";
560 $data .= "$config->{description}\n" if $config->{description
};
562 write_file
($data, $filename, 0644);
566 my ($self, $opts) = @_;
568 my $suite = $self->{config
}->{suite
};
569 my $infodir = $self->{infodir
};
570 my $arch = $self->{config
}->{architecture
};
572 my $instpkgs = $self->read_installed ();
573 my $pkginfo = $self->pkginfo();
574 my $veid = $self->{veid
};
575 my $conffile = $self->{veconffile
};
576 my $rootdir = $self->{rootfs
};
578 my $vestat = $self->ve_status();
579 die "ve not running - unable to finalize\n" if !$vestat->{running
};
582 if (-f
"$rootdir/etc/init.d/mysql") {
583 $self->ve_command ("/etc/init.d/mysql stop");
586 if (!($opts->{keepmycnf
} || (-f
"$rootdir/etc/init.d/mysql_randompw"))) {
587 unlink "$rootdir/root/.my.cnf";
590 if ($suite eq 'etch') {
591 # enable apache2 startup
592 if ($instpkgs->{apache2
}) {
593 write_file
("NO_START=0\n", "$rootdir/etc/default/apache2");
595 unlink "$rootdir/etc/default/apache2";
598 $self->logmsg ("cleanup package status\n");
599 # prevent auto selection of all standard, required or important
600 # packages which are not installed
601 foreach my $pkg (keys %$pkginfo) {
602 my $pri = $pkginfo->{$pkg}->{priority
};
603 if ($pri && ($pri eq 'required' || $pri eq 'important'
604 || $pri eq 'standard')) {
605 if (!$instpkgs->{$pkg}) {
606 $self->ve_dpkg_set_selection ($pkg, 'purge');
611 $self->ve_command ("apt-get clean");
613 $self->logmsg ("update available package list\n");
615 $self->ve_command ("dpkg --clear-avail");
616 foreach my $ss (@{$self->{sources
}}) {
617 my $relsrc = __url_to_filename
("$ss->{source}/dists/$ss->{suite}/Release");
618 if (-f
"$infodir/$relsrc" && -f
"$infodir/$relsrc.gpg") {
619 $self->run_command ("cp '$infodir/$relsrc' '$rootdir/var/lib/apt/lists/$relsrc'");
620 $self->run_command ("cp '$infodir/$relsrc.gpg' '$rootdir/var/lib/apt/lists/$relsrc.gpg'");
622 foreach my $comp (@{$ss->{comp
}}) {
623 my $src = __url_to_filename
("$ss->{source}/dists/$ss->{suite}/" .
624 "$comp/binary-$arch/Packages");
625 my $target = "/var/lib/apt/lists/$src";
626 $self->run_command ("cp '$infodir/$src' '$rootdir/$target'");
627 $self->ve_command ("dpkg --merge-avail '$target'");
631 # set dselect default method
632 write_file
("apt apt\n", "$rootdir/var/lib/dpkg/cmethopt");
634 $self->ve_divert_remove ("/usr/sbin/policy-rc.d");
636 $self->ve_divert_remove ("/sbin/start-stop-daemon");
638 $self->ve_divert_remove ("/sbin/init");
640 # finally stop the VE
641 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
643 unlink "$rootdir/sbin/defenv";
645 unlink <$rootdir/root/dead.letter
*>;
647 unlink "$rootdir/var/log/init.log";
649 unlink "$rootdir/aquota.group";
651 unlink "$rootdir/aquota.user";
653 write_file
("", "$rootdir/var/log/syslog");
655 $self->logmsg ("detecting final size: ");
657 my $sizestr = $self->run_command ("du -sm $rootdir", undef, 1);
659 if ($sizestr =~ m/^(\d+)\s+\Q$rootdir\E$/) {
662 die "unable to detect size\n";
664 $self->logmsg ("$size MB\n");
666 $self->write_config ("$rootdir/etc/appliance.info", $size);
668 $self->logmsg ("creating final appliance archive\n");
670 my $target = "$self->{targetname}.tar";
674 $self->run_command ("tar cpf $target --numeric-owner -C '$rootdir' ./etc/appliance.info");
675 $self->run_command ("tar rpf $target --numeric-owner -C '$rootdir' --exclude ./etc/appliance.info .");
676 $self->run_command ("gzip $target");
682 my $rootdir = $self->{rootfs
};
684 my $pkgfilelist = "$rootdir/var/lib/dpkg/status";
686 open (PKGLST
, "<$pkgfilelist") ||
687 die "unable to open '$pkgfilelist'";
691 while (my $rec = <PKGLST
>) {
697 while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
701 my $pkg = $res->{'package'};
702 if (my $status = $res->{status
}) {
703 my @sa = split (/\s+/, $status);
705 if ($stat && ($stat ne 'purge')) {
706 $pkglist->{$pkg} = $res;
719 my $veid = $self->{veid
};
721 my $res = { running
=> 0 };
723 $res->{exist
} = 1 if -d
"$self->{rootfs}/usr";
725 my $filename = "/proc/net/unix";
727 # similar test is used by lcxcontainers.c: list_active_containers
728 my $fh = IO
::File-
>new ($filename, "r");
731 while (defined(my $line = <$fh>)) {
732 if ($line =~ m/^[a-f0-9]+:\s\S+\s\S+\s\S+\s\S+\s\S+\s\d+\s(\S+)$/) {
734 if ($path =~ m!^@/\S+/$veid/command$!) {
745 my ($self, $cmd, $input) = @_;
747 my $veid = $self->{veid
};
748 my $conffile = $self->{veconffile
};
750 if (ref ($cmd) eq 'ARRAY') {
751 unshift @$cmd, 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--clear-env', '--', 'defenv';
752 $self->run_command ($cmd, $input);
754 $self->run_command ("lxc-attach -n $veid --rcfile $conffile --clear-env -- defenv $cmd", $input);
758 # like ve_command, but pipes stdin correctly
760 my ($self, @cmd) = @_;
762 my $veid = $self->{veid
};
763 my $conffile = $self->{veconffile
};
766 my $pid = open2
($reader, "<&STDIN", 'lxc-attach', '-n', $veid, '--rcfile', $conffile, '--',
767 'defenv', @cmd) || die "unable to exec command";
769 while (defined (my $line = <$reader>)) {
770 $self->logmsg ($line);
776 die "ve_exec failed - status $rc\n" if $rc != 0;
780 my ($self, $filename) = @_;
782 $self->ve_command ("dpkg-divert --add --divert '$filename.distrib' " .
783 "--rename '$filename'");
785 sub ve_divert_remove
{
786 my ($self, $filename) = @_;
788 my $rootdir = $self->{rootfs
};
790 unlink "$rootdir/$filename";
791 $self->ve_command ("dpkg-divert --remove --rename '$filename'");
794 sub ve_debconfig_set
{
795 my ($self, $dcdata) = @_;
797 my $rootdir = $self->{rootfs
};
798 my $cfgfile = "/tmp/debconf.txt";
799 write_file
($dcdata, "$rootdir/$cfgfile");
800 $self->ve_command ("debconf-set-selections $cfgfile");
801 unlink "$rootdir/$cfgfile";
804 sub ve_dpkg_set_selection
{
805 my ($self, $pkg, $status) = @_;
807 $self->ve_command ("dpkg --set-selections", "$pkg $status");
811 my ($self, $cmd, @pkglist) = @_;
813 return if !scalar (@pkglist);
815 my $pkginfo = $self->pkginfo();
817 my $rootdir = $self->{rootfs
};
818 my $cachedir = $self->{cachedir
};
822 foreach my $pkg (@pkglist) {
823 my $filename = $self->getpkgfile ($pkg);
824 $self->run_command ("cp '$cachedir/$filename' '$rootdir/$filename'");
825 push @files, "/$filename";
826 $self->logmsg ("$cmd: $pkg\n");
829 my $fl = join (' ', @files);
831 if ($cmd eq 'install') {
832 $self->ve_command ("dpkg --force-depends --force-confold --install $fl");
833 } elsif ($cmd eq 'unpack') {
834 $self->ve_command ("dpkg --force-depends --unpack $fl");
836 die "internal error";
839 foreach my $fn (@files) { unlink "$rootdir$fn"; }
845 my $veid = $self->{veid
}; # fixme
846 my $conffile = $self->{veconffile
};
848 my $vestat = $self->ve_status();
849 if ($vestat->{running
}) {
850 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
853 rmtree
$self->{rootfs
};
854 unlink $self->{veconffile
};
860 my $veid = $self->{veid
};
861 my $conffile = $self->{veconffile
};
863 $self->logmsg ("initialize VE $veid\n");
865 my $vestat = $self->ve_status();
866 if ($vestat->{running
}) {
867 $self->run_command ("lxc-stop -n $veid --rcfile $conffile --kill");
870 rmtree
$self->{rootfs
};
871 mkpath
$self->{rootfs
};
874 sub __deb_version_cmp
{
875 my ($cur, $op, $new) = @_;
877 if (system("dpkg", "--compare-versions", $cur, $op, $new) == 0) {
884 sub __parse_packages
{
885 my ($pkginfo, $filename, $src) = @_;
888 open (PKGLST
, "<$filename") ||
889 die "unable to open '$filename'";
891 while (my $rec = <PKGLST
>) {
898 while ($rec =~ s/^([^:]+):\s+(.*)\s*\n//) {
902 my $pkg = $res->{'package'};
903 if ($pkg && $res->{'filename'}) {
905 if (my $info = $pkginfo->{$pkg}) {
906 $cur = $info->{version
};
908 my $new = $res->{version
};
909 if (!$cur || __deb_version_cmp
($cur, 'lt', $new)) {
911 $res->{url
} = "$src/$res->{'filename'}";
913 die "no url for package '$pkg'" if !$res->{url
};
915 $pkginfo->{$pkg} = $res;
926 return $self->{pkginfo
} if $self->{pkginfo
};
928 my $infodir = $self->{infodir
};
929 my $arch = $self->{config
}->{architecture
};
931 my $availfn = "$infodir/available";
936 # reading 'available' is faster, because it only contains latest version
937 # (no need to do slow version compares)
939 __parse_packages
($pkginfo, $availfn);
940 $self->{pkginfo
} = $pkginfo;
944 $self->logmsg ("generating available package list\n");
946 foreach my $ss (@{$self->{sources
}}) {
947 foreach my $comp (@{$ss->{comp
}}) {
948 my $url = "$ss->{source}/dists/$ss->{suite}/$comp/binary-$arch/Packages";
949 my $pkgfilelist = "$infodir/" . __url_to_filename
($url);
951 my $src = $ss->{mirror
} || $ss->{source
};
953 __parse_packages
($pkginfo, $pkgfilelist, $src);
957 if (my $dep = $self->{config
}->{depends
}) {
958 foreach my $d (split (/,/, $dep)) {
959 if ($d =~ m/^\s*(\S+)\s*(\((\S+)\s+(\S+)\)\s*)?$/) {
960 my ($pkg, $op, $rver) = ($1, $3, $4);
961 $self->logmsg ("checking dependencies: $d\n");
962 my $info = $pkginfo->{$pkg};
963 die "package '$pkg' not available\n" if !$info;
965 my $cver = $info->{version
};
966 if (!__deb_version_cmp
($cver, $op, $rver)) {
967 die "detected wrong version '$cver'\n";
971 die "syntax error in depends field";
976 $self->{pkginfo
} = $pkginfo;
978 my $tmpfn = "$availfn.tmp$$";
979 my $fd = IO
::File-
>new (">$tmpfn");
980 foreach my $pkg (sort keys %$pkginfo) {
981 my $info = $pkginfo->{$pkg};
982 print $fd "package: $pkg\n";
983 foreach my $k (sort keys %$info) {
984 next if $k eq 'description';
985 next if $k eq 'package';
987 print $fd "$k: $v\n" if $v;
989 print $fd "description: $info->{description}\n" if $info->{description
};
994 rename ($tmpfn, $availfn);
999 sub __record_provides
{
1000 my ($pkginfo, $closure, $list, $skipself) = @_;
1002 foreach my $pname (@$list) {
1003 my $info = $pkginfo->{$pname};
1004 # fixme: if someone install packages directly using dpkg, there
1005 # is no entry in 'available', only in 'status'. In that case, we
1006 # should extract info from $instpkgs
1008 warn "hint: ignoring provides for '$pname' - package not in 'available' list.\n";
1011 if (my $prov = $info->{provides
}) {
1012 my @pl = split (',', $prov);
1013 foreach my $p (@pl) {
1015 if (!($skipself && (grep { $1 eq $_ } @$list))) {
1020 $closure->{$pname} = 1 if !$skipself;
1025 my ($self, $closure, $list) = @_;
1027 my $pkginfo = $self->pkginfo();
1029 # first, record provided packages
1030 __record_provides
($pkginfo, $closure, $list, 1);
1035 # then resolve dependencies
1036 foreach my $pname (@$list) {
1037 __closure_single
($pkginfo, $closure, $pkghash, $pkglist, $pname, $self->{excl
});
1043 sub __closure_single
{
1044 my ($pkginfo, $closure, $pkghash, $pkglist, $pname, $excl) = @_;
1048 $pname =~ s/:any$//;
1050 return if $closure->{$pname};
1052 my $info = $pkginfo->{$pname} || die "no such package '$pname'";
1054 my $dep = $info->{depends
};
1055 my $predep = $info->{'pre-depends'};
1057 my $size = $info->{size
};
1058 my $url = $info->{url
};
1060 $url || die "$pname: no url for package '$pname'";
1062 if (!$pkghash->{$pname}) {
1063 unshift @$pkglist, $pname;
1064 $pkghash->{$pname} = 1;
1067 __record_provides
($pkginfo, $closure, [$pname]) if $info->{provides
};
1069 $closure->{$pname} = 1;
1075 push @l, split (/,/, $predep) if $predep;
1076 push @l, split (/,/, $dep) if $dep;
1078 DEPEND
: foreach my $p (@l) {
1079 my @l1 = split (/\|/, $p);
1080 foreach my $p1 (@l1) {
1081 if ($p1 =~ m/^\s*(\S+).*/) {
1082 #printf (STDERR "$pname: $p --> $1\n");
1083 if ($closure->{$1}) {
1084 next DEPEND
; # dependency already met
1088 # search for non-excluded alternative
1090 foreach my $p1 (@l1) {
1091 if ($p1 =~ m/^\s*(\S+).*/) {
1092 next if grep { $1 eq $_ } @$excl;
1097 die "package '$pname' depends on exclusion '$p'\n" if !$found;
1099 #printf (STDERR "$pname: $p --> $found\n");
1101 __closure_single
($pkginfo, $closure, $pkghash, $pkglist, $found, $excl);
1105 sub cache_packages
{
1106 my ($self, $pkglist) = @_;
1108 foreach my $pkg (@$pkglist) {
1109 $self->getpkgfile ($pkg);
1114 my ($self, $pkg) = @_;
1116 my $pkginfo = $self->pkginfo();
1117 my $info = $pkginfo->{$pkg} || die "no such package '$pkg'";
1118 my $cachedir = $self->{cachedir
};
1120 my $url = $info->{url
};
1123 if ($url =~ m
|/([^/]+.deb
)$|) {
1126 die "internal error";
1129 return $filename if -f
"$cachedir/$filename";
1133 $self->download ($url, "$cachedir/$filename");
1138 sub install_init_script
{
1139 my ($self, $script, $runlevel, $prio) = @_;
1141 my $suite = $self->{config
}->{suite
};
1142 my $rootdir = $self->{rootfs
};
1144 my $base = basename
($script);
1145 my $target = "$rootdir/etc/init.d/$base";
1147 $self->run_command ("install -m 0755 '$script' '$target'");
1148 if ($suite eq 'etch' || $suite eq 'lenny') {
1149 $self->ve_command ("update-rc.d $base start $prio $runlevel .");
1150 } elsif ($suite eq 'xenial' || $suite eq 'wily' || $suite eq 'vivid' ||
1151 $suite eq 'yakkety' || $suite eq 'zesty' || $suite eq 'artful' ||
1152 $suite eq 'bionic') {
1153 die "unable to install init script (system uses systemd)\n";
1154 } elsif ($suite eq 'trusty' || $suite eq 'precise') {
1155 die "unable to install init script (system uses upstart)\n";
1157 $self->ve_command ("insserv $base");
1164 my ($self, $opts) = @_;
1166 my $pkginfo = $self->pkginfo();
1167 my $veid = $self->{veid
};
1168 my $suite = $self->{config
}->{suite
};
1170 my $important = [ @{$self->{incl
}} ];
1174 my $mta = $opts->{exim
} ?
'exim' : 'postfix';
1176 if ($mta eq 'postfix') {
1177 push @$important, "postfix";
1180 foreach my $p (sort keys %$pkginfo) {
1181 next if grep { $p eq $_ } @{$self->{excl
}};
1182 my $pri = $pkginfo->{$p}->{priority
};
1184 next if $mta ne 'exim' && $p =~ m/exim/;
1185 next if $p =~ m/(selinux|semanage|policycoreutils)/;
1187 push @$required, $p if $pri eq 'required';
1188 push @$important, $p if $pri eq 'important';
1189 push @$standard, $p if $pri eq 'standard' && !$opts->{minimal
};
1193 $required = $self->closure ($closure, $required);
1194 $important = $self->closure ($closure, $important);
1196 if (!$opts->{minimal
}) {
1197 push @$standard, 'xbase-clients';
1198 $standard = $self->closure ($closure, $standard);
1201 # test if we have all 'ubuntu-minimal' and 'ubuntu-standard' packages
1202 # except those explicitly excluded
1203 if ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1204 my $mdeps = $pkginfo->{'ubuntu-minimal'}->{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-minimal package '$pkg'\n";
1213 if (!$opts->{minimal
}) {
1214 $mdeps = $pkginfo->{'ubuntu-standard'}->{depends
};
1215 foreach my $d (split (/,/, $mdeps)) {
1216 if ($d =~ m/^\s*(\S+)$/) {
1218 next if $closure->{$pkg};
1219 next if grep { $pkg eq $_ } @{$self->{excl
}};
1220 die "missing ubuntu-standard package '$pkg'\n";
1226 # download/cache all files first
1227 $self->cache_packages ($required);
1228 $self->cache_packages ($important);
1229 $self->cache_packages ($standard);
1231 my $rootdir = $self->{rootfs
};
1233 # extract required packages first
1234 $self->logmsg ("create basic environment\n");
1235 foreach my $p (@$required) {
1236 my $filename = $self->getpkgfile ($p);
1237 my $content = $self->run_command("ar -t '$self->{cachedir}/$filename'", undef, 1);
1238 if ($content =~ m/^data.tar.xz$/m) {
1239 $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.xz | tar -C '$rootdir' -xJf -");
1241 $self->run_command ("ar -p '$self->{cachedir}/$filename' data.tar.gz | tar -C '$rootdir' -xzf -");
1246 my $data = "Package: dpkg\n" .
1247 "Version: $pkginfo->{dpkg}->{version}\n" .
1248 "Status: install ok installed\n";
1250 write_file
($data, "$rootdir/var/lib/dpkg/status");
1251 write_file
("", "$rootdir/var/lib/dpkg/info/dpkg.list");
1252 write_file
("", "$rootdir/var/lib/dpkg/available");
1255 foreach my $ss (@{$self->{sources
}}) {
1256 my $url = $ss->{source
};
1257 my $comp = join (' ', @{$ss->{comp
}});
1258 $data .= "deb $url $ss->{suite} $comp\n\n";
1261 write_file
($data, "$rootdir/etc/apt/sources.list");
1263 $data = "# UNCONFIGURED FSTAB FOR BASE SYSTEM\n";
1264 write_file
($data, "$rootdir/etc/fstab", 0644);
1266 write_file
("localhost\n", "$rootdir/etc/hostname", 0644);
1268 # avoid warnings about non-existent resolv.conf
1269 write_file
("", "$rootdir/etc/resolv.conf", 0644);
1271 if ($suite eq 'bionic' || $suite eq 'artful' || $suite eq 'zesty' ||
1272 $suite eq 'yakkety' || $suite eq 'xenial' || $suite eq 'wily') {
1273 # no need to configure loopback device
1275 $data = "auto lo\niface lo inet loopback\n";
1276 mkdir "$rootdir/etc/network";
1277 write_file
($data, "$rootdir/etc/network/interfaces", 0644);
1281 $self->run_command ("tar xzf '$devicetar' -C '$rootdir'");
1283 # avoid warnings about missing default locale
1284 write_file
("LANG=\"C\"\n", "$rootdir/etc/default/locale", 0644);
1287 rename ("$rootdir/sbin/init", "$rootdir/sbin/init.org");
1288 $self->run_command ("cp '$fake_init' '$rootdir/sbin/init'");
1290 $self->run_command ("cp '$default_env' '$rootdir/sbin/defenv'");
1292 $self->run_command ("lxc-start -n $veid -f $self->{veconffile}");
1294 $self->logmsg ("initialize ld cache\n");
1295 $self->ve_command ("/sbin/ldconfig");
1296 $self->run_command ("ln -sf mawk '$rootdir/usr/bin/awk'");
1298 $self->logmsg ("installing packages\n");
1300 $self->ve_dpkg ('install', 'base-files', 'base-passwd');
1302 $self->ve_dpkg ('install', 'dpkg');
1304 $self->run_command ("ln -sf /usr/share/zoneinfo/UTC '$rootdir/etc/localtime'");
1306 $self->run_command ("ln -sf bash '$rootdir/bin/sh'");
1308 $self->ve_dpkg ('install', 'libc6');
1309 $self->ve_dpkg ('install', 'perl-base');
1311 unlink "$rootdir/usr/bin/awk";
1313 $self->ve_dpkg ('install', 'mawk');
1314 $self->ve_dpkg ('install', 'debconf');
1316 # unpack required packages
1317 foreach my $p (@$required) {
1318 $self->ve_dpkg ('unpack', $p);
1321 rename ("$rootdir/sbin/init.org", "$rootdir/sbin/init");
1322 $self->ve_divert_add ("/sbin/init");
1323 $self->run_command ("cp '$fake_init' '$rootdir/sbin/init'");
1325 # disable service activation
1326 $self->ve_divert_add ("/usr/sbin/policy-rc.d");
1327 $data = "#!/bin/sh\nexit 101\n";
1328 write_file
($data, "$rootdir/usr/sbin/policy-rc.d", 755);
1330 # disable start-stop-daemon
1331 $self->ve_divert_add ("/sbin/start-stop-daemon");
1335 echo \"Warning: Fake start-stop-daemon called, doing nothing\"
1337 write_file
($data, "$rootdir/sbin/start-stop-daemon", 0755);
1340 $self->ve_divert_add ("/sbin/udevd");
1342 if ($suite eq 'etch') {
1343 # disable apache2 startup
1344 write_file
("NO_START=1\n", "$rootdir/etc/default/apache2");
1347 $self->logmsg ("configure required packages\n");
1348 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1350 # set postfix defaults
1351 if ($mta eq 'postfix') {
1352 $data = "postfix postfix/main_mailer_type select Local only\n";
1353 $self->ve_debconfig_set ($data);
1355 $data = "postmaster: root\nwebmaster: root\n";
1356 write_file
($data, "$rootdir/etc/aliases");
1359 if ($suite eq 'jaunty') {
1360 # jaunty does not create /var/run/network, so network startup fails.
1361 # so we do not use tmpfs for /var/run and /var/lock
1362 $self->run_command ("sed -e 's/RAMRUN=yes/RAMRUN=no/' -e 's/RAMLOCK=yes/RAMLOCK=no/' -i $rootdir/etc/default/rcS");
1363 # and create the directory here
1364 $self->run_command ("mkdir $rootdir/var/run/network");
1367 # unpack base packages
1368 foreach my $p (@$important) {
1369 $self->ve_dpkg ('unpack', $p);
1373 if (-x
"$rootdir/sbin/ifconfig") {
1374 $self->ve_command ("ifconfig lo up");
1376 $self->ve_command ("ip link set lo up");
1379 $self->logmsg ("configure important packages\n");
1380 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1382 if (-d
"$rootdir/etc/event.d") {
1383 unlink <$rootdir/etc/event.d
/tty
*>;
1386 if (-f
"$rootdir/etc/inittab") {
1387 $self->run_command ("sed -i -e '/getty\\s38400\\stty[23456]/d' '$rootdir/etc/inittab'");
1390 # Link /etc/mtab to /proc/mounts, so df and friends will work:
1391 unlink "$rootdir/etc/mtab";
1392 $self->ve_command ("ln -s /proc/mounts /etc/mtab");
1395 $self->ve_command ("usermod -L root");
1397 if ($mta eq 'postfix') {
1398 $data = "postfix postfix/main_mailer_type select No configuration\n";
1399 $self->ve_debconfig_set ($data);
1401 unlink "$rootdir/etc/mailname";
1402 write_file
($postfix_main_cf, "$rootdir/etc/postfix/main.cf");
1405 if (!$opts->{minimal
}) {
1406 # unpack standard packages
1407 foreach my $p (@$standard) {
1408 $self->ve_dpkg ('unpack', $p);
1411 $self->logmsg ("configure standard packages\n");
1412 $self->ve_command ("dpkg --force-confold --skip-same-version --configure -a");
1415 # disable HWCLOCK access
1416 $self->run_command ("echo 'HWCLOCKACCESS=no' >> '$rootdir/etc/default/rcS'");
1419 $self->ve_divert_add ("/usr/sbin/hald");
1421 # disable /dev/urandom init
1422 $self->run_command ("install -m 0755 '$script_init_urandom' '$rootdir/etc/init.d/urandom'");
1424 if ($suite eq 'etch' || $suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1426 $self->ve_divert_add ("/sbin/klogd");
1429 # remove unnecessays sysctl entries to avoid warnings
1431 $cmd .= ' -e \'s/^\(kernel\.printk.*\)/#\1/\'';
1432 $cmd .= ' -e \'s/^\(kernel\.maps_protect.*\)/#\1/\'';
1433 $cmd .= ' -e \'s/^\(fs\.inotify\.max_user_watches.*\)/#\1/\'';
1434 $cmd .= ' -e \'s/^\(vm\.mmap_min_addr.*\)/#\1/\'';
1435 $cmd .= " -i '$rootdir/etc/sysctl.conf'";
1436 $self->run_command ($cmd);
1438 my $bindv6only = "$rootdir/etc/sysctl.d/bindv6only.conf";
1439 if (-f
$bindv6only) {
1441 $cmd .= ' -e \'s/^\(net\.ipv6\.bindv6only.*\)/#\1/\'';
1442 $cmd .= " -i '$bindv6only'";
1443 $self->run_command ($cmd);
1446 if ($suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1447 # disable tty init (console-setup)
1449 $cmd .= ' -e \'s/^\(ACTIVE_CONSOLES=.*\)/ACTIVE_CONSOLES=/\'';
1450 $cmd .= " -i '$rootdir/etc/default/console-setup'";
1451 $self->run_command ($cmd);
1454 if ($suite eq 'intrepid') {
1455 # remove sysctl setup (avoid warnings at startup)
1456 my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
1457 $filelist .= " $rootdir/etc/sysctl.d/10-process-security.conf";
1458 $filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
1459 $self->run_command ("rm $filelist");
1461 if ($suite eq 'jaunty') {
1462 # remove sysctl setup (avoid warnings at startup)
1463 my $filelist = "$rootdir/etc/sysctl.d/10-console-messages.conf";
1464 $filelist .= " $rootdir/etc/sysctl.d/10-network-security.conf";
1465 $self->run_command ("rm $filelist");
1472 my $veid = $self->{veid
};
1473 my $conffile = $self->{veconffile
};
1475 my $vestat = $self->ve_status();
1477 if (!$vestat->{exist
}) {
1478 $self->logmsg ("Please create the appliance first (bootstrap)");
1482 if (!$vestat->{running
}) {
1483 $self->run_command ("lxc-start -n $veid -f $conffile");
1486 system ("lxc-attach -n $veid --rcfile $conffile --clear-env");
1489 sub ve_mysql_command
{
1490 my ($self, $sql, $password) = @_;
1492 #my $bootstrap = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables " .
1493 #"--skip-bdb --skip-innodb --skip-ndbcluster";
1495 $self->ve_command ("mysql", $sql);
1498 sub ve_mysql_bootstrap
{
1499 my ($self, $sql, $password) = @_;
1503 my $suite = $self->{config
}->{suite
};
1505 if ($suite eq 'jessie') {
1506 my $rootdir = $self->{rootfs
};
1507 $self->run_command ("sed -e 's/^key_buffer\\s*=/key_buffer_size =/' -i $rootdir/etc/mysql/my.cnf");
1510 if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie') {
1511 $cmd = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables";
1514 $cmd = "/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables " .
1515 "--skip-bdb --skip-innodb --skip-ndbcluster";
1518 $self->ve_command ($cmd, $sql);
1521 sub compute_required
{
1522 my ($self, $pkglist) = @_;
1524 my $pkginfo = $self->pkginfo();
1525 my $instpkgs = $self->read_installed ();
1528 __record_provides
($pkginfo, $closure, [keys %$instpkgs]);
1530 return $self->closure ($closure, $pkglist);
1534 my ($self, $opts) = @_;
1536 my @supp = ('7.4', '8.1');
1537 my $pgversion = '8.1';
1539 my $suite = $self->{config
}->{suite
};
1541 if ($suite eq 'lenny' || $suite eq 'hardy' || $suite eq 'intrepid' || $suite eq 'jaunty') {
1544 } elsif ($suite eq 'squeeze') {
1547 } elsif ($suite eq 'wheezy') {
1550 } elsif ($suite eq 'jessie') {
1553 } elsif ($suite eq 'stretch') {
1558 $pgversion = $opts->{version
} if $opts->{version
};
1560 die "unsupported postgres version '$pgversion'\n"
1561 if !grep { $pgversion eq $_; } @supp;
1563 my $rootdir = $self->{rootfs
};
1565 my $required = $self->compute_required (["postgresql-$pgversion"]);
1567 $self->cache_packages ($required);
1569 $self->ve_dpkg ('install', @$required);
1571 my $iscript = "postgresql-$pgversion";
1572 if ($suite eq 'squeeze' || $suite eq 'wheezy' || $suite eq 'jessie' ||
1573 $suite eq 'stretch') {
1574 $iscript = 'postgresql';
1577 $self->ve_command ("/etc/init.d/$iscript start") if $opts->{start
};
1581 my ($self, $opts) = @_;
1583 my $password = $opts->{password
};
1584 my $rootdir = $self->{rootfs
};
1586 my $suite = $self->{config
}->{suite
};
1589 if ($suite eq 'squeeze') {
1591 } elsif ($suite eq 'wheezy' || $suite eq 'jessie') {
1594 die "task_mysql: unsupported suite '$suite'";
1597 my $required = $self->compute_required (['mysql-common', "mysql-server-$ver"]);
1599 $self->cache_packages ($required);
1601 $self->ve_dpkg ('install', @$required);
1603 # fix security (see /usr/bin/mysql_secure_installation)
1604 my $sql = "DELETE FROM mysql.user WHERE User='';\n" .
1605 "DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';\n" .
1606 "FLUSH PRIVILEGES;\n";
1607 $self->ve_mysql_bootstrap ($sql);
1611 my $rpw = $password eq 'random' ?
'admin' : $password;
1613 my $sql = "USE mysql;\n" .
1614 "UPDATE user SET password=PASSWORD(\"$rpw\") WHERE user
='root';\n" .
1615 "FLUSH PRIVILEGES
;\n";
1616 $self->ve_mysql_bootstrap ($sql);
1618 write_file ("[client
]\nuser
=root
\npassword
=\"$rpw\"\n", "$rootdir/root/.my.cnf", 0600);
1619 if ($password eq 'random') {
1620 $self->install_init_script ($script_mysql_randompw, 2, 20);
1624 $self->ve_command ("/etc/init.d/mysql start") if $opts->{start
};
1628 my ($self, $opts) = @_;
1630 my $memlimit = $opts->{memlimit
};
1631 my $rootdir = $self->{rootfs
};
1633 my $required = $self->compute_required ([qw
(php5 php5-cli libapache2-mod-php5 php5-gd
)]);
1635 $self->cache_packages ($required);
1637 $self->ve_dpkg ('install', @$required);
1640 $self->run_command ("sed -e 's/^\\s*memory_limit\\s*=.*;/memory_limit = ${memlimit}M;/' -i $rootdir/etc/php5/apache2/php.ini");
1645 my ($self, $pkglist, $unpack) = @_;
1647 my $required = $self->compute_required ($pkglist);
1649 $self->cache_packages ($required);
1651 $self->ve_dpkg ($unpack ?
'unpack' : 'install', @$required);
1655 my ($self, $distclean) = @_;
1657 unlink $self->{logfile
};
1658 unlink "$self->{targetname}.tar";
1659 unlink "$self->{targetname}.tar.gz";
1661 $self->ve_destroy ();
1664 rmtree
$self->{cachedir
} if $distclean && !$self->{config
}->{cachedir
};
1666 rmtree
$self->{infodir
};