1 # version-substvars -- lintian check script -*- perl -*-
3 # Copyright (C) 2006 Adeodato Simó
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, you can find it on the World Wide
17 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
18 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
27 # (b1) any -> any (= ${source:Version}) -> use b:V
28 # (b2) any -> all (= ${Source-Version}) [or b:V] -> use s:V
29 # (b3) all -> any (= ${either-of-them}) -> use (>= ${s:V}),
30 # optionally (<< ${s:V}.1~)
32 # Always warn on ${Source-Version} even if it doesn't break since the substvar
33 # is now considered deprecated.
35 package Maemian::version_substvars;
47 my $binpkgs = $info->binaries;
49 my @dep_fields = qw(depends pre-depends recommends suggests conflicts replaces);
51 foreach (keys %$binpkgs) {
52 my ($pkg1, $pkg1_is_any, $pkg2, $pkg2_is_any, $substvar_strips_binNMU);
55 $pkg1_is_any = ($info->binary_field($pkg1, 'architecture') ne 'all');
57 foreach my $field (@dep_fields) {
58 next unless $info->binary_field($pkg1, $field);
59 if ($info->binary_field($pkg1, $field) =~ m/\${Source-Version}/) {
60 tag "substvar-source-version-is-deprecated", $pkg1;
64 foreach (split(m/,/, $info->binary_field($pkg1, 'pre-depends').", ".
65 $info->binary_field($pkg1, 'depends'))) {
66 next unless m/(\S+)\s*\(\s*=\s*\${((?:Source-|source:|binary:)Version)}/x;
69 $substvar_strips_binNMU = ($2 eq 'source:Version');
71 # We can't test dependencies on packages whose names are
72 # formed via substvars expanded during the build. Assume
73 # those maintainers know what they're doing.
74 if (not $info->binary_field($pkg2, 'architecture')) {
75 tag "version-substvar-for-external-package", "$pkg1 -> $pkg2"
76 unless ($pkg2 =~ /\$\{\S+\}/);
79 $pkg2_is_any = ($info->binary_field($pkg2, 'architecture') !~ m/^all$/);
82 if ($pkg2_is_any and $substvar_strips_binNMU) {
83 # (b1) any -> any (= ${source:Version})
84 tag "not-binnmuable-any-depends-any", "$pkg1 -> $pkg2";
85 } elsif (not $pkg2_is_any and not $substvar_strips_binNMU) {
86 # (b2) any -> all (= ${Source-Version}) [or b:V]
87 tag "not-binnmuable-any-depends-all", "$pkg1 -> $pkg2";
89 } elsif ($pkg2_is_any) {
90 # (b3) all -> any (= ${either-of-them})
91 tag "not-binnmuable-all-depends-any", "$pkg1 -> $pkg2";
101 # indent-tabs-mode: t
102 # cperl-indent-level: 8
104 # vim: syntax=perl sw=4 ts=4 noet shiftround