Instead of adding a fake ldconfig to the chroot, use FAKECHROOT_CMD_SUBST

This commit is contained in:
Johannes 'josch' Schauer 2018-09-18 16:59:02 +02:00
parent 4f293ebf0d
commit 87586fa667
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -634,20 +634,14 @@ sub setup {
die "nothing got downloaded. used file:// uri instead of copy://?"; die "nothing got downloaded. used file:// uri instead of copy://?";
} }
# A fake ldconfig is needed for the installation of libc-bin
if ($options->{mode} eq 'fakechroot') { if ($options->{mode} eq 'fakechroot') {
move("$options->{root}/sbin/ldconfig", "$options->{root}/sbin/ldconfig.REAL") or die "cannot move ldconfig"; $ENV{FAKECHROOT_CMD_SUBST} = join ':', (
open my $fh, '>', "$options->{root}/sbin/ldconfig" or die "cannot open ldconfig: $!"; '/bin/mount=/bin/true',
print $fh "#!/bin/sh\n"; '/usr/bin/env=/usr/bin/env.fakechroot',
print $fh "echo \"Warning: Fake ldconfig called, doing nothing\">&2\n"; '/usr/bin/ldd=/usr/bin/ldd.fakechroot',
close $fh; '/usr/bin/mkfifo=/bin/true',
chmod 0755, "$options->{root}/sbin/ldconfig" or die "cannot chmod ldconfig: $!"; '/usr/sbin/ldconfig=/bin/true',
} );
# make sure that ldconfig is not overwritten by dpkg
if ($options->{mode} eq 'fakechroot') {
open my $fh, '>', "$options->{root}/var/lib/dpkg/diversions" or die "cannot open /var/lib/dpkg/diversions: $!";
print $fh "/sbin/ldconfig\n/sbin/ldconfig.REAL\nfakechroot\n";
close $fh;
} }
my @chrootcmd = ('/usr/sbin/chroot', $options->{root}); my @chrootcmd = ('/usr/sbin/chroot', $options->{root});
@ -814,11 +808,6 @@ sub setup {
0 == system(@chrootcmd, 'apt-get', 'clean') or die "apt-get clean failed: $?"; 0 == system(@chrootcmd, 'apt-get', 'clean') or die "apt-get clean failed: $?";
} }
if ($options->{mode} eq 'fakechroot') {
unlink "$options->{root}/sbin/ldconfig" or die "cannot unlink ldconfig";
0 == system('/usr/sbin/chroot', $options->{root}, 'dpkg-divert', '--package', 'fakechroot', '--rename', '--remove', '/sbin/ldconfig') or die "cannot remove diversion";
}
# clean up certain files to make output reproducible # clean up certain files to make output reproducible
unlink "$options->{root}/var/log/dpkg.log"; unlink "$options->{root}/var/log/dpkg.log";
unlink "$options->{root}/var/log/apt/history.log"; unlink "$options->{root}/var/log/apt/history.log";