[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#377141: lintian: please check for substvar usage that causes un-binNMUability



Package: lintian
Version: 1.23.22
Severity: wishlist
Tags: patch

Hello!

The attached new version-substvars check checks the usage of the
${Source-Version}, ${source:Version}, and ${binary:Version} substvars in
the Depends field, and warns when it causes un-binNMUability of the
package.

Note that one of the tags is marked as error instead of warning. This is
because the maintainer has introduced a regression while moving from
${Source-Version} to the new vars, using source:Version instead of
binary:Version (for example, xulrunner_1.8.0.4-1).

Thanks.

lintian (1.23.23) unstable; urgency=low

  * checks/version-substvars: new check to warn about usage of the
    ${Source-Version}, ${source:Version} and ${binary:Version} substvars
    that results in the package not being safely binNMUable.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
                            Listening to: Maximilian Hecker - My Friends
# version-substvars -- lintian check script
#
# Copyright (C) 2006 Adeodato Simó
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.

# SUMMARY
# =======
#
# What breaks
# -----------
# 
# (b1) any -> any (= ${source:Version})          -> use b:V
# (b2) any -> all (= ${Source-Version}) [or b:V] -> use s:V
# (b3) all -> any (= ${either-of-them})          -> use (>= ${s:V}), optionally (<< ${s:V}.1~)


package Lintian::version_substvars;
use strict;

use Util;
use Tags;

sub run {

my $pkg = shift;
my $type = shift;

my @control_data = read_dpkg_control("debfiles/control");

shift @control_data; # skip source info entry

foreach (@control_data) {
	my ($pkg1, $pkg1_is_any, $pkg2, $pkg2_is_any, $substvar_strips_binNMU);

    $pkg1 = $_->{'package'};
	$pkg1_is_any = ($_->{'architecture'} ne 'all');

	foreach (split /,/, ($_->{'depends'} || "")) {
		next unless m/(\S+)\s*\(\s*=\s*\${((?:Source-|source:|binary:)Version)}/x;

		$pkg2 = $1;
		$substvar_strips_binNMU = ($2 eq 'source:Version');
		$pkg2_is_any = (slurp_entire_file("control/$pkg2/architecture") !~ m/^all$/);

		if ($pkg1_is_any) {
			if ($pkg2_is_any and $substvar_strips_binNMU) {
				# (b1) any -> any (= ${source:Version})
				tag "not-binnmuable-any-depends-any", "$pkg1 -> $pkg2";
			} elsif (not $pkg2_is_any and not $substvar_strips_binNMU) {
				# (b2) any -> all (= ${Source-Version}) [or b:V]
				tag "not-binnmuable-any-depends-all", "$pkg1 -> $pkg2";
			}
		} elsif ($pkg2_is_any) {
			# (b3) all -> any (= ${either-of-them})
			tag "not-binnmuable-all-depends-any", "$pkg1 -> $pkg2";
		}

		# TODO (post-Etch?): warn/error about ${Source-Version} being deprecated
	}
}

}

1;

# vim: syntax=perl sw=4 ts=4 noet shiftround
Check-Script: version-substvars
Author: Adeodato Simó <dato@net.com.org.es>
Abbrev: v-s
Standards-Version: 3.7.2
Type: source
Unpack-Level: 1
Needs-Info: debfiles, source-control-file
Info: This script checks for correct use of the various *Version
 substvars, e.g. deprecated substvars, or usage that can cause
 un-binNMUability

Tag: not-binnmuable-any-depends-any
Type: error
Info: The package is not safely binNMUable because an arch:any package
 depends on another arch:any package with a (= ${source:Version})
 relationship. Please use (= ${binary:Version}) instead.

Tag: not-binnmuable-any-depends-all
Type: warning
Info: The package is not safely binNMUable because an arch:any package
 depends on an arch:all package with a (= ${Source-Version}) or
 (= ${binary:Version}) relationship. Please use (= ${source:Version})
 instead.

Tag: not-binnmuable-all-depends-any
Type: warning
Info: The package is not safely binNMUable because an arch:all package
 depends on an arch:any package with a strict (= ${Source-Version}), or
 similar, relationship.
 .
 It is not possible for arch:all packages to depend so strictly on
 arch:any packages while having the package binNMUable, so please use
 one of these, whichever is more appropriate:
 .
   Depends: arch_any (>= ${source:Version})
   Depends: arch_any (>= ${source:Version}), arch_any (<< ${source:Version}.1~)

Reply to: