pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files lintpkgsrc: cleanup: inline ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/19adf9533b79
branches: trunk
changeset: 383055:19adf9533b79
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Aug 11 07:07:26 2022 +0000
description:
lintpkgsrc: cleanup: inline numpkgver, split pkgver
diffstat:
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 33 ++++++++++++---------------------
pkgtools/lintpkgsrc/files/t/packages.t | 14 +++++++-------
2 files changed, 19 insertions(+), 28 deletions(-)
diffs (144 lines):
diff -r b1a2b37447be -r 19adf9533b79 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Thu Aug 11 07:03:59 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Thu Aug 11 07:07:26 2022 +0000
@@ -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 @@
$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 @@
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 @@
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 @@
# 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 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 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 @@
}
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 @@
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";
diff -r b1a2b37447be -r 19adf9533b79 pkgtools/lintpkgsrc/files/t/packages.t
--- a/pkgtools/lintpkgsrc/files/t/packages.t Thu Aug 11 07:03:59 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/packages.t Thu Aug 11 07:07:26 2022 +0000
@@ -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_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