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: Wed Aug 3 19:22:34 UTC 2022
Modified Files:
pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl
pkgsrc/pkgtools/lintpkgsrc/files/t: packages.t
Log Message:
lintpkgsrc: refactor PkgVer internals to be more descriptive
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r1.4 -r1.5 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.43 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.44
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.43 Wed Aug 3 16:15:49 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Wed Aug 3 19:22:34 2022
@@ -1,6 +1,6 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.43 2022/08/03 16:15:49 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.44 2022/08/03 19:22:34 rillig Exp $
# Written by David Brownlee <abs%netbsd.org@localhost>.
#
@@ -28,53 +28,53 @@ use Cwd 'realpath', 'getcwd';
package PkgVer;
sub new($$$) {
- my $class = shift;
- my $self = {};
-
+ my ($class, $pkgbase, $pkgversion) = @_;
+ my $self = {
+ pkgbase => $pkgbase,
+ pkgversion => $pkgversion,
+ vars => {},
+ };
bless $self, $class;
- $self->{_pkg} = $_[0];
- $self->{_ver} = $_[1];
return $self;
}
-sub pkgname($) {
- my $self = shift;
+sub pkg($) {
+ my ($self) = @_;
- $self->pkg . '-' . $self->ver;
+ $self->{pkgbase};
}
-sub pkg($) {
- my $self = shift;
+sub ver($) {
+ my ($self) = @_;
- $self->{_pkg};
+ $self->{pkgversion};
}
-sub var($$$) {
+sub pkgname($) {
my $self = shift;
- my ($key, $val) = @_;
- (defined $val)
- ? ($self->{$key} = $val)
- : $self->{$key};
+ $self->pkg . '-' . $self->ver;
}
-sub ver($) {
- my $self = shift;
+sub var($$$) {
+ my ($self, $key, $val) = @_;
- $self->{_ver};
+ (defined $val)
+ ? ($self->{vars}->{$key} = $val)
+ : $self->{vars}->{$key};
}
sub vars($) {
- my $self = shift;
+ my ($self) = @_;
- grep(!/^_(pkg|ver)$/, keys %{$self});
+ keys %{$self->{vars}};
}
sub store($) {
my $self = shift;
- my $name = $self->{_pkg};
- my $ver = $self->{_ver};
+ my $name = $self->pkg;
+ my $ver = $self->ver;
$name =~ /\s/ and die "cannot store package name '$name'\n";
$ver =~ /\s/ and die "cannot store package version '$ver'\n";
Index: pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.4 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.5
--- pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.4 Wed Aug 3 18:51:56 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t Wed Aug 3 19:22:34 2022
@@ -1,4 +1,4 @@
-# $NetBSD: packages.t,v 1.4 2022/08/03 18:51:56 rillig Exp $
+# $NetBSD: packages.t,v 1.5 2022/08/03 19:22:34 rillig Exp $
use strict;
use warnings;
@@ -9,6 +9,14 @@ BEGIN { plan tests => 11, onfail => sub
require('../lintpkgsrc.pl');
+sub test_pkgver() {
+ my $pkgver = PkgVer->new('base', '1.0nb4');
+
+ ok($pkgver->pkg , 'base');
+ ok($pkgver->ver , '1.0nb4');
+ ok($pkgver->pkgname , 'base-1.0nb4');
+}
+
sub test_package_variables() {
my $pkglist = PkgList->new();
my $pkgbase_1_0 = $pkglist->add('pkgbase', '1.0');
@@ -57,5 +65,6 @@ sub test_store_order() {
. "package\tpkgbase\t1.3nb4\n");
}
+test_pkgver();
test_package_variables();
test_store_order();
Home |
Main Index |
Thread Index |
Old Index