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

lintian: r44 - in trunk: checks debian



Author: jeroen
Date: 2004-02-16 21:36:59 +0100 (Mon, 16 Feb 2004)
New Revision: 44

Added:
   trunk/checks/deb-format
Removed:
   trunk/checks/deb-format
Modified:
   trunk/checks/deb-format.desc
   trunk/debian/changelog
   trunk/debian/control
Log:
checks/deb-format, debian/control:
+ Rewrite by Denis Barbier, slightly cleaned up, renders
  libarchive-tar-perl dependency unneeded (Closes: #232875)

(Denis Barbier's version had a little bit needless complexity, and a small bug
(didn't detect 0-size files)).

Thanks Denis! Great work.


Deleted: trunk/checks/deb-format
===================================================================
--- trunk/checks/deb-format	2004-02-15 14:22:59 UTC (rev 43)
+++ trunk/checks/deb-format	2004-02-16 20:36:59 UTC (rev 44)
@@ -1,98 +0,0 @@
-#!/usr/bin/perl -w
-# Most of this code is shamelessly stolen from Archive::Tar. Thanks.
-#
-# The copyright for the rest is as follows: 
-#
-# Copyright: (C) 2004 Marc Brockschmidt <marc@dch-faq.de>
-# Adapted to lintian by Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library General Public License as published
-# by the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-use strict;
-
-($#ARGV == 1) or fail("syntax: standards-version <pkg> <type>");
-my $pkg = shift;
-my $type = shift;
-
-use Archive::Tar;
-
-use constant HEAD           => 512;
-use constant TAR_END        => "\0" x 512;
-use constant BLOCK_SIZE     => sub { my $n = int($_[0]/512); $n++ if $_[0] % 512; $n * 512 };
-
-open INPUT, "ar p deb data.tar.gz | gzip -dc |";
-
-my ($chunk, $real_name, $data, $oldraw, $raw);
-while( read( INPUT, $chunk, HEAD ) ) {                  
-    ### if we can't read in all bytes... ###
-    last if length $chunk != HEAD;
-    
-    # Apparently this should really be two blocks of 512 zeroes,
-    # but GNU tar sometimes gets it wrong. See comment in the
-    # source code (tar.c) to GNU cpio.
-    last if $chunk eq TAR_END; 
-    
-    my $entry; 
-    unless( $entry = Archive::Tar::File->_new_from_chunk( $chunk ) ) {
-        warn ( qq[Couldnt read chunk '$chunk'] );
-        next;
-    }
-    
-    ### ignore labels:
-    ### http://www.gnu.org/manual/tar/html_node/tar_139.html
-    next if $entry->is_label;
-    
-    if( length $entry->type and ($entry->is_file || $entry->is_longlink) ) {      
-        ### part II of the @LongLink munging -- need to do /after/
-        ### the checksum check.
-
-        my $block = BLOCK_SIZE->( $entry->size );
-
-        $data = $entry->get_content_by_ref;
-        
-        ### just read everything into memory 
-        ### can't do lazy loading since IO::Zlib doesn't support 'seek'
-        ### this is because Compress::Zlib doesn't support it =/            
-        if( read( INPUT, $$data, $block ) < $block ) {
-            die ( qq[Read error on tarfile ]. $entry->name ."'" );
-        }
-
-        ### throw away trailing garbage ###
-        substr ($$data, $entry->size) = "";
-    }
-
-    $oldraw = $raw;
-    $raw = $entry->raw();
-
-    ### clean up of the entries.. posix tar /apparently/ has some
-    ### weird 'feature' that allows for filenames > 255 characters
-    ### they'll put a header in with as name '././@LongLink' and the
-    ### contents will be the name of the /next/ file in the archive
-    ### pretty crappy and kludgy if you ask me
-    
-    ### set the name for the next entry if this is a @LongLink;
-    ### this is one ugly hack =/ but needed for direct extraction
-    if( $entry->is_longlink ) {
-        $real_name = $data;	
-        next;
-    } elsif ( defined $real_name ) {
-        $entry->name( $$real_name );
-        undef $real_name;
-    }
-
-	my $name = substr($raw, 0, 100);
-	$name =~ s/\x00/-/g;
-
-	print "E: $pkg $type: deb-created-with-broken-tar broken file: /$name\n"
-		if ((length($name) == 100) && ($name eq $entry->name()) &&
-			substr($oldraw, 0, 13) ne '././@LongLink');
-    
-    ### Guard against tarfiles with garbage at the end
-    last if $entry->name eq ''; 
-} continue {
-    undef $data;
-}
-

Added: trunk/checks/deb-format
===================================================================
--- trunk/checks/deb-format	2004-02-15 14:22:59 UTC (rev 43)
+++ trunk/checks/deb-format	2004-02-16 20:36:59 UTC (rev 44)
@@ -0,0 +1,64 @@
+#! /usr/bin/perl -w
+
+# deb-format -- lintian check script
+
+# Copyright (C) 2004 Denis Barbier
+# Based on a check provided by Marc 'HE' Brockschmidt.
+# Code cleared up a bit, and fix one thinko by Jeroen van Wolffelaar
+# 
+# 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., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+use strict;
+
+($#ARGV == 1) or fail("syntax: deb-format <pkg> <type>");
+my $pkg = shift;
+my $type = shift;
+
+sub get_block_size {
+	my $size = shift;
+	my $nblocks = int($size / 512);
+	$nblocks ++ if (($size % 512) > 0);
+	return 512*$nblocks;
+}
+
+open INPUT, "ar p deb data.tar.gz | gzip -dc |";
+
+my $chunk;
+# Previous was a LongLink?
+my $is_long = 0;
+while (read(INPUT, $chunk, 512)) {
+	last if length($chunk) != 512;
+	my ($name, $size, $type) = unpack "A100x24A12x20A1", $chunk;
+	$size = oct($size);
+
+	if (!$is_long && length($name) == 100) {
+		# This should have been a LongLink, as now the filename isn't
+		# NUL-terminated, as dpkg -i expects.
+		print "E: $pkg $type: deb-created-with-broken-tar file: $name\n";
+	}
+
+	$is_long = $type eq 'L';
+
+	# eat data
+	if ($size) {
+		read(INPUT, $chunk, get_block_size($size)) or last;
+	}
+}
+
+close INPUT;
+
+# vim: ts=4 sw=4


Property changes on: trunk/checks/deb-format
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/checks/deb-format.desc
===================================================================
--- trunk/checks/deb-format.desc	2004-02-15 14:22:59 UTC (rev 43)
+++ trunk/checks/deb-format.desc	2004-02-16 20:36:59 UTC (rev 44)
@@ -14,4 +14,5 @@
  unpack, some filenames are going to be corrupted.
  .
  This package was build with such a version of tar, and the mentioned filename
- is corrupted. Refer to Debian bug #230910 for more information.
+ is corrupted. Refer to Debian bug #230910 for more information, or simply
+ update your tar-version and rebuild.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-02-15 14:22:59 UTC (rev 43)
+++ trunk/debian/changelog	2004-02-16 20:36:59 UTC (rev 44)
@@ -11,6 +11,9 @@
      (Patch by Frank Lichtenheld <djpig@debian.org>)
    * checks/binaries.desc:
      + Fix typo (Closes: #202856)
+   * checks/deb-format, debian/control:
+     + Rewrite by Denis Barbier, slightly cleaned up, renders
+       libarchive-tar-perl dependency unneeded (Closes: #232875)
    * checks/filenames (and more):
      + Check for Subversion version control leftovers (Closes: #190067)
      + Ignore empty __init__.py files in /usr/share/doc (Closes: #215234)
@@ -44,9 +47,6 @@
      + Recognise the 'tcl' interpreter, not the same as tclsh (Closes: #230182)
 
   Frank Lichtenheld <djpig@debian.org>
-   * debian/control,checks/deb-format:
-     + Move libarchive-tar-perl to Depends and make it versioned
-     + So just fail in checks/deb-format if Archive::Tar is missing
    * checks/debhelper:
      + fix parsing debian/compat for needed
        version (Closes: #198611)
@@ -62,7 +62,7 @@
      + fix testing of dependencies to eliminate false
        positives of missing-debconf-dependency (Closes: #195201)
 
- -- Jeroen van Wolffelaar <jeroen@wolffelaar.nl>  Thu, 12 Feb 2004 21:20:41 +0100
+ -- Jeroen van Wolffelaar <jeroen@wolffelaar.nl>  Mon, 16 Feb 2004 21:17:59 +0100
 
 lintian (1.22.10) unstable; urgency=low
 

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control	2004-02-15 14:22:59 UTC (rev 43)
+++ trunk/debian/control	2004-02-16 20:36:59 UTC (rev 44)
@@ -11,7 +11,7 @@
 
 Package: lintian
 Architecture: all
-Depends: perl, file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1), libarchive-tar-perl (>= 1)
+Depends: perl, file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1)
 Suggests: binutils-multiarch, gettext
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy



Reply to: