The following commit has been merged in the master branch:
commit 7b73dab6a83ae643361ae5868649a6e2f1b05139
Author: Guillem Jover <[email protected]>
Date:   Thu Jul 18 03:58:18 2013 +0200

    dpkg-shlibdeps: New option -l to add private shared library directories
    
    This allows to specify additional build-time shared library directories
    without requiring the caller to set LD_LIBRARY_PATH, which is a run-time
    dynamic linker variable, and abusing it might be problematic for example
    when cross-compiling.
    
    While accepting colon-separated paths might seem tempting, it disallows
    valid paths with colons, while not common on system paths, these could
    be present on user paths, which makes this a bad interface to have.
    
    Closes: #698881

diff --git a/debian/changelog b/debian/changelog
index a11b7f1..8093240 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -135,6 +135,9 @@ dpkg (1.17.0) UNRELEASED; urgency=low
   * Fix value caching in Dpkg::Arch by not shadowing the variables.
   * Fix chmod() arguments order in Dpkg::Source::Quilt. Closes: #710265
     Thanks to Pablo Oliveira <[email protected]>.
+  * Add new dpkg-shlibdeps -l option to add private shared library directories.
+    This should be used instead of abusing LD_LIBRARY_PATH to pass the paths,
+    which might be problematic when cross-compiling. Closes: #698881
 
   [ Raphaël Hertzog ]
   * Fix dpkg-maintscript-helper rm_conffile and mv_conffile to do nothing
diff --git a/man/dpkg-shlibdeps.1 b/man/dpkg-shlibdeps.1
index a5abf88..315b4cb 100644
--- a/man/dpkg-shlibdeps.1
+++ b/man/dpkg-shlibdeps.1
@@ -4,7 +4,7 @@
 .\" Copyright © 2000 Wichert Akkerman <[email protected]>
 .\" Copyright © 2006 Frank Lichtenheld <[email protected]>
 .\" Copyright © 2007-2011 Raphaël Hertzog <[email protected]>
-.\" Copyright © 2012 Guillem Jover <[email protected]>
+.\" Copyright © 2012-2013 Guillem Jover <[email protected]>
 .\"
 .\" This is free software; you can redistribute it and/or modify
 .\" it under the terms of the GNU General Public License as published by
@@ -136,6 +136,17 @@ been supplied as
 Include dependencies appropriate for the shared libraries required by
 .IR executable .
 .TP
+.BI \-l directory
+Add
+.I directory
+to the list of directories to search for private shared libraries
+(since dpkg 1.17.0). This option can be used multiple times.
+
+Note: Use this option instead of setting \fBLD_LIBRARY_PATH\fP,
+as that environment variable is used to control the run-time linker
+and abusing it to set the shared library paths at build-time can be
+problematic when cross-compiling for example.
+.TP
 .BI \-d dependency-field
 Add dependencies to be added to the control file dependency field
 .IR dependency-field .
@@ -301,6 +312,7 @@ has been unable to find the library.
 .B dpkg\-shlibdeps
 creates a list of directories to check as following: directories listed in
 the RPATH of the binary, directories listed in /etc/ld.so.conf,
+directories added by the \fB\-l\fP option,
 directories listed in the \fBLD_LIBRARY_PATH\fP environment variable, and
 standard public directories (/lib, /usr/lib, /lib32, /usr/lib32, /lib64,
 /usr/lib64). Then it checks those directories in the package's build tree
@@ -311,9 +323,9 @@ If the library is not found in any of those directories, 
then you get this
 error.
 
 If the library not found is in a private directory of the same package,
-then you want to add the directory to \fBLD_LIBRARY_PATH\fP. If it's in another
+then you want to add the directory with \fB\-l\fP. If it's in another
 binary package being built, you want to make sure that the shlibs/symbols
-file of this package is already created and that \fBLD_LIBRARY_PATH\fP
+file of this package is already created and that \fB\-l\fP
 contains the appropriate directory if it also is in a private directory.
 .TP
 .BI "no dependency information found for " library-file " (used by " binary 
")."
diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm
index df0ebee..c3c3445 100644
--- a/scripts/Dpkg/Shlibs.pm
+++ b/scripts/Dpkg/Shlibs.pm
@@ -21,7 +21,7 @@ use warnings;
 our $VERSION = '0.01';
 
 use Exporter qw(import);
-our @EXPORT_OK = qw(@librarypaths find_library);
+our @EXPORT_OK = qw(@librarypaths find_library add_library_dir);
 
 use File::Spec;
 
@@ -67,11 +67,11 @@ if ($crossprefix) {
 
 our @librarypaths = (DEFAULT_LIBRARY_PATH, @crosslibrarypaths);
 
-# Update library paths with LD_LIBRARY_PATH
+# XXX: Deprecated. Update library paths with LD_LIBRARY_PATH
 if ($ENV{LD_LIBRARY_PATH}) {
     foreach my $path (reverse split( /:/, $ENV{LD_LIBRARY_PATH} )) {
        $path =~ s{/+$}{};
-       unshift @librarypaths, $path;
+       add_library_dir($path);
     }
 }
 
@@ -103,6 +103,11 @@ sub parse_ldso_conf {
     close $fh;
 }
 
+sub add_library_dir {
+    my ($dir) = @_;
+    unshift @librarypaths, $dir;
+}
+
 # find_library ($soname, \@rpath, $format, $root)
 sub find_library {
     my ($lib, $rpath, $format, $root) = @_;
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
index 250b8bc..9485397 100755
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@ -87,6 +87,8 @@ foreach (@ARGV) {
        $varnameprefix = $1;
     } elsif (m/^-L(.*)$/) {
        $shlibslocal = $1;
+    } elsif (m/^-l(.*)$/) {
+       Dpkg::Shlibs::add_library_dir($1);
     } elsif (m/^-S(.*)$/) {
        push @pkg_dir_to_search, $1;
     } elsif (m/^-O$/) {
@@ -441,7 +443,7 @@ foreach my $soname (keys %global_soname_needed) {
 if ($error_count >= 1) {
     my $note = _g('Note: libraries are not searched in other binary packages ' 
.
        "that do not have any shlibs or symbols file.\nTo help dpkg-shlibdeps " 
.
-       'find private libraries, you might need to set LD_LIBRARY_PATH.');
+       'find private libraries, you might need to use -l.');
     error(P_('cannot continue due to the error above',
              'cannot continue due to the errors listed above',
              $error_count) . "\n" . $note);
@@ -560,6 +562,7 @@ sub usage {
   -d<dependency-field>     next executable(s) set shlibs:<dependency-field>.")
     . "\n\n" . _g(
 "Options:
+  -l<library-dir>          add directory to private shared library search list.
   -p<varname-prefix>       set <varname-prefix>:* instead of shlibs:*.
   -O                       print variable settings to stdout.
   -L<local-shlibs-file>    shlibs override file, not debian/shlibs.local.

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]


Reply via email to