Received: by mail.netbsd.org (Postfix, from userid 605) id 012B584E7C; Sat, 13 Aug 2022 11:27:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 391AE84D67 for ; Sat, 13 Aug 2022 11:27:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id PzcHGDMiuMe9 for ; Sat, 13 Aug 2022 11:27:32 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 8CBA684CFA for ; Sat, 13 Aug 2022 11:27:32 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 7EF9CFB1A; Sat, 13 Aug 2022 11:27:32 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1660390052128910" MIME-Version: 1.0 Date: Sat, 13 Aug 2022 11:27:32 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/pkgtools/lintpkgsrc/files To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20220813112732.7EF9CFB1A@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1660390052128910 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Sat Aug 13 11:27:32 UTC 2022 Modified Files: pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl Log Message: lintpkgsrc: make distinfo parsing stricter There are no distinfo files anymore in which the filename starts with './', so remove that check. Complain about invalid distinfo lines. This flags a few pkgsrc-wip packages, but none in main pkgsrc. Extract load_distinfo into a separate subroutine, improve local variable names. Document that only the first distinfo algorithm (currently BLAKE2s) is ever checked. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_1660390052128910 Content-Disposition: inline Content-Length: 2951 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.85 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.86 --- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.85 Sat Aug 13 10:51:28 2022 +++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Sat Aug 13 11:27:32 2022 @@ -1,6 +1,6 @@ #!@PERL5@ -# $NetBSD: lintpkgsrc.pl,v 1.85 2022/08/13 10:51:28 rillig Exp $ +# $NetBSD: lintpkgsrc.pl,v 1.86 2022/08/13 11:27:32 rillig Exp $ # Written by David Brownlee . # @@ -1103,6 +1103,42 @@ sub pkgsrc_check_depends() { } } +sub load_distinfo($pkgsrcdir, $cat, $pkgdir, $distfiles, $warnings) { + my $fname = "$pkgsrcdir/$cat/$pkgdir/distinfo"; + open(DISTINFO, '<', $fname) or return; + + while (defined(my $line = )) { + chomp($line); + + next if $line eq '' || $line =~ /^\$NetBSD/; + + if ($line !~ m/^ (\w+) \s \( ([^)]+) \) \s=\s (\S+)/x) { + warn "Invalid line in $fname:$.: $line\n"; + next; + } + my ($alg, $distfile, $hash) = ($1, $2, $3); + + next if $distfile =~ /^patch-[\w.+\-]+$/; + + # Only store and check the first algorithm listed in distinfo. + if (!defined $distfiles->{$distfile}) { + $distfiles->{$distfile} = { + sumtype => $alg, + sum => $hash, + path => "$cat/$pkgdir", + }; + + } elsif ($distfiles->{$distfile}->{sumtype} eq $alg + && $distfiles->{$distfile}->{sum} ne $hash) { + push @$warnings, + "checksum mismatch between '$alg' for '$distfile' " + . "in $cat/$pkgdir " + . "and $distfiles->{$distfile}{path}\n"; + } + } + close(DISTINFO) or die; +} + # Extract all distinfo entries, then verify contents of distfiles # sub scan_pkgsrc_distfiles_vs_distinfo($pkgsrcdir, $pkgdistdir, $check_unref, @@ -1117,36 +1153,9 @@ sub scan_pkgsrc_distfiles_vs_distinfo($p $numpkg = 0; foreach my $cat (sort @categories) { foreach my $pkgdir (list_pkgsrc_pkgdirs($pkgsrcdir, $cat)) { - if (open(DISTINFO, "$pkgsrcdir/$cat/$pkgdir/distinfo")) { - ++$numpkg; - while () { - if (m/^(\w+) ?\(([^\)]+)\) = (\S+)/) { - my ($dn, $ds, $dt); - $dt = $1; - $dn = $2; - $ds = $3; - if ($dn =~ /^patch-[\w.+\-]+$/) { - next; - } - - # Strip leading ./ which sometimes gets added - # because of DISTSUBDIR=. - $dn =~ s/^(\.\/)*//; - if (!defined $distfiles{$dn}) { - $distfiles{$dn}{sumtype} = $dt; - $distfiles{$dn}{sum} = $ds; - $distfiles{$dn}{path} = "$cat/$pkgdir"; - - } elsif ($distfiles{$dn}{sumtype} eq $dt && $distfiles{$dn}{sum} ne $ds) { - push(@distwarn, - "checksum mismatch between '$dt' for '$dn' " - . "in $cat/$pkgdir and $distfiles{$dn}{path}\n" - ); - } - } - } - close(DISTINFO); - } + ++$numpkg; + load_distinfo($pkgsrcdir, $cat, $pkgdir, + \%distfiles, \@distwarn); } verbose('.'); } --_----------=_1660390052128910--