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: rename ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/9c2b0723e970
branches: trunk
changeset: 383275:9c2b0723e970
user: rillig <rillig%pkgsrc.org@localhost>
date: Tue Aug 16 20:54:35 2022 +0000
description:
lintpkgsrc: cleanup: rename PkgDb to PkgData
The previous name could be confused with the pkgdb directory that holds
information about the currently installed packages.
diffstat:
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 60 ++++++++++++++--------------
pkgtools/lintpkgsrc/files/t/packages.t | 68 ++++++++++++++++----------------
2 files changed, 64 insertions(+), 64 deletions(-)
diffs (truncated from 369 to 300 lines):
diff -r 9f04d2568322 -r 9c2b0723e970 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Tue Aug 16 20:28:41 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Tue Aug 16 20:54:35 2022 +0000
@@ -1,5 +1,5 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.106 2022/08/16 20:28:41 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.107 2022/08/16 20:54:35 rillig Exp $
# Written by David Brownlee <abs%netbsd.org@localhost>.
#
@@ -94,8 +94,8 @@
$self->{pkgvers}->{$pkgversion}
}
-# PkgDb is a small database of all packages in pkgsrc.
-package PkgDb;
+# PkgData is a small database of all packages in pkgsrc.
+package PkgData;
sub new($class) {
my $self = {}; # pkgbase => Pkgs
@@ -146,7 +146,7 @@
my $conf_x11base = '@X11BASE@';
my (
- $pkgdb, # Database of pkgsrc packages
+ $pkgdata, # Database of pkgsrc packages
$default_vars, # Set for Makefiles, inc PACKAGES & PKGSRCDIR
%opt, # Command line options
@matched_prebuiltpackages, # List of obsolete prebuilt package paths
@@ -729,7 +729,7 @@
# If we find one match, it's good enough.
return () unless defined $badver;
- my $pkgs = $pkgdb->pkgs($pkg);
+ my $pkgs = $pkgdata->pkgs($pkg);
push @warnings, $pkgs
? "Version mismatch: '$pkg' $badver vs "
. join(',', $pkgs->versions)
@@ -836,7 +836,7 @@
if ($pkgmatch =~ /^ ([^*?[]+) (<|>|<=|>=|-) (\d[^*?[{]*) $/x) {
my ($match_base, $op, $match_ver) = ($1, $2, $3);
- my @pkgvers = $pkgdb->pkgvers_by_pkgbase($match_base);
+ my @pkgvers = $pkgdata->pkgvers_by_pkgbase($match_base);
foreach my $pkgver (@pkgvers) {
if ($op eq '-'
? $pkgver->pkgversion eq $match_ver
@@ -854,11 +854,11 @@
my ($matchpkgname, $matchver) = ($1, $2);
my @pkgnames;
- if (defined $pkgdb->pkgs($matchpkgname)) {
+ if (defined $pkgdata->pkgs($matchpkgname)) {
push @pkgnames, $matchpkgname;
} elsif (my $regex = glob2regex($matchpkgname)) {
- foreach my $pkg ($pkgdb->pkgs) {
+ foreach my $pkg ($pkgdata->pkgs) {
if ($pkg->pkgbase =~ /$regex/) {
push @pkgnames, $pkg->pkgbase;
}
@@ -870,12 +870,12 @@
my $regex = glob2regex($matchver);
foreach my $pkg (@pkgnames) {
- if (defined $pkgdb->pkgver($pkg, $matchver)) {
+ if (defined $pkgdata->pkgver($pkg, $matchver)) {
return ($matchver);
}
if ($regex) {
- foreach my $ver ($pkgdb->pkgs($pkg)->versions) {
+ foreach my $ver ($pkgdata->pkgs($pkg)->versions) {
if ($ver =~ /$regex/) {
$matchver = undef;
last;
@@ -891,7 +891,7 @@
if ($matchver && ($regex = glob2regex($pkgmatch))) {
# (large-glob)
- foreach my $pkgver ($pkgdb->pkgvers_all) {
+ foreach my $pkgver ($pkgdata->pkgvers_all) {
if ($pkgver->pkgname =~ /$regex/) {
$matchver = undef;
last;
@@ -972,8 +972,8 @@
print "\nBogus: $pkgname (from $file)\n";
} elsif ($pkgname =~ /(.*)-(\d.*)/) {
- if ($pkgdb) {
- my ($pkgver) = $pkgdb->add($1, $2);
+ if ($pkgdata) {
+ my ($pkgver) = $pkgdata->add($1, $2);
debug("add $1 $2");
@@ -1010,15 +1010,15 @@
return $prev_dir;
}
-sub load_pkgdb_from_cache($fname) {
+sub load_pkgdata_from_cache($fname) {
open(STORE, '<', $fname)
or die("Cannot read pkgsrc store from $fname: $!\n");
my ($pkgver);
- $pkgdb = PkgDb->new();
+ $pkgdata = PkgData->new();
while (defined(my $line = <STORE>)) {
chomp($line);
if ($line =~ m"^ package \t ([^\t]+) \t ([^\t]+) $"x) {
- $pkgver = $pkgdb->add($1, $2);
+ $pkgver = $pkgdata->add($1, $2);
} elsif ($line =~ m"^ var \t ([^\t]+) \t (.*) $"x) {
$pkgver->var($1, $2);
} elsif ($line =~ m"^ sub ") {
@@ -1034,14 +1034,14 @@
#
sub scan_pkgsrc_makefiles($pkgsrcdir) {
- return if defined $pkgdb; # Already done.
+ return if defined $pkgdata; # Already done.
if ($opt{I}) {
- load_pkgdb_from_cache($opt{I});
+ load_pkgdata_from_cache($opt{I});
return;
}
- $pkgdb = PkgDb->new();
+ $pkgdata = PkgData->new();
my @categories = list_pkgsrc_categories($pkgsrcdir);
if ($opt{L}) {
@@ -1061,7 +1061,7 @@
if (!$opt{L}) {
my ($len);
- $_ = scalar $pkgdb->pkgvers_all . ' packages';
+ $_ = scalar $pkgdata->pkgvers_all . ' packages';
$len = @categories - length($_);
verbose("\b" x @categories, $_, ' ' x $len, "\b" x $len, "\n");
}
@@ -1070,7 +1070,7 @@
# Cross reference all depends
#
sub pkgsrc_check_depends() {
- foreach my $pkgver ($pkgdb->pkgvers_all) {
+ foreach my $pkgver ($pkgdata->pkgvers_all) {
my $depends = $pkgver->var('DEPENDS');
next unless defined $depends;
@@ -1234,7 +1234,7 @@
sort keys %unref_distfiles;
}
-sub store_pkgdb_in_cache($db, $fname) {
+sub store_pkgdata_in_cache($db, $fname) {
open(STORE, '>', $fname)
or die("Cannot save package data to $fname: $!\n");
foreach my $pkgver ($db->pkgvers_all) {
@@ -1308,7 +1308,7 @@
$pkg = canonicalize_pkgname($pkg);
my ($pkgs);
- if ($pkgs = $pkgdb->pkgs($pkg)) {
+ if ($pkgs = $pkgdata->pkgs($pkg)) {
my ($pkgver) = $pkgs->pkgver($ver);
if (!defined $pkgver) {
@@ -1446,7 +1446,7 @@
next;
}
- foreach my $pkgver ($pkgdb->pkgvers_by_pkgbase($1)) {
+ foreach my $pkgver ($pkgdata->pkgvers_by_pkgbase($1)) {
next if $pkgver->var('dir') =~ /-current/;
push @installed_pkgvers, $pkgver;
last;
@@ -1479,7 +1479,7 @@
sub list_broken_packages($pkgsrcdir) {
scan_pkgsrc_makefiles($pkgsrcdir);
- foreach my $pkgver ($pkgdb->pkgvers_all) {
+ foreach my $pkgver ($pkgdata->pkgvers_all) {
my $broken = $pkgver->var('BROKEN');
next unless $broken;
print $pkgver->pkgname . ": $broken\n";
@@ -1519,7 +1519,7 @@
}
scan_pkgsrc_makefiles($pkgsrcdir);
- foreach my $pkgver ($pkgdb->pkgvers_all) {
+ foreach my $pkgver ($pkgdata->pkgvers_all) {
my $pkgpath = $pkgver->var('dir');
if (!defined $in_subdir{$pkgpath}) {
print "$pkgpath: Not in SUBDIR\n";
@@ -1532,7 +1532,7 @@
scan_pkgsrc_makefiles($pkgsrcdir);
open(TABLE, '>', $tmpfile) or fail("Cannot write '$tmpfile': $!");
- foreach my $pkgver ($pkgdb->pkgvers_all) {
+ foreach my $pkgver ($pkgdata->pkgvers_all) {
printf TABLE "%s\t%s\t%s\n",
$pkgver->pkgbase,
$pkgver->var('dir'),
@@ -1554,7 +1554,7 @@
print map { "$_\n" } @warnings;
next unless $pkgname =~ /^([^*?[]+)-([\d*?[].*)/;
- foreach my $pkgver ($pkgdb->pkgvers_by_pkgbase($1)) {
+ foreach my $pkgver ($pkgdata->pkgvers_by_pkgbase($1)) {
next if $pkgver->var('dir') =~ /-current/;
push @update, $pkgver;
last;
@@ -1651,7 +1651,7 @@
if ($opt{E}) {
scan_pkgsrc_makefiles($pkgsrcdir);
- store_pkgdb_in_cache($pkgdb, $opt{E});
+ store_pkgdata_in_cache($pkgdata, $opt{E});
}
}
@@ -1659,7 +1659,7 @@
({
'opt' => \%opt,
'default_vars' => $default_vars,
- 'pkgdb' => $pkgdb,
+ 'pkgdata' => $pkgdata,
});
}
diff -r 9f04d2568322 -r 9c2b0723e970 pkgtools/lintpkgsrc/files/t/packages.t
--- a/pkgtools/lintpkgsrc/files/t/packages.t Tue Aug 16 20:28:41 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/packages.t Tue Aug 16 20:54:35 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: packages.t,v 1.15 2022/08/13 12:22:20 rillig Exp $
+# $NetBSD: packages.t,v 1.16 2022/08/16 20:54:35 rillig Exp $
#
# Tests for the internal package database, which stores the packages and their
# versions, and a few variables like DEPENDS and BROKEN.
@@ -38,66 +38,66 @@
ok(($pkgs->pkgvers_all)[1]->pkgname, 'base-1.0nb20');
}
-sub test_pkgdb() {
- my $pkgdb = PkgDb->new();
+sub test_pkgdata() {
+ my $pkgdata = PkgData->new();
- ok(scalar $pkgdb->pkgvers_all, 0);
- ok(join(', ', map { $_->pkgname } $pkgdb->pkgvers_all), '');
+ ok(scalar $pkgdata->pkgvers_all, 0);
+ ok(join(', ', map { $_->pkgname } $pkgdata->pkgvers_all), '');
- $pkgdb->add('base', '1.0');
+ $pkgdata->add('base', '1.0');
- ok(scalar $pkgdb->pkgvers_all, 1);
+ ok(scalar $pkgdata->pkgvers_all, 1);
- $pkgdb->add('other', '5.7');
+ $pkgdata->add('other', '5.7');
- ok(scalar $pkgdb->pkgvers_all, 2);
+ ok(scalar $pkgdata->pkgvers_all, 2);
- my $base_8_0 = $pkgdb->add('base', '8.0');
+ my $base_8_0 = $pkgdata->add('base', '8.0');
- ok(scalar $pkgdb->pkgvers_all, 3);
+ ok(scalar $pkgdata->pkgvers_all, 3);
ok($base_8_0->pkgname, 'base-8.0');
- my $actual = join(', ', map { $_->pkgname } $pkgdb->pkgvers_all);
+ my $actual = join(', ', map { $_->pkgname } $pkgdata->pkgvers_all);
ok($actual, 'base-8.0, base-1.0, other-5.7');
- $actual = join(', ', map { $_->pkgname } $pkgdb->pkgvers_by_pkgbase('base'));
+ $actual = join(', ', map { $_->pkgname } $pkgdata->pkgvers_by_pkgbase('base'));
ok($actual, 'base-8.0, base-1.0');
- $actual = join(', ', map { $_->pkgname } $pkgdb->pkgvers_by_pkgbase('unknown'));
+ $actual = join(', ', map { $_->pkgname } $pkgdata->pkgvers_by_pkgbase('unknown'));
ok($actual, '');
- ok($pkgdb->pkgver('base', '1.0')->pkgname, 'base-1.0');
- ok($pkgdb->pkgver('unknown', '1.0'), undef);
- ok($pkgdb->pkgver('base', '3.0'), undef);
+ ok($pkgdata->pkgver('base', '1.0')->pkgname, 'base-1.0');
+ ok($pkgdata->pkgver('unknown', '1.0'), undef);
+ ok($pkgdata->pkgver('base', '3.0'), undef);
- ok(join(', ', map { $_->pkgbase } $pkgdb->pkgs), 'base, other');
- ok($pkgdb->pkgs('base')->pkgbase, 'base');
- ok($pkgdb->pkgs('unknown'), undef);
+ ok(join(', ', map { $_->pkgbase } $pkgdata->pkgs), 'base, other');
+ ok($pkgdata->pkgs('base')->pkgbase, 'base');
+ ok($pkgdata->pkgs('unknown'), undef);
Home |
Main Index |
Thread Index |
Old Index