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

[SCM] Debian package checker branch, master, updated. 2.1.6-12-gca85ece



The following commit has been merged in the master branch:
commit 8d85b7f6303d5ba7ef3ef7351fe75917b9e0f980
Author: Russ Allbery <rra@debian.org>
Date:   Sat Jan 24 01:03:47 2009 -0800

    Redo standards-version check to use Lintian::Data
    
    * checks/standards-version{,.desc}:
      + [RA] Use Lintian::Data to get the standards versions and release
        dates.  Dates are now in seconds since epoch, so remove the date
        conversion code.
    * data/standards-version/release-dates:
      + [RA] Known standards versions and their release dates in seconds
        since epoch, taken from checks/standards-version.

diff --git a/checks/standards-version b/checks/standards-version
index 014e6e2..fc8b782 100644
--- a/checks/standards-version
+++ b/checks/standards-version
@@ -1,6 +1,7 @@
 # standards-version -- lintian check script -*- perl -*-
 
 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
+# Copyright (C) 2008-2009 Russ Allbery
 #
 # 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
@@ -21,58 +22,24 @@
 package Lintian::standards_version;
 use strict;
 
-use Date::Parse qw(str2time);
 use POSIX qw(strftime);
 use Parse::DebianChangelog;
 
+use Lintian::Data;
 use Tags;
 use Util;
 
-# This is a list of all known standards versions, current and older, with
-# their dates of publication.
-my @standards =
-    ([ '3.8.0'  => '2008-06-04' ],
-     [ '3.7.3'  => '2007-12-03' ],
-     [ '3.7.2'  => '2006-05-03' ],
-     [ '3.7.1'  => '2006-05-03' ],
-     [ '3.7.0'  => '2006-04-26' ],
-     [ '3.6.2'  => '2005-06-17' ],
-     [ '3.6.1'  => '2003-08-19' ],
-     [ '3.6.0'  => '2003-07-09' ],
-     [ '3.5.10' => '2003-05-10' ],
-     [ '3.5.9'  => '2003-03-07' ],
-     [ '3.5.8'  => '2002-11-15' ],
-     [ '3.5.7'  => '2002-08-31' ],
-     [ '3.5.6'  => '2001-07-25' ],
-     [ '3.5.5'  => '2001-06-01' ],
-     [ '3.5.4'  => '2001-04-28' ],
-     [ '3.5.3'  => '2001-04-15' ],
-     [ '3.5.2'  => '2001-02-18' ],
-     [ '3.5.1'  => '2001-02-15' ],
-     [ '3.5.0'  => '2001-01-29' ],
-     [ '3.2.1'  => '2000-08-24' ],
-     [ '3.2.0'  => '2000-07-30' ],
-     [ '3.1.1'  => '1999-11-16' ],
-     [ '3.1.0'  => '1999-11-04' ],
-     [ '3.0.1'  => '1999-07-15' ],
-     [ '3.0.0'  => '1999-07-01' ],
-     [ '2.5.1'  => '1999-04-27' ],
-     [ '2.5.0'  => '1998-10-29' ],
-     [ '2.4.1'  => '1998-04-14' ],
-     [ '2.4.0'  => '1998-01-30' ],
-     [ '2.3.0'  => '1997-09-01' ],
-     [ '2.2.0'  => '1997-07-13' ],
-     [ '2.1.3'  => '1997-03-15' ],
-     [ '2.1.2'  => '1996-11-23' ],
-     [ '2.1.1'  => '1996-09-12' ],
-     [ '2.1.0'  => '1996-09-01' ],
-     [ '2.0.1'  => '1996-08-31' ],
-     [ '2.0.0'  => '1996-08-26' ],
-     [ '0.2.1'  => '1996-08-23' ],
-     [ '0.2.0'  => '1996-08-21' ]);
-my %standards = map { $$_[0] => $$_[1] } @standards;
-my $current = $standards[0][0];
-my @current = split (/\./, $current);
+our $STANDARDS = Lintian::Data->new('standards-version/release-dates', '\s+');
+
+# In addition to the normal Lintian::Data structure, we also want a list of
+# all standards and their release dates so that we can check things like the
+# release date of the standard released after the one a package declared.  Do
+# that by pulling all data out of the Lintian::Data structure and sorting it
+# by release date.  We can also use this to get the current standards version.
+our @STANDARDS = sort { $b->[1] <=> $a->[1] }
+    map { [ $_, $STANDARDS->value($_) ] } $STANDARDS->all;
+our $CURRENT   = $STANDARDS[0][0];
+our @CURRENT   = split(/\./, $CURRENT);
 
 sub run {
 
@@ -121,23 +88,24 @@ if (defined $changes) {
 
 # Check for packages dated prior to the date of release of the standards
 # version with which they claim to comply.
-if ($standards{$stdver} && str2time($standards{$stdver}, '+0000') > $pkgdate) {
-    my $pretty = strftime ('%Y-%m-%d', gmtime $pkgdate);
-    tag 'timewarp-standards-version', "($pretty < $standards{$stdver})";
+if ($STANDARDS->known($stdver) && $STANDARDS->value($stdver) > $pkgdate) {
+    my $package = strftime('%Y-%m-%d', gmtime $pkgdate);
+    my $release = strftime('%Y-%m-%d', gmtime $STANDARDS->value($stdver));
+    tag 'timewarp-standards-version', "($package < $release)";
 }
 
-my $tag = "$version (current is $current)";
-if (not exists $standards{$stdver}) {
+my $tag = "$version (current is $CURRENT)";
+if (not $STANDARDS->known($stdver)) {
     # Unknown standards version.  Perhaps newer?
-    if (   ($major > $current[0])
-        or ($major == $current[0] and $minor > $current[1])
-        or ($major == $current[0] and $minor == $current[1]
-            and $patch > $current[2])) {
+    if (   ($major > $CURRENT[0])
+        or ($major == $CURRENT[0] and $minor > $CURRENT[1])
+        or ($major == $CURRENT[0] and $minor == $CURRENT[1]
+            and $patch > $CURRENT[2])) {
         tag 'newer-standards-version', $tag;
     } else {
         tag 'invalid-standards-version', $version;
     }
-} elsif ($stdver eq $current) {
+} elsif ($stdver eq $CURRENT) {
     # Current standard.  Nothing more to check.
     return 0;
 } else {
@@ -149,13 +117,13 @@ if (not exists $standards{$stdver}) {
     # following it has been out for at least two years (so the current version
     # is never obsolete).
     my $obsdate = time;
-    for my $index (0 .. $#standards) {
-        if ($standards[$index][0] eq $stdver) {
-            $obsdate = $standards[$index - 1][1] if $index > 0;
+    for my $index (0 .. $#STANDARDS) {
+        if ($STANDARDS[$index][0] eq $stdver) {
+            $obsdate = $STANDARDS[$index - 1][1] if $index > 0;
             last;
         }
     }
-    if (str2time($obsdate, '+0000') + (60 * 60 * 24 * 365 * 2) < time) {
+    if ($obsdate + (60 * 60 * 24 * 365 * 2) < time) {
         tag 'ancient-standards-version', $tag;
     } else {
         # We have to get the package date from the changelog file.  If we
@@ -167,9 +135,9 @@ if (not exists $standards{$stdver}) {
         }
         my ($entry) = $changes->data;
         my $timestamp = $entry ? $entry->Timestamp : 0;
-        for my $standard (@standards) {
+        for my $standard (@STANDARDS) {
             last if $standard->[0] eq $stdver;
-            if (str2time($standard->[1], '+0000') < $timestamp) {
+            if ($standard->[1] < $timestamp) {
                 tag 'out-of-date-standards-version', $tag;
                 last;
             }
diff --git a/data/standards-version/release-dates b/data/standards-version/release-dates
new file mode 100644
index 0000000..75c18ee
--- /dev/null
+++ b/data/standards-version/release-dates
@@ -0,0 +1,50 @@
+# This is a list of all known standards versions, current and older, with
+# their dates of publication.  The dates are in seconds since epoch to
+# avoid having to do time conversion during the check.  (Believe it or
+# not, this takes a noticable amount of time.)
+#
+# To get the date of a new standards version, try:
+#
+#     perl -MDate::Parse -e 'print str2time("<date of release>"), "\n"'
+#
+# You'll need libtimedate-perl installed.
+
+3.8.0  1212562800
+3.7.3  1196668800
+3.7.2  1146639600
+3.7.1  1146639600
+3.7.0  1146034800
+3.6.2  1118991600
+3.6.1  1061276400
+3.6.0  1057734000
+3.5.10 1052550000
+3.5.9  1047024000
+3.5.8  1037347200
+3.5.7  1030777200
+3.5.6   996044400
+3.5.5   991378800
+3.5.4   988441200
+3.5.3   987318000
+3.5.2   982483200
+3.5.1   982224000
+3.5.0   980755200
+3.2.1   967100400
+3.2.0   964940400
+3.1.1   942739200
+3.1.0   941702400
+3.0.1   932022000
+3.0.0   930812400
+2.5.1   925196400
+2.5.0   909648000
+2.4.1   892537200
+2.4.0   886147200
+2.3.0   873097200
+2.2.0   868777200
+2.1.3   858412800
+2.1.2   848736000
+2.1.1   842511600
+2.1.0   841561200
+2.0.1   841474800
+2.0.0   841042800
+0.2.1   840783600
+0.2.0   840610800
diff --git a/debian/changelog b/debian/changelog
index 21e4659..cb64ce1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,15 +13,22 @@ lintian (2.1.7) UNRELEASED; urgency=low
   * checks/files:
     + [RA] Add swfobject.js to embedded-javascript-library.  Thanks, Paul
       Wise.  (Closes: #512363)
-  * checks/standards-version.desc:
+  * checks/standards-version{,.desc}:
     + [ADB] Add source-control-file to the list of information needed by
       the script.  Thanks, Raphael Geissert.  (Closes: #512563)
+    + [RA] Use Lintian::Data to get the standards versions and release
+      dates.  Dates are now in seconds since epoch, so remove the date
+      conversion code.
 
   * collection/*.desc:
     + [RA] Replace `' "balanced" quotes with straight double-quotes.  The
       old style looks strange with modern fonts.  Based on work by Raphael
       Geissert.
 
+  * data/standards-version/release-dates:
+    + [RA] Known standards versions and their release dates in seconds
+      since epoch, taken from checks/standards-version.
+
   * lib/Checker.pm:
     + [ADB] Remove some unused code.
   * lib/Lintian/Collect/Source.pm:
diff --git a/testset/diffs/debian/changelog b/testset/diffs/debian/changelog
index e8eee64..68a7df3 100644
--- a/testset/diffs/debian/changelog
+++ b/testset/diffs/debian/changelog
@@ -12,4 +12,4 @@ diffs (1-1~lint1) unstable; urgency=low
   (Closes Bug# 123893)
   (Closes #1239124)
 
- -- Lintian Maintainers <lintian-maint@debian.org>  Thu,  6 Mar 2003 18:00:00 -0600
+ -- Lintian Maintainers <lintian-maint@debian.org>  Fri,  7 Mar 2003 12:35:16 -0600

-- 
Debian package checker


Reply to: