avoid glob() because it splits its argument on whitespace

This commit is contained in:
Johannes 'josch' Schauer 2018-09-21 20:32:07 +02:00
parent 56688b2fde
commit 42d9141970
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -644,9 +644,33 @@ sub setup {
}
# extract the downloaded packages
my $num_essential = 0;
foreach my $deb (glob "$options->{root}/var/cache/apt/archives/*.deb") {
$num_essential++;
my $apt_archives = "$options->{root}/var/cache/apt/archives/";
my @essential_pkgs;
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
# merged-usr symlinks with plain directories
pipe my $rfh, my $wfh;
@ -665,16 +689,6 @@ sub setup {
waitpid($pid2, 0);
$? == 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') {
$ENV{FAKECHROOT_CMD_SUBST} = join ':', (