From fd4af2bc4801af30c4145dce30a3e2591ad223a6 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Thu, 3 Jan 2008 20:41:21 +0100 Subject: [PATCH] dpkg-shlibdeps: Add a new -S option * scripts/dpkg-shlibdeps.pl: Add a new -S option to indicate a package build tree that should be scanned first when trying to find a library. * man/dpkg-shlibdeps.1: Document the new -S option. --- ChangeLog | 5 +++++ debian/changelog | 2 ++ man/dpkg-shlibdeps.1 | 16 ++++++++++++---- scripts/dpkg-shlibdeps.pl | 27 +++++++++++++++++++-------- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8670bf8..1d442cd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,11 @@ a shlibs file). * man/dpkg-shlibdeps.1: Document the change listed above. + * scripts/dpkg-shlibdeps.pl: Add a new -S option to + indicate a package build tree that should be scanned first when + trying to find a library. + * man/dpkg-shlibdeps.1: Document the new -S option. + 2008-01-03 Guillem Jover * scripts/dpkg-buildpackage.pl: Do not automatically enable '-j' diff --git a/debian/changelog b/debian/changelog index 38afc068..9ace4494 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ dpkg (1.14.15) UNRELEASED; urgency=low * Fix typos in various manpages. Patch from A. Costa. Closes: #458276 * Make dpkg-shlibdeps choose the right symbols files when we have several debian/*/DEBIAN/symbols for a given soname. Closes: #458860 + * Add a -S option to dpkg-shlibdeps to indicate a package build + tree to scan first when trying to find a needed library. [ Guillem Jover ] * Move compression related variables to a new Dpkg::Compression module. diff --git a/man/dpkg-shlibdeps.1 b/man/dpkg-shlibdeps.1 index 21908968..0039e106 100644 --- a/man/dpkg-shlibdeps.1 +++ b/man/dpkg-shlibdeps.1 @@ -180,6 +180,13 @@ avoid self-dependencies for packages which provide ELF binaries package. This option can be used multiple times to exclude several packages. .TP +.BI \-S pkgbuilddir +Look into \fIpkgbuilddir\fP first when trying to find a library. This is +useful when the source package builds multiple flavors of the same library +and you want to ensure that you get the dependency from a given binary +package. You can use this option multiple times: directories will be +tried in the same order before directories of other binary packages. +.TP .BI \-\-ignore\-missing\-info Do not fail if dependency information can't be found for a shared library. Usage of this option is discouraged, all libraries should provide @@ -241,16 +248,17 @@ the RPATH of the binary, directories listed in /etc/ld.so.conf, directories listed in the LD_LIBRARY_PATH 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 -of the binary being analyzed, in other packages's build tree that contains +of the binary being analyzed, in the packages's build trees indicated with +the \-S command\-line option, in other packages's build trees that contains a DEBIAN/shlibs or DEBIAN/symbols file and finally in the root directory. 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 LD_LIBRARY_PATH. If it's in another -binary package being built, you want to make sure that the shlibs file of -this package is already created and that LD_LIBRARY_PATH contains the -appropriate directory if it also is in a private directory. +binary package being built, you want to make sure that the shlibs/symbols +file of this package is already created and that LD_LIBRARY_PATH +contains the appropriate directory if it also is in a private directory. .TP .BI "no dependency information found for " library\-file " (used by " binary ")." The library needed by \fIbinary\fR has been found by diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 4bf8948b..e62f515e 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -38,6 +38,7 @@ my $varnameprefix = 'shlibs'; my $ignore_missing_info = 0; my $debug = 0; my @exclude = (); +my @pkg_dir_to_search = (); my $host_arch = get_host_arch(); my (@pkg_shlibs, @pkg_symbols, @pkg_root_dirs); @@ -56,6 +57,8 @@ foreach (@ARGV) { $varnameprefix = $1; } elsif (m/^-L(.*)$/) { $shlibslocal = $1; + } elsif (m/^-S(.*)$/) { + push @pkg_dir_to_search, $1; } elsif (m/^-O$/) { $stdout = 1; } elsif (m/^-(h|-help)$/) { @@ -389,6 +392,8 @@ Options: -T update variables here, not debian/substvars. -t set package type (default is deb). -x exclude package from the generated dependencies. + -S search needed libraries in the given + package build directory first. --admindir= change the administrative directory. -h, --help show this help message. --version show the version. @@ -591,17 +596,23 @@ sub my_find_library { push @RPATH, $path; } - # Look into the packages we're currently building (but only those - # that provides shlibs/symbols file and the one that contains the - # binary being analyzed...) - # TODO: we should probably replace that by a cleaner way to look into - # the various temporary build directories... - my @copy = (@pkg_root_dirs); + # Look into the packages we're currently building in the following + # order: + # - package build tree of the binary which is analyzed + # - package build tree given on the command line (option -S) + # - other package build trees that contain either a shlibs or a + # symbols file + my @builddirs; my $pkg_root = guess_pkg_root_dir($execfile); - unshift @copy, $pkg_root if defined $pkg_root; - foreach my $builddir (@copy) { + push @builddirs, $pkg_root if defined $pkg_root; + push @builddirs, @pkg_dir_to_search; + push @builddirs, @pkg_root_dirs; + my %dir_checked; + foreach my $builddir (@builddirs) { + next if defined($dir_checked{$builddir}); $file = find_library($lib, \@RPATH, $format, $builddir); return $file if defined($file); + $dir_checked{$builddir} = 1; } # Fallback in the root directory if we have not found what we were -- 2.39.5