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

[SCM] Debian package checker branch, master, updated. 2.3.4-33-g4d7501e



The following commit has been merged in the master branch:
commit 28b7fd7a2fb8b9712ac05834e675f0b12618d829
Author: Adam D. Barratt <adam@adam-barratt.org.uk>
Date:   Wed Jan 6 16:20:01 2010 +0000

    Add new changes-file check script
    
    All the tags implemented by this check script have been moved from the
    special-case lintian.desc, which now only contains override-related
    tags.

diff --git a/checks/changes-file b/checks/changes-file
new file mode 100755
index 0000000..67c5e68
--- /dev/null
+++ b/checks/changes-file
@@ -0,0 +1,153 @@
+# changes-file -- lintian check script -*- perl -*-
+
+# Copyright (C) 1998 Christian Schwarz and Richard Braakman
+#
+# This program is free software.  It is distributed 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::changes_file;
+use strict;
+use Util;
+
+use Lintian::Tags qw(tag);
+use Lintian::Check qw(check_maintainer);
+
+my $check_checksums = $main::check_checksums;
+
+sub run {
+
+my $pkg = shift;
+my $type = shift;
+my $info = shift;
+
+# If we don't have a Format key, something went seriously wrong.
+# Tag the file and skip remaining processing.
+if (!$info->field('format')) {
+    tag('malformed-changes-file');
+    return 0;
+}
+
+# Description is mandated by dak, but only makes sense if binary
+# packages are included.  Don't tag pure source uploads.
+if (!$info->field('description') && $info->field('architecture') ne 'source') {
+    tag("no-description-in-changes-file");
+}
+
+# check distribution field
+if (defined $info->field('distribution')) {
+    my $ubuntu_dists = Lintian::Data->new ('changelog-file/ubuntu-dists');
+    my $ubuntu_regex = join('|', $ubuntu_dists->all);
+    my @distributions = split /\s+/o, $info->field('distribution');
+    for my $distribution (@distributions) {
+	if ($distribution eq 'UNRELEASED') {
+	    # ignore
+	} elsif ($info->field('version') =~ /ubuntu|$ubuntu_regex/
+	    or $distribution =~ /$ubuntu_regex/) {
+		if ($distribution !~ /^($ubuntu_regex)(-(proposed|updates|backports|security))?$/ ) {
+		    tag("bad-ubuntu-distribution-in-changes-file",
+			$distribution);
+		}
+	} elsif (! (($distribution eq 'oldstable')
+		     or ($distribution eq 'stable')
+		     or ($distribution eq 'testing')
+		     or ($distribution eq 'unstable')
+		     or ($distribution eq 'experimental')
+		     or ($distribution =~ /^\w+-backports$/)
+		     or ($distribution =~ /^\w+-proposed-updates$/)
+		     or ($distribution =~ /^\w+-security$/))
+		) {
+	    # bad distribution entry
+	    tag("bad-distribution-in-changes-file", $distribution);
+	}
+    }
+
+    if ($#distributions > 0) {
+	tag("multiple-distributions-in-changes-file",
+	    $info->field('distribution'));
+	}
+    }
+
+    # Urgency is only recommended by Policy.
+    if (!$info->field('urgency')) {
+	tag("no-urgency-in-changes-file");
+    } else {
+	my $urgency = lc $info->field('urgency');
+	$urgency =~ s/ .*//;
+	unless ($urgency =~ /^(low|medium|high|critical|emergency)$/i) {
+	    tag("bad-urgency-in-changes-file", $info->field('urgency'));
+	}
+    }
+
+    # Changed-By is optional in Policy, but if set, must be
+    # syntactically correct.  It's also used by dak.
+    if ($info->field('changed-by')) {
+	check_maintainer($info->field('changed-by'), 'changed-by');
+    }
+
+    my $files = $info->files;
+    foreach my $file (keys %$files) {
+        my $file_info = $files->{$file};
+
+	# check section
+	if (($file_info->{section} eq 'non-free') or
+	    ($file_info->{section} eq 'contrib')) {
+	    tag("bad-section-in-changes-file", $file, $file_info->{section});
+	}
+
+	foreach my $alg (qw(sha1 sha256)) {
+	    my $checksum_info = $file_info->{checksums}{$alg};
+	    if (defined $checksum_info) {
+		if ($file_info->{size} != $checksum_info->{filesize}) {
+		    tag( "file-size-mismatch-in-changes-file", $file,
+			$file_info->{size} . ' != ' .
+			$checksum_info->{filesize} );
+		}
+	    }
+	}
+
+	# check size
+	my $path = readlink('changes');
+	$path =~ s#/[^/]+$##;
+	my $filename = "$path/$file";
+	my $size = -s $filename;
+
+	if ($size ne $file_info->{size}) {
+	    tag( "file-size-mismatch-in-changes-file", $file,
+		 $file_info->{size} . " != $size");
+	}
+
+	# check checksums
+	if ($check_checksums or $file =~ /\.dsc$/) {
+	    foreach my $alg (qw(md5 sha1 sha256)) {
+		next unless exists $file_info->{checksums}{$alg};
+
+		my $real_checksum = get_file_checksum($alg, $filename);
+
+		if ($real_checksum ne $file_info->{checksums}{$alg}{sum}) {
+		    tag( "checksum-mismatch-in-changes-file", $alg, $file );
+		}
+	    }
+	}
+    }
+}
+
+1;
+
+# Local Variables:
+# indent-tabs-mode: t
+# cperl-indent-level: 4
+# End:
+# vim: sw=4 ts=8 noet fdm=marker
diff --git a/checks/lintian.desc b/checks/changes-file.desc
similarity index 81%
copy from checks/lintian.desc
copy to checks/changes-file.desc
index 8314b86..1c9364b 100644
--- a/checks/lintian.desc
+++ b/checks/changes-file.desc
@@ -1,6 +1,7 @@
-Check-Script: lintian
-Info: This description file is a special case.  It contains the tag info
- for the tags produced by the lintian frontend itself.
+Check-Script: changes-file
+Abbrev: chng
+Type: changes
+Info: This script checks for various problems with .changes files
 
 Tag: malformed-changes-file
 Severity: serious
@@ -10,8 +11,8 @@ Info: There is no "Format" field in your .changes file.  This probably
  a changes file, or it's not in the proper format, or it's PGP-signed
  twice.
  .
- Since Lintian was unable to parse this .changes file, it and any files
- that it would have referenced were skipped.
+ Since Lintian was unable to parse this .changes file, any further checks
+ on it were skipped.
 Ref: policy 5.5
 
 Tag: no-description-in-changes-file
@@ -127,22 +128,3 @@ Certainty: certain
 Info: The Changed-By address includes localhost(.localdomain), which is
  an invalid e-mail address.
 Ref: policy 5.6.2
-
-Tag: unused-override
-Severity: wishlist
-Certainty: certain
-Info: Lintian discovered an unused override entry in its database.
- Please remove it from the overrides file if it is not needed anymore.
-
-Tag: malformed-override
-Severity: important
-Certainty: certain
-Info: Lintian discovered an override entry with an invalid format.  An
- override entry should have the format:
- .
-   &lt;package&gt;[ &lt;type&gt;]: &lt;tag&gt;[ &lt;extra&gt; ...]
- .
- where &lt;package&gt; is the package name, the optional &lt;type&gt;
- parameter specifies the package type (binary is the default), &lt;tag&gt;
- is the tag to suppress, and &lt;extra&gt; is any specific information for
- the particular tag to suppress.
diff --git a/checks/lintian.desc b/checks/lintian.desc
index 8314b86..08f7f01 100644
--- a/checks/lintian.desc
+++ b/checks/lintian.desc
@@ -2,132 +2,6 @@ Check-Script: lintian
 Info: This description file is a special case.  It contains the tag info
  for the tags produced by the lintian frontend itself.
 
-Tag: malformed-changes-file
-Severity: serious
-Certainty: certain
-Info: There is no "Format" field in your .changes file.  This probably
- indicates some serious problem with the file.  Perhaps it's not actually
- a changes file, or it's not in the proper format, or it's PGP-signed
- twice.
- .
- Since Lintian was unable to parse this .changes file, it and any files
- that it would have referenced were skipped.
-Ref: policy 5.5
-
-Tag: no-description-in-changes-file
-Severity: serious
-Certainty: certain
-Info: There is no "Description" field in your .changes file.  A
- description is mandatory and is usually constructed from the descriptions
- in the control file of the package by the package build tools.
-Ref: policy 5.5
-
-Tag: bad-distribution-in-changes-file
-Severity: important
-Certainty: certain
-Info: You've specified an unknown target distribution for your upload in
- the <tt>debian/changelog</tt> file.
- .
- Note that the distributions <tt>non-free</tt> and <tt>contrib</tt> are no
- longer valid. You'll have to use distribution <tt>unstable</tt> and
- <tt>Section: non-free/xxx</tt> or <tt>Section: contrib/xxx</tt> instead.
-Ref: policy 5.6.14
-
-Tag: bad-ubuntu-distribution-in-changes-file
-Severity: important
-Certainty: certain
-Info: You've specified an unknown target distribution for your upload in
- the <tt>debian/changelog</tt> file.
- .
- Your version string suggests this package is for Ubuntu, so your
- distribution should be one of lucid, karmic, jaunty, intrepid, hardy or
- dapper.
-
-Tag: multiple-distributions-in-changes-file
-Severity: important
-Certainty: possible
-Info: You've specified more than one target distribution for your upload
- in the <tt>*.changes</tt> file, probably via the most recent entry in the
- <tt>debian/changelog</tt> file.
- .
- Although this syntax is valid, it is not accepted by the Debian archive
- management software.  This may not be a problem if this upload is
- targeted at an archive other than Debian's.
-Ref: policy 5.6.14
-
-Tag: no-urgency-in-changes-file
-Severity: normal
-Certainty: certain
-Info: There is no "Urgency" field in the .changes file.  This field is
- recommended by policy and is usually derived from the first line of the
- most recent changelog entry by the package build tools.
-Ref: policy 5.5
-
-Tag: bad-urgency-in-changes-file
-Severity: important
-Certainty: certain
-Info: The keyword value of the "Urgency" field in the .changes file is not
- one of the allowed values of low, medium, high, critical, and emergency
- (case-insensitive).  This value normally taken from the first line of the
- most recent entry in <tt>debian/changelog</tt>, which is probably where
- the error is.
-Ref: policy 5.6.17
-
-Tag: file-size-mismatch-in-changes-file
-Severity: serious
-Certainty: certain
-Info: The actual file size does not match what's listed in the
- <tt>.changes</tt> file.
-
-Tag: checksum-mismatch-in-changes-file
-Severity: serious
-Certainty: certain
-Info: The actual checksum does not match what's listed in the
- <tt>.changes</tt> file.
-
-Tag: bad-section-in-changes-file
-Severity: important
-Certainty: certain
-Info: The sections <tt>non-free</tt> and <tt>contrib</tt> are no longer
- valid. Please use section <tt>non-free/xxx</tt> or
- <tt>contrib/xxx</tt> instead.
-Ref: policy 2.4
-
-Tag: changed-by-name-missing
-Severity: serious
-Certainty: certain
-Info: The Changed-By field seems to contain just an email address. It must
- contain the package maintainer's name and email address.
-Ref: policy 5.6.4
-
-Tag: changed-by-address-missing
-Severity: serious
-Certainty: certain
-Info: The Changed-By field should contain the package builder's name and
- email address, with the name followed by the address inside angle
- brackets (&lt; and &gt;).  The address seems to be missing.
-Ref: policy 5.6.4
-
-Tag: changed-by-address-malformed
-Severity: important
-Certainty: certain
-Info: The Changed-By field could not be parsed according to the rules in
- the Policy Manual.
-Ref: policy 5.6.4
-
-Tag: changed-by-address-looks-weird
-Severity: normal
-Certainty: possible
-Info: The Changed-By field does not have whitespace between the name
- and the email address.
-
-Tag: changed-by-address-is-on-localhost
-Severity: important
-Certainty: certain
-Info: The Changed-By address includes localhost(.localdomain), which is
- an invalid e-mail address.
-Ref: policy 5.6.2
-
 Tag: unused-override
 Severity: wishlist
 Certainty: certain

-- 
Debian package checker


Reply to: