From sem@ciam.ru  Sun May  7 16:15:44 2006
Return-Path: <sem@ciam.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E860B16A400
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 May 2006 16:15:43 +0000 (UTC)
	(envelope-from sem@ciam.ru)
Received: from mail.ciam.ru (ns.ciam.ru [213.247.195.75])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3CA5443D46
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 May 2006 16:15:42 +0000 (GMT)
	(envelope-from sem@ciam.ru)
Received: from [87.240.16.199] (helo=solem.sem-home.ciam.ru)
	by mail.ciam.ru with esmtpa (Exim 4.x)
	id 1Fclv2-000Gcp-TV
	for FreeBSD-gnats-submit@freebsd.org; Sun, 07 May 2006 20:15:41 +0400
Received: from sem by solem.sem-home.ciam.ru with local (Exim 4.61 (FreeBSD))
	(envelope-from <sem@solem.sem-home.ciam.ru>)
	id 1Fcluw-000B7j-Oo
	for FreeBSD-gnats-submit@freebsd.org; Sun, 07 May 2006 20:15:34 +0400
Message-Id: <E1Fcluw-000B7j-Oo@solem.sem-home.ciam.ru>
Date: Sun, 07 May 2006 20:15:34 +0400
From: Sergey Matveychuk <sem@FreeBSD.org>
Sender: Sergey Matveychuk <sem@ciam.ru>
Reply-To: Sergey Matveychuk <sem@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] devel/portlint lacks distinfo file check
X-Send-Pr-Version: 3.113
X-GNATS-Notify: marcus@FreeBSD.org

>Number:         96923
>Category:       ports
>Synopsis:       [patch] devel/portlint lacks distinfo file check
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    marcus
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 07 16:20:16 GMT 2006
>Closed-Date:    Wed May 31 04:44:29 GMT 2006
>Last-Modified:  Wed May 31 04:44:29 GMT 2006
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD solem.sem-home.ciam.ru 7.0-CURRENT FreeBSD 7.0-CURRENT #33: Sat Apr 29 14:09:38 MSD 2006 root@solem.sem-home.ciam.ru:/usr/obj/usr/src/sys/SOLEM i386


	
>Description:
	
	portlint does not checks distinfo file.
	The patch add the feature to portlint.
	I've tested it running portlint on all ports tree.

	There are a couple things I'm not sure:
	1) May be warning of IGNOREFILES should be moved in other place?
	2) Syntax of FATAL and WARN message. Check it please.
>How-To-Repeat:
	
>Fix:

	

--- portlint.diff begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/devel/portlint/Makefile,v
retrieving revision 1.108
diff -u -r1.108 Makefile
--- Makefile	7 Apr 2006 00:08:00 -0000	1.108
+++ Makefile	7 May 2006 12:42:07 -0000
@@ -8,7 +8,7 @@
 #
 
 PORTNAME=	portlint
-PORTVERSION=	2.8.7
+PORTVERSION=	2.8.8
 CATEGORIES=	devel
 MASTER_SITES=	# none
 DISTFILES=	# none
Index: src/portlint.pl
===================================================================
RCS file: /home/pcvs/ports/devel/portlint/src/portlint.pl,v
retrieving revision 1.88
diff -u -r1.88 portlint.pl
--- src/portlint.pl	12 Mar 2006 19:19:43 -0000	1.88
+++ src/portlint.pl	7 May 2006 12:42:08 -0000
@@ -177,6 +177,7 @@
 	PKGREQ PKGMESSAGE MD5_FILE .CURDIR INSTALLS_SHLIB USE_AUTOTOOLS
 	INDEXFILE PKGORIGIN CONFLICTS PKG_VERSION PKGINSTALLVER
 	PLIST_FILES OPTIONS INSTALLS_OMF USE_GETTEXT USE_RC_SUBR
+	DIST_SUBDIR ALLFILES IGNOREFILES CHECKSUM_ALGORITHMS
 );
 
 my $cmd = join(' -V ', "make $makeenv MASTER_SITE_BACKUP=''", @varlist);
@@ -257,7 +258,7 @@
 my %checker = (
 	$makevar{DESCR} => \&checkdescr,
 	'Makefile' => \&checkmakefile,
-	$makevar{MD5_FILE} => \&TRUE
+	$makevar{MD5_FILE} => \&checkdistinfo
 );
 if ($extrafile) {
 	my @files = (
@@ -502,6 +503,74 @@
 exit $err;
 
 #
+# distinfo
+#
+sub checkdistinfo {
+	my($file) = @_;
+	my($dist_subdir) = $makevar{DIST_SUBDIR};
+	my(@allfiles) = split (/\s+/, $makevar{ALLFILES});
+	my %ignorefiles = ();
+	my %algorithms = ();
+	my %records = ();
+
+	foreach my $i (split (/\s+/, $makevar{IGNOREFILES})) {
+		$ignorefiles{$i} = 1;
+	}
+	foreach my $i (split (/\s+/, uc ($makevar{CHECKSUM_ALGORITHMS}))) {
+		$algorithms{$i} = 1;
+	}
+
+	if (scalar (%ignorefiles)) {
+		&perror("WARN: Found IGNOREFILES. It's not recomended.");
+	}
+
+	open(IN, "< $file") || return 0;
+	while (<IN>) {
+		if (/^\s*$/) {
+			&perror("FATAL: $file [$.]: a blank line.");
+			next;
+		}
+		m/(\S+)\s+\((\S+)\)\s+=\s+(\S+)/;
+
+		if ($1 ne "" && $2 ne "" && $3 ne "") {
+			my ($tag, $path, $value) = ($1, $2, $3);
+			$records{$path}{$tag} = $value;
+
+			if (!$algorithms{$tag} && $tag ne "SIZE") {
+				&perror("FATAL: $file [$.]: unsupported checksum algorithm found: $tag.");
+			}
+		} else {
+			&perror("FATAL: $file [$.]: line format error.");
+		}
+	}
+	close(IN);
+
+	# For all files check SIZE and checksums
+	foreach my $f (@allfiles) {
+		# Remove hindering chars from DISTNAME
+		$f =~ s/['\\]//g;
+
+		my $path = $f;
+		$path = "$dist_subdir/$f" if $dist_subdir;
+		if (!defined($records{$path}{SIZE}) && !$ignorefiles{$f}) {
+			&perror("FATAL: $file has no SIZE record for $path.");
+		}
+		my $n = 0;
+		foreach my $alg (keys %algorithms) {
+			$n++ if exists($records{$path}{$alg});
+		}
+		if ($n == 0) {
+			&perror("FATAL: $file has no checksum record for $path.");
+		}
+		if ($n < scalar(keys %algorithms)) {
+			&perror("WARN: $file has checksum records not for all supported ".
+				"algorithms (".join(" ",keys %algorithms).") for $path.");
+		}
+	}
+	return 1;
+}
+
+#
 # pkg-descr
 #
 sub checkdescr {
--- portlint.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->marcus 
Responsible-Changed-By: sem 
Responsible-Changed-When: Sun May 7 16:24:10 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96923 
State-Changed-From-To: open->patched 
State-Changed-By: marcus 
State-Changed-When: Tue May 30 04:36:44 UTC 2006 
State-Changed-Why:  
Patched in my CVS repo.  It will be committed with the 2.9.0 update. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96923 
State-Changed-From-To: patched->closed 
State-Changed-By: marcus 
State-Changed-When: Wed May 31 04:44:19 UTC 2006 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96923 
>Unformatted:
