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:           Tue Aug 16 20:54:35 UTC 2022

Modified Files:
        pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl
        pkgsrc/pkgtools/lintpkgsrc/files/t: packages.t

Log Message:
lintpkgsrc: cleanup: rename PkgDb to PkgData

The previous name could be confused with the pkgdb directory that holds
information about the currently installed packages.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r1.15 -r1.16 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.106 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.107
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.106        Tue Aug 16 20:28:41 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Tue Aug 16 20:54:35 2022
@@ -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 @@ sub pkgver($self, $pkgversion) {
        $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_prefix = '@PREFIX@';
 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 @@ sub invalid_version($pkgmatch) {
                # 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 @@ sub package_globmatch($pkgmatch) {
        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 @@ sub package_globmatch($pkgmatch) {
                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 @@ sub package_globmatch($pkgmatch) {
                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 @@ sub package_globmatch($pkgmatch) {
                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 @@ sub parse_makefile_pkgsrc($file) {
                        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 @@ sub chdir_or_fail($dir) {
        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 load_pkgdb_from_cache($fname) {
 #
 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 @@ sub scan_pkgsrc_makefiles($pkgsrcdir) {
        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 @@ sub scan_pkgsrc_makefiles($pkgsrcdir) {
 # 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 @@ sub check_pkgsrc_distfiles_vs_distinfo($
        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 @@ sub check_prebuilt_packages() {
                $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 @@ sub remove_distfiles($pkgsrcdir, $pkgdis
                        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 remove_distfiles($pkgsrcdir, $pkgdis
 
 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 @@ sub list_packages_not_in_SUBDIR($pkgsrcd
        }
 
        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 @@ sub generate_map_file($pkgsrcdir, $fname
 
        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 @@ sub check_outdated_installed_packages($p
                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 @@ sub main() {
 
        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 @@ sub export_for_test() {
        ({
            'opt'          => \%opt,
            'default_vars' => $default_vars,
-           'pkgdb'        => $pkgdb,
+           'pkgdata'      => $pkgdata,
        });
 }
 

Index: pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.15 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.16
--- pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.15  Sat Aug 13 12:22:20 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t       Tue Aug 16 20:54:35 2022
@@ -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 @@ sub test_pkgs() {
        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(join(', ', map { $_->pkgbase } $pkgdb->pkgs), 'base, other');
-       ok($pkgdb->pkgs('base')->pkgbase, 'base');
-       ok($pkgdb->pkgs('unknown'), 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 } $pkgdata->pkgs), 'base, other');
+       ok($pkgdata->pkgs('base')->pkgbase, 'base');
+       ok($pkgdata->pkgs('unknown'), undef);
 }
 
 sub test_package_variables() {
-       my $pkgdb = PkgDb->new();
-       my $pkgbase_1_0 = $pkgdb->add('pkgbase', '1.0');
+       my $pkgdata = PkgData->new();
+       my $pkgbase_1_0 = $pkgdata->add('pkgbase', '1.0');
 
        $pkgbase_1_0->var('NAME', 'value');
 
        ok($pkgbase_1_0->var('NAME'), 'value');
        ok($pkgbase_1_0->var('undefined'), undef);
 
-       my $pkgbase_2_0 = $pkgdb->add('pkgbase', '2.0');
-       my $pkgbase_1_5 = $pkgdb->add('pkgbase', '1.5');
-       my $pkgbase_1_10 = $pkgdb->add('pkgbase', '1.10');
+       my $pkgbase_2_0 = $pkgdata->add('pkgbase', '2.0');
+       my $pkgbase_1_5 = $pkgdata->add('pkgbase', '1.5');
+       my $pkgbase_1_10 = $pkgdata->add('pkgbase', '1.10');
 
        $pkgbase_2_0->var('COMMENT', 'Version 2 of the package');
 
-       ok($pkgdb->pkgs('unknown-pkgbase'), undef);
+       ok($pkgdata->pkgs('unknown-pkgbase'), undef);
 
        # The versions are sorted in decreasing alphabetical order.
-       my $versions = join(', ', $pkgdb->pkgs('pkgbase')->versions());
+       my $versions = join(', ', $pkgdata->pkgs('pkgbase')->versions());
        ok($versions, '2.0, 1.5, 1.10, 1.0');
 
        # The versioned packages are sorted in decreasing alphabetical order.
-       my @pkgvers = $pkgdb->pkgvers_by_pkgbase('pkgbase');
+       my @pkgvers = $pkgdata->pkgvers_by_pkgbase('pkgbase');
        ok(join(', ', map { $_->pkgversion } @pkgvers), '2.0, 1.5, 1.10, 1.0');
        ok($pkgvers[0], $pkgbase_2_0);
        ok($pkgvers[3], $pkgbase_1_0);
@@ -105,11 +105,11 @@ sub test_package_variables() {
 
 # Demonstrate how the package data is stored in the cache file.
 sub test_store_order() {
-       my $pkgdb = PkgDb->new();
+       my $pkgdata = PkgData->new();
 
-       my $pkgbase_1_0 = $pkgdb->add('pkgbase', '1.0');
-       my $pkgbase_1_3nb4 = $pkgdb->add('pkgbase', '1.3nb4');
-       my $pkgbase_1_15 = $pkgdb->add('pkgbase', '1.15');
+       my $pkgbase_1_0 = $pkgdata->add('pkgbase', '1.0');
+       my $pkgbase_1_3nb4 = $pkgdata->add('pkgbase', '1.3nb4');
+       my $pkgbase_1_15 = $pkgdata->add('pkgbase', '1.15');
 
        # Ensure that variables are stored in alphabetical order.
        $pkgbase_1_0->var('COMMENT', 'Version 1');
@@ -120,7 +120,7 @@ sub test_store_order() {
        $pkgbase_1_15->var('COMMENT', 'Version 1.15');
 
        my $tmpfile = File::Temp->new();
-       store_pkgdb_in_cache($pkgdb, $tmpfile->filename);
+       store_pkgdata_in_cache($pkgdata, $tmpfile->filename);
        my $stored = read_file($tmpfile->filename);
 
        # XXX: 1.3nb4 should be sorted before 1.15.
@@ -139,6 +139,6 @@ sub test_store_order() {
 
 test_pkgver();
 test_pkgs();
-test_pkgdb();
+test_pkgdata();
 test_package_variables();
 test_store_order();



Home | Main Index | Thread Index | Old Index