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

Bug#437959: lintian: [Feature request] dpatch check



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

As I have been told to always include a description in the patches, I
wondered why there wasn't a check for that in lintian.

So I have created a simple check for dpatch files. It could probably be
expanded to other types of patches, but I'm not used to the others.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-1-686 (SMP w/1 CPU core)
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages lintian depends on:
ii  binutils               2.17cvs20070804-1 The GNU assembler, linker and bina
ii  diffstat               1.43-2            produces graph of changes introduc
ii  dpkg-dev               1.14.5            package building tools for Debian
ii  file                   4.21-2            Determines file type using "magic"
ii  gettext                0.16.1-2          GNU Internationalization utilities
ii  intltool-debian        0.35.0+20060710.1 Help i18n of RFC822 compliant conf
ii  libparse-debianchangel 1.1-1             parse Debian changelogs and output
ii  man-db                 2.4.4-3           The on-line manual pager
ii  perl [libdigest-md5-pe 5.8.8-7           Larry Wall's Practical Extraction 

lintian recommends no packages.

-- no debconf information
# patch -- lintian check script -*- perl -*-
#
# Copyright © 2007 Carl Fürstenberg
#
# 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.

package Lintian::dpatch;
use strict;
use Util;
use Tags;

use Cwd;
use File::Find;
use File::Basename;

sub run {
	my $pkg = shift;
	my $type = shift;
	if( $type eq 'source' ) {
		my $cwd = cwd;
		my $dir = "$cwd/unpacked/debian/patches";

		if( -d $dir ) {
			find({ wanted => \&process_dpatch, follow => 1 }, $dir);
		}
	}
}

sub process_dpatch {
	if(/^.*\.dpatch\z/s) {
		my $file = $_;
		open FILE, '<', $File::Find::name or die "Couldn't open $File::Find::name\: $!";
		my $had_description = 0;
		while( <FILE> ) {
			last if $. > 50; #Usually on the fifth row, make it 50 for saftey
			if( /^#{2} DP\: No description./ ) {
				tag "dpatch-missing-description", $file;
			} elsif( /^#{2} DP\: \w+/ ) {
				$had_description = 1;
				last;
			}
		}
		close FILE;
		unless( $had_description ) {
			tag "dpatch-missing-description", $file;
		}
	}
}
1;
# vim: filetype=perl sw=4 ts=4 noet shiftround

Check-Script: dpatch
Author: Carl Fürstenberg <azatoth@gmail.com>
Abbrev: deb
Standards-Version: 3.6.1
Type: source
Unpack-Level: 1
Info: This script checks debian/patches/*.dpatch in the source package
Needs-Info: debfiles

Tag: dpatch-missing-description
Type: warning
Info: The dpatch file in question lacks a description.
 Each dpatch file should have a descrption describing the abstract of the patch.
 All description lines shall start with "##DP:".

Reply to: