create temporary apt.conf inside chroot because unshared process might not have permissions to write into TMPDIR

This commit is contained in:
Johannes 'josch' Schauer 2020-03-07 02:11:35 +01:00
parent 9918809a65
commit 3e50d09b43
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1185,7 +1185,12 @@ sub setup {
warning "cannot read $options->{apttrustedparts}";
}
my ($conf, $tmpfile) = tempfile(UNLINK => 1)
# We create the temporary apt.conf inside the rootfs as an easy way to make
# sure that the unshared process is able to create it even if the user has
# TMPDIR set to a directory that the unshared process does not directly
# have access to.
my ($conf, $tmpfile)
= tempfile("mmdebstrap.apt.conf.XXXXXXXXXXXX", DIR => $options->{root})
or error "cannot open apt.conf: $!";
print $conf "Apt::Architecture \"$options->{nativearch}\";\n";
# the host system might have configured additional architectures
@ -2331,6 +2336,7 @@ sub setup {
});
run_apt_progress(
{ ARGV => ['apt-get', 'clean'], CHDIR => $options->{root} });
unlink $tmpfile or error "failed to unlink $tmpfile: $!";
# apt since 1.6 creates the auxfiles directory. If apt inside the chroot
# is older than that, then it will not know how to clean it.