pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/lintpkgsrc/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Thu Aug 11 07:07:27 UTC 2022

Modified Files:
        pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl
        pkgsrc/pkgtools/lintpkgsrc/files/t: packages.t

Log Message:
lintpkgsrc: cleanup: inline numpkgver, split pkgver


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r1.10 -r1.11 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.72 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.73
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.72 Wed Aug 10 22:43:55 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Thu Aug 11 07:07:26 2022
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.72 2022/08/10 22:43:55 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.73 2022/08/11 07:07:26 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -117,26 +117,17 @@ sub add($self, $pkgbase, $pkgversion) {
        $pkgs->add($pkgbase, $pkgversion);
 }
 
-sub numpkgver($self) {
-       scalar $self->pkgver;
+# All PkgVers, sorted by pkgbase, then by version in decreasing
+# alphabetical(!) order.
+sub pkgvers_all($self) {
+       map { $_->pkgver } $self->pkgs;
 }
 
-# pkgver() returns all PkgVers, sorted by pkgbase, then by version in
-# decreasing alphabetical(!) order.
-#
 # pkgver($pkgbase) returns all PkgVers of the given pkgbase, sorted by
 # version in decreasing alphabetical(!) order.
 #
 # pkgver($pkgbase, $pkgversion) returns the package, or undef.
 sub pkgver($self, $pkgbase = undef, $pkgversion = undef) {
-       if (!defined $pkgbase) {
-               my (@pkgvers);
-               foreach my $pkg ($self->pkgs) {
-                       push @pkgvers, $pkg->pkgver;
-               }
-               return @pkgvers;
-       }
-
        my $pkgs = $self->{$pkgbase};
        defined $pkgs && defined $pkgversion
            ? $pkgs->pkgver($pkgversion)
@@ -908,7 +899,7 @@ sub package_globmatch($pkgmatch) {
                if ($matchver && ($regex = glob2regex($pkgmatch))) {
 
                        # (large-glob)
-                       foreach my $pkgver ($pkgdb->pkgver) {
+                       foreach my $pkgver ($pkgdb->pkgvers_all) {
                                if ($pkgver->pkgname =~ /$regex/) {
                                        $matchver = undef;
                                        last;
@@ -1093,7 +1084,7 @@ sub scan_pkgsrc_makefiles($pkgsrcdir) {
        if (!$opt{L}) {
                my ($len);
 
-               $_ = $pkgdb->numpkgver() . ' packages';
+               $_ = scalar $pkgdb->pkgvers_all . ' packages';
                $len = @categories - length($_);
                verbose("\b" x @categories, $_, ' ' x $len, "\b" x $len, "\n");
        }
@@ -1102,7 +1093,7 @@ sub scan_pkgsrc_makefiles($pkgsrcdir) {
 # Cross reference all depends
 #
 sub pkgsrc_check_depends() {
-       foreach my $pkgver ($pkgdb->pkgver) {
+       foreach my $pkgver ($pkgdb->pkgvers_all) {
                my ($err, $msg);
 
                defined $pkgver->var('DEPENDS') || next;
@@ -1244,7 +1235,7 @@ sub scan_pkgsrc_distfiles_vs_distinfo($p
 sub store_pkgsrc_makefiles($db, $fname) {
        open(STORE, '>', $fname)
            or die("Cannot save pkgsrc store to $fname: $!\n");
-       foreach my $pkgver ($db->pkgver) {
+       foreach my $pkgver ($db->pkgvers_all) {
                my $pkgbase = $pkgver->pkgbase;
                my $pkgversion = $pkgver->pkgversion;
 
@@ -1490,7 +1481,7 @@ sub remove_distfiles($pkgsrcdir, $pkgdis
 
 sub list_broken_packages($pkgsrcdir) {
        scan_pkgsrc_makefiles($pkgsrcdir);
-       foreach my $pkgver ($pkgdb->pkgver) {
+       foreach my $pkgver ($pkgdb->pkgvers_all) {
                my $broken = $pkgver->var('BROKEN');
                next unless $broken;
                print $pkgver->pkgname . ": $broken\n";
@@ -1532,7 +1523,7 @@ sub list_packages_not_in_SUBDIR($pkgsrcd
        }
 
        scan_pkgsrc_makefiles($pkgsrcdir);
-       foreach my $pkgver ($pkgdb->pkgver) {
+       foreach my $pkgver ($pkgdb->pkgvers_all) {
                my $pkgpath = $pkgver->var('dir');
                if (!defined $in_subdir{$pkgpath}) {
                        print "$pkgpath: Not in SUBDIR\n";
@@ -1545,7 +1536,7 @@ sub generate_map_file($pkgsrcdir, $fname
 
        scan_pkgsrc_makefiles($pkgsrcdir);
        open(TABLE, '>', $tmpfile) or fail("Cannot write '$tmpfile': $!");
-       foreach my $pkgver ($pkgdb->pkgver) {
+       foreach my $pkgver ($pkgdb->pkgvers_all) {
                print TABLE $pkgver->pkgbase . "\t"
                    . $pkgver->var('dir') . "\t"
                    . $pkgver->pkgversion . "\n";

Index: pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.10 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.11
--- pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.10  Thu Aug  4 21:55:58 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t       Thu Aug 11 07:07:27 2022
@@ -1,4 +1,4 @@
-# $NetBSD: packages.t,v 1.10 2022/08/04 21:55:58 rillig Exp $
+# $NetBSD: packages.t,v 1.11 2022/08/11 07:07:27 rillig Exp $
 
 use strict;
 use warnings;
@@ -37,23 +37,23 @@ sub test_pkgs() {
 sub test_pkgdb() {
        my $pkgdb = PkgDb->new();
 
-       ok($pkgdb->numpkgver, 0);
-       ok(join(', ', map { $_->pkgname } $pkgdb->pkgver), '');
+       ok(scalar $pkgdb->pkgvers_all, 0);
+       ok(join(', ', map { $_->pkgname } $pkgdb->pkgvers_all), '');
 
        $pkgdb->add('base', '1.0');
 
-       ok($pkgdb->numpkgver, 1);
+       ok(scalar $pkgdb->pkgvers_all, 1);
 
        $pkgdb->add('other', '5.7');
 
-       ok($pkgdb->numpkgver, 2);
+       ok(scalar $pkgdb->pkgvers_all, 2);
 
        my $base_8_0 = $pkgdb->add('base', '8.0');
 
-       ok($pkgdb->numpkgver, 3);
+       ok(scalar $pkgdb->pkgvers_all, 3);
        ok($base_8_0->pkgname, 'base-8.0');
 
-       my $actual = join(', ', map { $_->pkgname } $pkgdb->pkgver);
+       my $actual = join(', ', map { $_->pkgname } $pkgdb->pkgvers_all);
        ok($actual, 'base-8.0, base-1.0, other-5.7');
 
        $actual = join(', ', map { $_->pkgname } $pkgdb->pkgver('base'));



Home | Main Index | Thread Index | Old Index