improve fakechroot LD_LIBRARY_PATH
- use /etc/ld.so.conf from the chroot instead of the host - parse /etc/ld.so.conf instead of blindly accessing /etc/ld.so.conf.d - add libraries from the chroot instead of the host
This commit is contained in:
parent
f5f6343622
commit
2c945e4c87
1 changed files with 29 additions and 22 deletions
47
mmdebstrap
47
mmdebstrap
|
@ -2697,17 +2697,6 @@ sub run_prepare {
|
|||
$ENV{FAKECHROOT_AF_UNIX_PATH} = "/tmp";
|
||||
}
|
||||
{
|
||||
my @ldsoconf = ('/etc/ld.so.conf');
|
||||
opendir(my $dh, '/etc/ld.so.conf.d')
|
||||
or error "Can't opendir(/etc/ld.so.conf.d): $!";
|
||||
while (my $entry = readdir $dh) {
|
||||
# skip the "." and ".." entries
|
||||
next if $entry eq ".";
|
||||
next if $entry eq "..";
|
||||
next if $entry !~ /\.conf$/;
|
||||
push @ldsoconf, "/etc/ld.so.conf.d/$entry";
|
||||
}
|
||||
closedir($dh);
|
||||
my @ldlibpath = ();
|
||||
if (defined $ENV{LD_LIBRARY_PATH}
|
||||
&& $ENV{LD_LIBRARY_PATH} ne "") {
|
||||
|
@ -2715,16 +2704,35 @@ sub run_prepare {
|
|||
}
|
||||
# FIXME: workaround allowing installation of systemd should
|
||||
# live in fakechroot, see #917920
|
||||
push @ldlibpath, "/lib/systemd";
|
||||
foreach my $fname (@ldsoconf) {
|
||||
open my $fh, "<", $fname
|
||||
or error "cannot open $fname for reading: $!";
|
||||
push @ldlibpath, "$options->{root}/lib/systemd";
|
||||
my $parse_ld_so_conf;
|
||||
$parse_ld_so_conf = sub {
|
||||
foreach my $conf (@_) {
|
||||
next if !-r $conf;
|
||||
open my $fh, '<', "$conf" or error "can't read $conf: $!";
|
||||
while (my $line = <$fh>) {
|
||||
next if $line !~ /^\//;
|
||||
push @ldlibpath, $line;
|
||||
chomp $line;
|
||||
if ($line eq "") {
|
||||
next;
|
||||
}
|
||||
if ($line =~ /^#/) {
|
||||
next;
|
||||
}
|
||||
if ($line =~ /include (.*)/) {
|
||||
$parse_ld_so_conf->(glob("$options->{root}/$1"));
|
||||
next;
|
||||
}
|
||||
if (!-d "$options->{root}/$line") {
|
||||
next;
|
||||
}
|
||||
push @ldlibpath, "$options->{root}/$line";
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
};
|
||||
if (-e "$options->{root}/etc/ld.so.conf") {
|
||||
$parse_ld_so_conf->("$options->{root}/etc/ld.so.conf");
|
||||
}
|
||||
## no critic (Variables::RequireLocalizedPunctuationVars)
|
||||
$ENV{LD_LIBRARY_PATH} = join ':', @ldlibpath;
|
||||
}
|
||||
|
@ -6483,9 +6491,8 @@ fakeroot.env> and use C<fakeroot.env> later when entering the chroot with
|
|||
C<fakechroot fakeroot -i fakeroot.env chroot ...>. This mode will not work if
|
||||
maintainer scripts are unable to handle C<LD_PRELOAD> correctly like the
|
||||
package B<initramfs-tools> until version 0.132. This mode will also not work
|
||||
with a different libc inside the chroot than on the outside. Since ldconfig
|
||||
cannot run under fakechroot, the final system will not contain
|
||||
F</etc/ld.so.cache>. See the section B<LIMITATIONS> in B<fakechroot(1)>.
|
||||
with a different libc inside the chroot than on the outside. See the section
|
||||
B<LIMITATIONS> in B<fakechroot(1)>.
|
||||
|
||||
=item B<proot>
|
||||
|
||||
|
|
Loading…
Reference in a new issue