From b776c00b2570b0083172ea8a91820c9b34752624 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Mon, 24 Sep 2007 11:19:25 +0200 Subject: [PATCH] Add "-x" option to dpkg-shlibdeps to exlude packages dpkg-shlibdeps now supports "-x" options that can be used to exclude packages from generated dependencies. This is particalularly useful to avoid self-dependencies when a package contains a binary and a library (without requiring an shlibs.local file to override the usual shlibs file). It might also be used to avoid other unwanted dependencies (use with care though). Closes: #41907, #109954 --- man/dpkg-shlibdeps.1 | 7 ++++++ scripts/dpkg-shlibdeps.pl | 49 +++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/man/dpkg-shlibdeps.1 b/man/dpkg-shlibdeps.1 index 488dc172..0f93495e 100644 --- a/man/dpkg-shlibdeps.1 +++ b/man/dpkg-shlibdeps.1 @@ -166,6 +166,13 @@ Enable verbose mode. Numerous messages are displayed to explain what .B dpkg\-shlibdeps does. .TP +.BI \-x package +Exclude the package from the generated dependencies. This is useful to +avoid self-dependencies for packages which provide ELF binaries +(executables or library plugins) using a library contained in the same +package. This option can be used multiple times to exclude several +packages. +.TP .BI \-\-admindir= dir Change the location of the \fBdpkg\fR database. The default location is \fI/var/lib/dpkg\fP. diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index c73d70af..9fa31e0d 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -31,6 +31,7 @@ my $dependencyfield= 'Depends'; my $varlistfile= 'debian/substvars'; my $varnameprefix= 'shlibs'; my $debug= 0; +my @exclude = (); my (@pkg_shlibs, @pkg_symbols); if (-d "debian") { @@ -67,6 +68,8 @@ foreach (@ARGV) { $packagetype = $1; } elsif (m/-v$/) { $debug = 1; + } elsif (m/-x(.*)$/) { + push @exclude, $1; } elsif (m/^-/) { usageerr(sprintf(_g("unknown option \`%s'"), $_)); } else { @@ -207,6 +210,31 @@ if ($stdout) { # Write out the shlibs substvars my %depseen; + +sub filter_deps { + my ($dep, $field) = @_; + # Skip dependencies on excluded packages + foreach my $exc (@exclude) { + return 0 if $dep =~ /^\s*\Q$exc\E\b/; + } + # Don't include dependencies if they are already + # mentionned in a higher priority field + if (not defined($depseen{$dep})) { + $depseen{$dep} = $dependencies{$field}{$dep}; + return 1; + } else { + # 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) { + return 0; + } else { + $depseen{$dep} = $dependencies{$field}{$dep}; + return 1; + } + } +} + foreach my $field (reverse @depfields) { my $dep = ""; if (exists $dependencies{$field} and scalar keys %{$dependencies{$field}}) { @@ -220,24 +248,8 @@ foreach my $field (reverse @depfields) { } s/\s+/ /g; $_; - } grep { - # Don't include dependencies if they are already - # mentionned in a higher priority field - if (not defined($depseen{$_})) { - $depseen{$_} = $dependencies{$field}{$_}; - 1; - } else { - # Since dependencies can be versionned, we have to - # verify if the dependency is stronger than the - # previously seen one - if (vercmp($depseen{$_}, $dependencies{$field}{$_}) > 0) { - 0; - } else { - $depseen{$_} = $dependencies{$field}{$_}; - 1; - } - } - } keys %{$dependencies{$field}}; + } grep { filter_deps($_, $field) } + keys %{$dependencies{$field}}; } if ($dep) { print $fh "$varnameprefix:$field=$dep\n"; @@ -286,6 +298,7 @@ Options: -L shlibs override file, not debian/shlibs.local. -T update variables here, not debian/substvars. -t set package type (default is deb). + -x exclude package from the generated dependencies. --admindir= change the administrative directory. -h, --help show this help message. --version show the version. -- 2.39.5