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: Fri Aug 12 20:53:01 UTC 2022
Modified Files:
pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl
pkgsrc/pkgtools/lintpkgsrc/files/t: packages.t
Log Message:
lintpkgsrc: clean up Pkgs type
To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r1.12 -r1.13 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.76 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.77
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.76 Thu Aug 11 18:55:35 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Fri Aug 12 20:53:01 2022
@@ -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 v5.36;
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 @@ sub pkgname($self) {
$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 @@ sub add($self, $pkgbase, $pkgversion) {
$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 @@ sub add($self, $pkgbase, $pkgversion) {
# 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 @@ sub check_prebuilt_packages() {
}
# Pick probably the last version
- $pkgver = $pkgs->latestver;
+ $pkgver = ($pkgs->pkgvers_all)[0];
}
if ($opt{R} && $pkgver->var('RESTRICTED')) {
Index: pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.12 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.13
--- pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.12 Thu Aug 11 07:18:47 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t Fri Aug 12 20:53:01 2022
@@ -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 @@ sub test_pkgs() {
$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