The branch, master has been updated
via 15b03b6fc3271dcdb3108c8c9ef0bfd4f350106d (commit)
via 72524e4f013dd006cefd4b9d9daa766d228788ee (commit)
from 9da6daf8e79850c56505a39bd1473989dacc900c (commit)
- Shortlog ------------------------------------------------------------
15b03b6 dpkg-shlibdeps: use the Build-Depends-Package information from symbols
files
72524e4 Dpkg::Shlibs::SymbolFile supports meta-information fields
Summary of changes:
ChangeLog | 13 ++++
debian/changelog | 4 +
man/ChangeLog | 7 ++
man/deb-symbols.5 | 13 ++++
man/dpkg-shlibdeps.1 | 7 ++
scripts/Dpkg/Shlibs/SymbolFile.pm | 31 ++++++++--
scripts/dpkg-shlibdeps.pl | 91 ++++++++++++++++++++++++------
scripts/t/200_Dpkg_Shlibs.t | 16 +++++-
scripts/t/200_Dpkg_Shlibs/symbols.fake-2 | 1 +
9 files changed, 159 insertions(+), 24 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit 15b03b6fc3271dcdb3108c8c9ef0bfd4f350106d
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date: Sun Dec 9 15:42:40 2007 +0100
dpkg-shlibdeps: use the Build-Depends-Package information from symbols files
Use this new field to identify the version requirement possibly encoded in
the Build-Depends field and make sure that the generated dependency is at
least as strict as this one. Updated dpkg-shlibdeps's manual page.
diff --git a/ChangeLog b/ChangeLog
index 1dc85f1..e8ea1bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -44,11 +44,13 @@
* scripts/Dpkg/Shlibs/SymbolFile.pm: Parse and dump properly
new meta-information fields (on lines starting with an asterisk).
Bugfix with alternate dependency handling that were not properly
- dumped.
+ dumped. New functions get_dependencies() and get_field().
* scripts/t/200_Dpkg_Shlibs.t,
scripts/t/200_Dpkg_Shlibs/symbols.fake-2: Add a test case to
verify that meta-information fields and alternate dependencies are
properly parsed and dumped.
+ * scripts/dpkg-shlibdeps.pl: Take into account the new
+ Build-Depends-Package field in symbols files.
2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
diff --git a/debian/changelog b/debian/changelog
index c8c9dfc..e3be2ad 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,10 @@ dpkg (1.14.13) UNRELEASED; urgency=low
* Tweak the sort algorithm between dependencies so that intervals
are displayed as "a (>= 1), a (<< 2)" instead of the opposite.
Closes: #455520
+ * Extend format of symbols files to support arbitrary fields of
+ meta-information. First field is Build-Depends-Package used to extract the
+ version requirement possibly encoded in the Build-Depends field and make
+ sure that the generated dependency is at least as strict as this one.
[ Updated man pages translations ]
* Swedish (Peter Karlsson)
diff --git a/man/ChangeLog b/man/ChangeLog
index 177d027..214d101 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -6,6 +6,8 @@
* deb-symbols.5: Describe syntax of meta-information
fields and document the Build-Depends-Package field.
+ * dpkg-shlibdeps.1: Describe how the Build-Depends-Package field
+ of symbols file is used.
2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
diff --git a/man/dpkg-shlibdeps.1 b/man/dpkg-shlibdeps.1
index f02d203..d7ea373 100644
--- a/man/dpkg-shlibdeps.1
+++ b/man/dpkg-shlibdeps.1
@@ -68,6 +68,13 @@ remembers the (biggest) minimal version needed for each
library. At the end
of the process, it is able to write out the minimal dependency for every
library used (provided that the information of the \fIsymbols\fR files are
accurate).
+.P
+As a safe-guard measure, a symbols file can provide a
+\fIBuild-Depends-Package\fR meta-information field and
+.B dpkg-shlibdeps
+will extract the minimal version required by the corresponding package in
+the Build-Depends field and use this version if it's higher than the
+minimal version computed by scanning symbols.
.SS Shlibs files
Shlibs files associate directly a library to a dependency (without looking
at the symbols). It's thus often stronger than really needed but very safe
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm
b/scripts/Dpkg/Shlibs/SymbolFile.pm
index 8f3dfe5..e3eb483 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -273,6 +273,19 @@ sub get_dependency {
return $self->{objects}{$soname}{deps}[$dep_id];
}
+sub get_dependencies {
+ my ($self, $soname) = @_;
+ return @{$self->{objects}{$soname}{deps}};
+}
+
+sub get_field {
+ my ($self, $soname, $name) = @_;
+ if (exists $self->{objects}{$soname}{fields}{$name}) {
+ return $self->{objects}{$soname}{fields}{$name};
+ }
+ return undef;
+}
+
sub lookup_symbol {
my ($self, $name, $sonames, $inc_deprecated) = @_;
$inc_deprecated = 0 unless defined($inc_deprecated);
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
index c26b7a3..72b34ae 100755
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@ -11,12 +11,16 @@ use Dpkg::Gettext;
use Dpkg::ErrorHandling qw(warning error failure syserr usageerr);
use Dpkg::Path qw(relative_to_pkg_root guess_pkg_root_dir
check_files_are_the_same);
-use Dpkg::Version qw(vercmp);
+use Dpkg::Version qw(compare_versions);
use Dpkg::Shlibs qw(find_library);
use Dpkg::Shlibs::Objdump;
use Dpkg::Shlibs::SymbolFile;
use Dpkg::Arch qw(get_host_arch);
use Dpkg::Fields qw(capit);
+use Dpkg::Deps;
+
+push(@INC,$dpkglibdir);
+require 'controllib.pl';
# By increasing importance
my @depfields = qw(Suggests Recommends Depends Pre-Depends);
@@ -83,6 +87,12 @@ foreach (@ARGV) {
scalar keys %exec || usageerr(_g("need at least one executable"));
+our %fi;
+parsecontrolfile("debian/control");
+my $build_depends = defined($fi{"C Build-Depends"}) ?
+ $fi{"C Build-Depends"} : "";
+my $build_deps = Dpkg::Deps::parse($build_depends, reduce_arch => 1);
+
my %dependencies;
my %shlibs;
@@ -210,21 +220,9 @@ foreach my $file (keys %exec) {
}
my $symdep = $symfile->lookup_symbol($name, [EMAIL PROTECTED]);
if (defined($symdep)) {
- my ($d, $m) = ($symdep->{depends}, $symdep->{minver});
$used_sonames{$symdep->{soname}}++;
- foreach my $subdep (split /\s*,\s*/, $d) {
- if (exists $dependencies{$cur_field}{$subdep} and
- defined($dependencies{$cur_field}{$subdep}))
- {
- if ($dependencies{$cur_field}{$subdep} eq '' or
- vercmp($m, $dependencies{$cur_field}{$subdep}) > 0)
- {
- $dependencies{$cur_field}{$subdep} = $m;
- }
- } else {
- $dependencies{$cur_field}{$subdep} = $m;
- }
- }
+ update_dependency_version($symdep->{depends},
+ $symdep->{minver});
} else {
my $syminfo = $dumplibs_wo_symfile->locate_symbol($name);
if (not defined($syminfo)) {
@@ -252,8 +250,20 @@ foreach my $file (keys %exec) {
}
warning(_g("%d other similar warnings have been skipped (use -v to see " .
"them all)."), $nb_skipped_warnings) if $nb_skipped_warnings;
- # Warn about un-NEEDED libraries
foreach my $soname (@sonames) {
+ # Adjust minimal version of dependencies with information
+ # extracted from build-dependencies
+ my $dev_pkg = $symfile->get_field($soname, 'Build-Depends-Package');
+ if (defined $dev_pkg) {
+ my $minver = get_min_version_from_deps($build_deps, $dev_pkg);
+ if (defined $minver) {
+ foreach my $dep ($symfile->get_dependencies($soname)) {
+ update_dependency_version($dep, $minver);
+ }
+ }
+ }
+
+ # Warn about un-NEEDED libraries
unless ($soname_notfound{$soname} or $used_sonames{$soname}) {
# Ignore warning for libm.so.6 if also linked against libstdc++
next if ($soname =~ /^libm\.so\.\d+$/ and
@@ -302,7 +312,7 @@ sub filter_deps {
# Since dependencies can be versionned, we have to
# verify if the dependency is stronger than the
# previously seen one
- if (vercmp($depseen{$dep}, $dependencies{$field}{$dep}) > 0) {
+ if (compare_versions($depseen{$dep}, '>>',
$dependencies{$field}{$dep})) {
return 0;
} else {
$depseen{$dep} = $dependencies{$field}{$dep};
@@ -384,6 +394,53 @@ Dependency fields recognised are:
"), $progname, join("/",@depfields);
}
+sub get_min_version_from_deps {
+ my ($dep, $pkg) = @_;
+ if ($dep->isa('Dpkg::Deps::Simple')) {
+ if (($dep->{package} eq $pkg) &&
+ defined($dep->{relation}) &&
+ (($dep->{relation} eq ">=") ||
+ ($dep->{relation} eq ">>")))
+ {
+ return $dep->{version};
+ }
+ return undef;
+ } else {
+ my $res;
+ foreach my $subdep ($dep->get_deps()) {
+ my $minver = get_min_version_from_deps($subdep, $pkg);
+ next if not defined $minver;
+ if (defined $res) {
+ if (compare_versions($minver, '>>', $res)) {
+ $res = $minver;
+ }
+ } else {
+ $res = $minver;
+ }
+ }
+ return $res;
+ }
+}
+
+sub update_dependency_version {
+ my ($dep, $minver) = @_;
+ return if not defined($minver);
+ foreach my $subdep (split /\s*,\s*/, $dep) {
+ if (exists $dependencies{$cur_field}{$subdep} and
+ defined($dependencies{$cur_field}{$subdep}))
+ {
+ if ($dependencies{$cur_field}{$subdep} eq '' or
+ compare_versions($minver, '>>',
+ $dependencies{$cur_field}{$subdep}))
+ {
+ $dependencies{$cur_field}{$subdep} = $minver;
+ }
+ } else {
+ $dependencies{$cur_field}{$subdep} = $minver;
+ }
+ }
+}
+
sub add_shlibs_dep {
my ($soname, $pkg) = @_;
print "Looking up shlibs dependency of $soname provided by '$pkg'\n" if
$debug;
commit 72524e4f013dd006cefd4b9d9daa766d228788ee
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date: Sun Dec 9 11:14:47 2007 +0100
Dpkg::Shlibs::SymbolFile supports meta-information fields
Meta-information fields are stored in symbols files on lines
starting with an asterisk. Added a corresponding non-regression
test. Updated deb-symbols(5) accordingly.
diff --git a/ChangeLog b/ChangeLog
index e37452a..1dc85f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,17 @@
2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
+ * scripts/Dpkg/Shlibs/SymbolFile.pm: Parse and dump properly
+ new meta-information fields (on lines starting with an asterisk).
+ Bugfix with alternate dependency handling that were not properly
+ dumped.
+ * scripts/t/200_Dpkg_Shlibs.t,
+ scripts/t/200_Dpkg_Shlibs/symbols.fake-2: Add a test case to
+ verify that meta-information fields and alternate dependencies are
+ properly parsed and dumped.
+
+2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
+
* scripts/Dpkg/Shlibs/SymbolFile.pm (load): Pass the current
object as last parameter so that included files do not need to
repeat the header line.
diff --git a/man/ChangeLog b/man/ChangeLog
index 608d771..177d027 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -4,6 +4,11 @@
2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
+ * deb-symbols.5: Describe syntax of meta-information
+ fields and document the Build-Depends-Package field.
+
+2007-12-09 Raphael Hertzog <[EMAIL PROTECTED]>
+
* dpkg-gensymbols.1: Remove the restriction that included files
must be valid symbol files on their own.
diff --git a/man/deb-symbols.5 b/man/deb-symbols.5
index 94c1bd5..98a3c55 100644
--- a/man/deb-symbols.5
+++ b/man/deb-symbols.5
@@ -15,6 +15,10 @@ in these files is:
[ | <alternative dependency template> ]
.br
[ ... ]
+.br
+[ * <field-name>: <field value> ]
+.br
+[ ... ]
<symbol> <mininal version>[ <id of dependency template> ]
.P
The \fIlibrary soname\fR is exactly the value of the SONAME field
@@ -29,6 +33,13 @@ to a \fIminimal version\fR of its dependency template (the
main dependency
template is used if \fIid of dependency template\fR is not present). The
first alternative dependency template is numbered 1, the second one 2,
etc.
+.P
+Each entry for a library can also have some fields of meta-information.
+Those fields are stored on lines starting with an asterisk. Currently,
+the only valid field is \fIBuild-Depends-Package\fR, it indicates the name
+of the "-dev" package associated to the library and is used by
+dpkg-shlibdeps to make sure that the dependency generated is at least as
+strict as the corresponding build dependency.
.SH EXAMPLES
.SS Simple symbols file
.PP
@@ -41,6 +52,8 @@ libftp.so.3 libftp3 #MINVER#
libGL.so.1 libgl1
.br
| libgl1-mesa-glx #MINVER#
+.br
+* Build-Depends-Package: libgl1-mesa-dev
[EMAIL PROTECTED] 6.3-1
[...]
[EMAIL PROTECTED] 6.5.2-7 1
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm
b/scripts/Dpkg/Shlibs/SymbolFile.pm
index a2cf9f2..8f3dfe5 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -19,6 +19,7 @@ package Dpkg::Shlibs::SymbolFile;
use Dpkg::Gettext;
use Dpkg::ErrorHandling qw(syserr warning error);
use Dpkg::Version qw(vercmp);
+use Dpkg::Fields qw(capit);
my %blacklist = (
'__bss_end__' => 1, # arm
@@ -129,6 +130,9 @@ sub load {
} elsif (/^\|\s*(.*)$/) {
# Alternative dependency template
push @{$self->{objects}{$object}{deps}}, "$1";
+ } elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/) {
+ # Add meta-fields
+ $self->{objects}{$object}{fields}{capit($1)} = $2;
} elsif (/^(\S+)\s+(.*)$/) {
# New object and dependency template
$object = $1;
@@ -137,10 +141,7 @@ sub load {
$self->{objects}{$object}{deps} = [ "$2" ];
} else {
# Create a new object
- $self->{objects}{$object} = {
- syms => {},
- deps => [ "$2" ]
- };
+ $self->create_object($object, "$2");
}
} else {
warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_));
@@ -167,8 +168,12 @@ sub dump {
my ($self, $fh, $with_deprecated) = @_;
$with_deprecated = 1 unless defined($with_deprecated);
foreach my $soname (sort keys %{$self->{objects}}) {
- print $fh "$soname $self->{objects}{$soname}{deps}[0]\n";
- print $fh "| $_" foreach (@{$self->{objects}{$soname}{deps}}[ 1 .. -1
]);
+ my @deps = @{$self->{objects}{$soname}{deps}};
+ print $fh "$soname $deps[0]\n";
+ shift @deps;
+ print $fh "| $_\n" foreach (@deps);
+ my $f = $self->{objects}{$soname}{fields};
+ print $fh "* $_: $f->{$_}\n" foreach (sort keys %{$f});
foreach my $sym (sort keys %{$self->{objects}{$soname}{syms}}) {
my $info = $self->{objects}{$soname}{syms}{$sym};
next if $info->{deprecated} and not $with_deprecated;
@@ -257,6 +262,7 @@ sub create_object {
my ($self, $soname, @deps) = @_;
$self->{objects}{$soname} = {
syms => {},
+ fields => {},
deps => [ @deps ]
};
}
diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t
index bfc5da2..86bdeab 100644
--- a/scripts/t/200_Dpkg_Shlibs.t
+++ b/scripts/t/200_Dpkg_Shlibs.t
@@ -1,6 +1,7 @@
# -*- mode: cperl;-*-
-use Test::More tests => 33;
+use Test::More tests => 34;
+use IO::String;
use strict;
use warnings;
@@ -148,6 +149,19 @@ is_deeply($sym, { 'minver' => '1.0', 'dep_id' => 1,
'deprecated' => 0,
'depends' => 'libvirtualfake', 'soname' => 'libfake.so.1' },
'overrides order with circular #include');
+# Check dump output
+my $io = IO::String->new();
+$sym_file->dump($io);
+is(${$io->string_ref()},
+'libfake.so.1 libfake1 #MINVER#
+| libvirtualfake
+* Build-Depends-Package: libfake-dev
+ [EMAIL PROTECTED] 1.0 1
+ [EMAIL PROTECTED] 1.0
+ [EMAIL PROTECTED] 1.0
+', "Dump of $srcdir/symbols.include-2");
+
+
# Check parsing of objdump output on ia64 (local symbols
# without versions and with visibility attribute)
$obj = Dpkg::Shlibs::Objdump::Object->new;
diff --git a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
index 89586d1..e8593b4 100644
--- a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
+++ b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
@@ -1,6 +1,7 @@
#include "symbols.include-2"
# This is just a comment
libfake.so.1 libfake1 #MINVER#
+* Build-Depends-Package: libfake-dev
# The alternate dependency is below
| libvirtualfake
[EMAIL PROTECTED] 1.0 1
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]