do not use 'dpkg --install --recursive' because we cannot have a progress bar without knowing how many packages we install
This commit is contained in:
parent
42d9141970
commit
fe060e6cad
1 changed files with 43 additions and 15 deletions
42
mmdebstrap
42
mmdebstrap
|
@ -644,20 +644,22 @@ sub setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
# extract the downloaded packages
|
# extract the downloaded packages
|
||||||
my $apt_archives = "$options->{root}/var/cache/apt/archives/";
|
|
||||||
my @essential_pkgs;
|
my @essential_pkgs;
|
||||||
opendir my $dh, $apt_archives or die "cannot read $apt_archives";
|
{
|
||||||
|
my $apt_archives = "/var/cache/apt/archives/";
|
||||||
|
opendir my $dh, "$options->{root}/$apt_archives" or die "cannot read $apt_archives";
|
||||||
while (my $deb = readdir $dh) {
|
while (my $deb = readdir $dh) {
|
||||||
if ($deb !~ /\.deb$/) {
|
if ($deb !~ /\.deb$/) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$deb = "$apt_archives/$deb";
|
$deb = "$apt_archives/$deb";
|
||||||
if (!-f $deb) {
|
if (!-f "$options->{root}/$deb") {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
push @essential_pkgs, $deb;
|
push @essential_pkgs, $deb;
|
||||||
}
|
}
|
||||||
close $dh;
|
close $dh;
|
||||||
|
}
|
||||||
|
|
||||||
if (scalar @essential_pkgs == 0) {
|
if (scalar @essential_pkgs == 0) {
|
||||||
# check if a file:// URI was used
|
# check if a file:// URI was used
|
||||||
|
@ -677,7 +679,7 @@ sub setup {
|
||||||
my $pid1 = fork() // die "fork() failed: $!";
|
my $pid1 = fork() // die "fork() failed: $!";
|
||||||
if ($pid1 == 0) {
|
if ($pid1 == 0) {
|
||||||
open(STDOUT, '>&', $wfh);
|
open(STDOUT, '>&', $wfh);
|
||||||
exec 'dpkg-deb', '--fsys-tarfile', $deb;
|
exec 'dpkg-deb', '--fsys-tarfile', "$options->{root}/$deb";
|
||||||
}
|
}
|
||||||
my $pid2 = fork() // die "fork() failed: $!";
|
my $pid2 = fork() // die "fork() failed: $!";
|
||||||
if ($pid2 == 0) {
|
if ($pid2 == 0) {
|
||||||
|
@ -771,7 +773,7 @@ sub setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
# install the extracted packages properly
|
# install the extracted packages properly
|
||||||
0 == system(@chrootcmd, 'dpkg', '--install', '--force-depends', '--recursive', File::Spec->abs2rel("$options->{root}/var/cache/apt/archives/", $options->{root})) or die "dpkg --install failed: $?";
|
0 == system(@chrootcmd, 'dpkg', '--install', '--force-depends', @essential_pkgs) or die "dpkg --install failed: $?";
|
||||||
|
|
||||||
# if the path-excluded option was added to the dpkg config, reinstall all
|
# if the path-excluded option was added to the dpkg config, reinstall all
|
||||||
# packages
|
# packages
|
||||||
|
@ -782,10 +784,14 @@ sub setup {
|
||||||
if ($num_matches > 0) {
|
if ($num_matches > 0) {
|
||||||
# without --skip-same-version, dpkg will install the given
|
# without --skip-same-version, dpkg will install the given
|
||||||
# packages even though they are already installed
|
# packages even though they are already installed
|
||||||
0 == system(@chrootcmd, 'dpkg', '--install', '--recursive', File::Spec->abs2rel("$options->{root}/var/cache/apt/archives/", $options->{root})) or die "dpkg --install failed: $?";
|
0 == system(@chrootcmd, 'dpkg', '--install', @essential_pkgs) or die "dpkg --install failed: $?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach my $deb (@essential_pkgs) {
|
||||||
|
unlink "$options->{root}/$deb" or die "cannot unlink $deb";
|
||||||
|
}
|
||||||
|
|
||||||
if (%pkgs_to_install) {
|
if (%pkgs_to_install) {
|
||||||
# some packages have to be installed from the outside before anything
|
# some packages have to be installed from the outside before anything
|
||||||
# can be installed from the inside.
|
# can be installed from the inside.
|
||||||
|
@ -818,7 +824,29 @@ sub setup {
|
||||||
|
|
||||||
if (%pkgs_to_install_from_outside) {
|
if (%pkgs_to_install_from_outside) {
|
||||||
0 == system('apt-get', '--yes', 'install', (keys %pkgs_to_install_from_outside)) or die "apt-get install failed: $?";
|
0 == system('apt-get', '--yes', 'install', (keys %pkgs_to_install_from_outside)) or die "apt-get install failed: $?";
|
||||||
0 == system(@chrootcmd, 'dpkg', '--install', '--skip-same-version', '--recursive', File::Spec->abs2rel("$options->{root}/var/cache/apt/archives/", $options->{root})) or die "dpkg --install failed: $?";
|
my @debs_to_install;
|
||||||
|
my $apt_archives = "/var/cache/apt/archives/";
|
||||||
|
opendir my $dh, "$options->{root}/$apt_archives" or die "cannot read $apt_archives";
|
||||||
|
while (my $deb = readdir $dh) {
|
||||||
|
if ($deb !~ /\.deb$/) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$deb = "$apt_archives/$deb";
|
||||||
|
if (!-f "$options->{root}/$deb") {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
push @debs_to_install, $deb;
|
||||||
|
}
|
||||||
|
close $dh;
|
||||||
|
if (scalar @debs_to_install == 0) {
|
||||||
|
die "nothing got downloaded";
|
||||||
|
}
|
||||||
|
# we need --force-depends because dpkg does not take Pre-Depends
|
||||||
|
# into account and thus doesn't install them in the right order
|
||||||
|
0 == system(@chrootcmd, 'dpkg', '--install', '--force-depends', @debs_to_install) or die "dpkg --install failed: $?";
|
||||||
|
foreach my $deb (@debs_to_install) {
|
||||||
|
unlink "$options->{root}/$deb" or die "cannot unlink $deb";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# from now on, apt will be executed inside the chroot
|
# from now on, apt will be executed inside the chroot
|
||||||
|
|
Loading…
Reference in a new issue