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 Lintian::version_substvars;
46 my @control_data = read_dpkg_control("debfiles/control");
47 my @dep_fields = qw(depends pre-depends recommends suggests conflicts replaces);
49 shift @control_data; # skip source info entry
51 foreach (@control_data) {
52 my ($pkg1, $pkg1_is_any, $pkg2, $pkg2_is_any, $substvar_strips_binNMU);
54 $pkg1 = $_->{'package'};
55 $pkg1_is_any = ($_->{'architecture'} ne 'all');
57 foreach my $field (@dep_fields) {
58 next unless $_->{$field};
59 if ($_->{$field} =~ m/\${Source-Version}/) {
60 tag "substvar-source-version-is-deprecated", $pkg1;
64 foreach (split(m/,/, ($_->{'pre-depends'} || "").", ".
65 ($_->{'depends'} || ""))) {
66 next unless m/(\S+)\s*\(\s*=\s*\${((?:Source-|source:|binary:)Version)}/x;
69 $substvar_strips_binNMU = ($2 eq 'source:Version');
71 if (not -f "control/$pkg2/architecture") {
72 tag "version-substvar-for-external-package", "$pkg1 -> $pkg2";
75 $pkg2_is_any = (slurp_entire_file("control/$pkg2/architecture") !~ m/^all$/);
78 if ($pkg2_is_any and $substvar_strips_binNMU) {
79 # (b1) any -> any (= ${source:Version})
80 tag "not-binnmuable-any-depends-any", "$pkg1 -> $pkg2";
81 } elsif (not $pkg2_is_any and not $substvar_strips_binNMU) {
82 # (b2) any -> all (= ${Source-Version}) [or b:V]
83 tag "not-binnmuable-any-depends-all", "$pkg1 -> $pkg2";
85 } elsif ($pkg2_is_any) {
86 # (b3) all -> any (= ${either-of-them})
87 tag "not-binnmuable-all-depends-any", "$pkg1 -> $pkg2";
96 # vim: syntax=perl sw=4 ts=4 noet shiftround