forked from josch/mmdebstrap
avoid glob() because it splits its argument on whitespace
This commit is contained in:
parent
56688b2fde
commit
42d9141970
1 changed files with 27 additions and 13 deletions
40
mmdebstrap
40
mmdebstrap
|
@ -644,9 +644,33 @@ sub setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
# extract the downloaded packages
|
# extract the downloaded packages
|
||||||
my $num_essential = 0;
|
my $apt_archives = "$options->{root}/var/cache/apt/archives/";
|
||||||
foreach my $deb (glob "$options->{root}/var/cache/apt/archives/*.deb") {
|
my @essential_pkgs;
|
||||||
$num_essential++;
|
opendir my $dh, $apt_archives or die "cannot read $apt_archives";
|
||||||
|
while (my $deb = readdir $dh) {
|
||||||
|
if ($deb !~ /\.deb$/) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$deb = "$apt_archives/$deb";
|
||||||
|
if (!-f $deb) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
push @essential_pkgs, $deb;
|
||||||
|
}
|
||||||
|
close $dh;
|
||||||
|
|
||||||
|
if (scalar @essential_pkgs == 0) {
|
||||||
|
# check if a file:// URI was used
|
||||||
|
open(my $pipe_apt, '-|', 'apt-get', 'indextargets', '--format', '$(URI)', 'Created-By: Packages') or die "cannot start apt-get indextargets: $!";
|
||||||
|
while (my $uri = <$pipe_apt>) {
|
||||||
|
if ($uri =~ /^file:\/\//) {
|
||||||
|
die "nothing got downloaded -- use copy:// instead of file://";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
die "nothing got downloaded";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $deb (@essential_pkgs) {
|
||||||
# not using dpkg-deb --extract as that would replace the
|
# not using dpkg-deb --extract as that would replace the
|
||||||
# merged-usr symlinks with plain directories
|
# merged-usr symlinks with plain directories
|
||||||
pipe my $rfh, my $wfh;
|
pipe my $rfh, my $wfh;
|
||||||
|
@ -665,16 +689,6 @@ sub setup {
|
||||||
waitpid($pid2, 0);
|
waitpid($pid2, 0);
|
||||||
$? == 0 or die "tar --extract failed: $?";
|
$? == 0 or die "tar --extract failed: $?";
|
||||||
}
|
}
|
||||||
if ($num_essential == 0) {
|
|
||||||
# check if a file:// URI was used
|
|
||||||
open(my $pipe_apt, '-|', 'apt-get', 'indextargets', '--format', '$(URI)', 'Created-By: Packages') or die "cannot start apt-get indextargets: $!";
|
|
||||||
while (my $uri = <$pipe_apt>) {
|
|
||||||
if ($uri =~ /^file:\/\//) {
|
|
||||||
die "nothing got downloaded -- use copy:// instead of file://";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
die "nothing got downloaded";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($options->{mode} eq 'fakechroot') {
|
if ($options->{mode} eq 'fakechroot') {
|
||||||
$ENV{FAKECHROOT_CMD_SUBST} = join ':', (
|
$ENV{FAKECHROOT_CMD_SUBST} = join ':', (
|
||||||
|
|
Loading…
Reference in a new issue