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: clean up Pkgs type
details: https://anonhg.NetBSD.org/pkgsrc/rev/e06a83e4ffae
branches: trunk
changeset: 383135:e06a83e4ffae
user: rillig <rillig%pkgsrc.org@localhost>
date: Fri Aug 12 20:53:01 2022 +0000
description:
lintpkgsrc: clean up Pkgs type
diffstat:
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 38 +++++++++++++-------------------
pkgtools/lintpkgsrc/files/t/packages.t | 9 ++++---
2 files changed, 21 insertions(+), 26 deletions(-)
diffs (120 lines):
diff -r 66cd0e3b88fc -r e06a83e4ffae pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Fri Aug 12 20:37:59 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Fri Aug 12 20:53:01 2022 +0000
@@ -1,6 +1,6 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.76 2022/08/11 18:55:35 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.77 2022/08/12 20:53:01 rillig Exp $
# Written by David Brownlee <abs%netbsd.org@localhost>.
#
@@ -17,11 +17,11 @@
use locale;
use strict;
use warnings;
-use Getopt::Std;
-use File::Find;
+use Cwd 'realpath', 'getcwd';
use File::Basename;
+use File::Find;
+use Getopt::Std;
use IPC::Open3;
-use Cwd 'realpath', 'getcwd';
# PkgVer is a PKGBASE + PKGVERSION, including some of the variables that
# have been extracted from the package Makefile.
@@ -49,10 +49,10 @@
$self->pkgbase . '-' . $self->pkgversion;
}
-sub var($self, $key, $val = undef) {
- defined $val
- ? ($self->{vars}->{$key} = $val)
- : $self->{vars}->{$key};
+sub var($self, $name, $value = undef) {
+ defined $value
+ ? ($self->{vars}->{$name} = $value)
+ : $self->{vars}->{$name};
}
sub vars($self) {
@@ -87,20 +87,14 @@
$self->{pkgvers}->{$pkgversion} = PkgVer->new($pkgbase, $pkgversion);
}
-# pkgver() returns all PkgVers of this pkgbase, in decreasing alphabetical(!)
-# version order.
-#
-# pkgver($pkgversion) returns the PkgVer, or undef.
-sub pkgver($self, $pkgversion = undef) {
+# All PkgVers of this pkgbase, in decreasing alphabetical(!) version order.
+sub pkgvers_all($self) {
my $pkgvers = $self->{pkgvers};
- defined $pkgversion
- ? $pkgvers->{$pkgversion}
- : sort { $b->pkgversion cmp $a->pkgversion } values %$pkgvers;
+ sort { $b->pkgversion cmp $a->pkgversion } values %$pkgvers;
}
-# XXX: Returns the alphabetically(!) highest PkgVer.
-sub latestver($self) {
- ($self->pkgver)[0];
+sub pkgver($self, $pkgversion) {
+ $self->{pkgvers}->{$pkgversion}
}
# PkgDb is a small database of all packages in pkgsrc.
@@ -120,14 +114,14 @@
# All PkgVers, sorted by pkgbase, then by version in decreasing
# alphabetical(!) order.
sub pkgvers_all($self) {
- map { $_->pkgver } $self->pkgs;
+ map { $_->pkgvers_all } $self->pkgs;
}
# All PkgVers of the given pkgbase, sorted by version in decreasing
# alphabetical(!) order.
sub pkgvers_by_pkgbase($self, $pkgbase) {
my $pkgs = $self->{$pkgbase};
- defined $pkgs ? $pkgs->pkgver : ();
+ defined $pkgs ? $pkgs->pkgvers_all : ();
}
sub pkgver($self, $pkgbase, $pkgversion) {
@@ -1315,7 +1309,7 @@
}
# Pick probably the last version
- $pkgver = $pkgs->latestver;
+ $pkgver = ($pkgs->pkgvers_all)[0];
}
if ($opt{R} && $pkgver->var('RESTRICTED')) {
diff -r 66cd0e3b88fc -r e06a83e4ffae pkgtools/lintpkgsrc/files/t/packages.t
--- a/pkgtools/lintpkgsrc/files/t/packages.t Fri Aug 12 20:37:59 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/packages.t Fri Aug 12 20:53:01 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: packages.t,v 1.12 2022/08/11 07:18:47 rillig Exp $
+# $NetBSD: packages.t,v 1.13 2022/08/12 20:53:01 rillig Exp $
use strict;
use warnings;
@@ -25,13 +25,14 @@
$pkgs->add('base', '1.0nb4');
- ok(($pkgs->pkgver)[0]->pkgbase, 'base');
- ok(($pkgs->pkgver)[0]->pkgversion, '1.0nb4');
+ ok(($pkgs->pkgvers_all)[0]->pkgname, 'base-1.0nb4');
$pkgs->add('base', '1.0nb20');
# FIXME: The latest version is actually 1.0nb20, not 1.0nb4.
- ok($pkgs->latestver->pkgversion, '1.0nb4');
+ # As of 2022-08-12, [0] is the alphabetically(!) largest version.
+ ok(($pkgs->pkgvers_all)[0]->pkgname, 'base-1.0nb4');
+ ok(($pkgs->pkgvers_all)[1]->pkgname, 'base-1.0nb20');
}
sub test_pkgdb() {
Home |
Main Index |
Thread Index |
Old Index