Received: by mail.netbsd.org (Postfix, from userid 605) id 89EF684F63; Tue, 16 Aug 2022 20:06:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id C2BF584D57 for ; Tue, 16 Aug 2022 20:06:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id p1FUTcqgZH-S for ; Tue, 16 Aug 2022 20:06:06 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 3156984CEF for ; Tue, 16 Aug 2022 20:06:06 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 2AB62FB1A; Tue, 16 Aug 2022 20:06:06 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_166068036659300" MIME-Version: 1.0 Date: Tue, 16 Aug 2022 20:06:06 +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: <20220816200606.2AB62FB1A@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_166068036659300 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Tue Aug 16 20:06:06 UTC 2022 Modified Files: pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl Log Message: lintpkgsrc: cleanup: condense invalid_version To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 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. --_----------=_166068036659300 Content-Disposition: inline Content-Length: 2768 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.103 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.104 --- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.103 Tue Aug 16 19:40:24 2022 +++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Tue Aug 16 20:06:05 2022 @@ -1,5 +1,5 @@ #!@PERL5@ -# $NetBSD: lintpkgsrc.pl,v 1.103 2022/08/16 19:40:24 rillig Exp $ +# $NetBSD: lintpkgsrc.pl,v 1.104 2022/08/16 20:06:05 rillig Exp $ # Written by David Brownlee . # @@ -707,30 +707,23 @@ sub get_default_makefile_vars() { $default_vars->{PACKAGES} ||= $default_vars->{PKGSRCDIR} . '/packages'; } -# Determine if a package version is current. If not, report correct version -# if found -# +# Determine if a package version is current. If not, report the correct +# version if found. sub invalid_version($pkgmatch) { - my ($fail, $ok); - my @pkgmatches = expand_braces($pkgmatch); - foreach $pkgmatch (@pkgmatches) { + my @warnings; + foreach $pkgmatch (expand_braces($pkgmatch)) { my ($pkg, $badver) = package_globmatch($pkgmatch); + # If we find one match, it's good enough. + return () unless defined $badver; - if (defined $badver) { - if (my $pkgs = $pkgdb->pkgs($pkg)) { - $fail .= - "Version mismatch: '$pkg' $badver vs " - . join(',', $pkgs->versions) . "\n"; - } else { - $fail .= "Unknown package: '$pkg' version $badver\n"; - } - } else { - # If we find one match, don't bitch about others - $ok = 1; - } + my $pkgs = $pkgdb->pkgs($pkg); + push @warnings, $pkgs + ? "Version mismatch: '$pkg' $badver vs " + . join(',', $pkgs->versions) + : "Unknown package: '$pkg' version $badver"; } - $ok ? undef : $fail; + @warnings; } sub list_installed_packages() { @@ -1074,14 +1067,13 @@ sub pkgsrc_check_depends() { next unless $depend =~ s/:.*//; $depend = canonicalize_pkgname($depend); - if ((my $msg = invalid_version($depend))) { - if ($seen_header == 0) { - print $pkgver->pkgname . " DEPENDS errors:\n"; - $seen_header = 1; - } - $msg =~ s/(\n)(.)/$1\t$2/g; - print "\t$msg"; + next unless my @msgs = invalid_version($depend); + + if ($seen_header == 0) { + print $pkgver->pkgname . " DEPENDS errors:\n"; + $seen_header = 1; } + print map { "\t$_\n" } @msgs; } } } @@ -1545,9 +1537,9 @@ sub check_outdated_installed_packages($p my @update; foreach my $pkgname (sort @pkgs) { - next unless $_ = invalid_version($pkgname); + next unless my @warnings = invalid_version($pkgname); - print $_; + print map { "$_\n" } @warnings; next unless $pkgname =~ /^([^*?[]+)-([\d*?[].*)/; foreach my $pkgver ($pkgdb->pkgvers_by_pkgbase($1)) { --_----------=_166068036659300--