From: Raphael Hertzog Date: Wed, 26 Sep 2007 21:05:23 +0000 (+0200) Subject: dpkg-shlibdeps: add support of $ORIGIN in RPATH entries X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2e57dbefaa554a908b83f61d48a39f1e484dea9;p=dpkg dpkg-shlibdeps: add support of $ORIGIN in RPATH entries $ORIGIN is a synonym for "directory of the current file" and should be replaced by the corresponding value dynamicly. --- diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index cc188532..a6378113 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -7,6 +7,7 @@ use English; use POSIX qw(:errno_h :signal_h); use Dpkg; use Dpkg::Gettext; +use Dpkg::Path qw(relative_to_pkg_root); use Dpkg::Version qw(vercmp); use Dpkg::Shlibs qw(find_library); use Dpkg::Shlibs::Objdump; @@ -96,9 +97,9 @@ foreach my $file (keys %exec) { # Load symbols files for all needed libraries (identified by SONAME) my %libfiles; foreach my $soname (@sonames) { - my $file = my_find_library($soname, $obj->{RPATH}, $obj->{format}); - failure(sprintf(_g("couldn't find library %s (note: only packages with 'shlibs' files are looked into)."), $soname)) unless defined($file); - $libfiles{$file} = $soname if defined($file); + my $lib = my_find_library($soname, $obj->{RPATH}, $obj->{format}, $file); + failure(sprintf(_g("couldn't find library %s (note: only packages with 'shlibs' files are looked into)."), $soname)) unless defined($lib); + $libfiles{$lib} = $soname if defined($lib); } my $file2pkg = find_packages(keys %libfiles); my $symfile = Dpkg::Shlibs::SymbolFile->new(); @@ -413,21 +414,33 @@ sub symfile_has_soname { # find_library ($soname, \@rpath, $format) sub my_find_library { - my ($lib, $rpath, $format) = @_; + my ($lib, $rpath, $format, $execfile) = @_; my $file; + # Create real RPATH in case $ORIGIN is used + # Note: ld.so also supports $PLATFORM and $LIB but they are + # used in real case (yet) + my $origin = "/" . relative_to_pkg_root($execfile); + $origin =~ s{/+[^/]*$}{}; + my @RPATH = (); + foreach my $path (@{$rpath}) { + $path =~ s/\$ORIGIN/$origin/g; + $path =~ s/\$\{ORIGIN\}/$origin/g; + push @RPATH, $path; + } + # Look into the packages we're currently building (but only those # that provides shlibs file...) # TODO: we should probably replace that by a cleaner way to look into # the various temporary build directories... foreach my $builddir (map { s{/DEBIAN/shlibs$}{}; $_ } @pkg_shlibs) { - $file = find_library($lib, $rpath, $format, $builddir); + $file = find_library($lib, \@RPATH, $format, $builddir); return $file if defined($file); } # Fallback in the root directory if we have not found what we were # looking for in the packages - $file = find_library($lib, $rpath, $format, ""); + $file = find_library($lib, \@RPATH, $format, ""); return $file if defined($file); return undef;