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:           Sat Jul 30 15:11:26 UTC 2022

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

Log Message:
pkglint: cleanup: group classes from small to big

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl

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.37 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.38
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.37 Sat Jul 30 11:33:23 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Sat Jul 30 15:11:26 2022
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.37 2022/07/30 11:33:23 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.38 2022/07/30 15:11:26 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -22,66 +22,68 @@ use File::Basename;
 use IPC::Open3;
 use Cwd 'realpath', 'getcwd';
 
-# PkgList is the master list of all packages in pkgsrc.
+# PkgVer is a unique package + version.
 #
-package PkgList;
-
-sub add($@) {
-       my $self = shift;
-
-       if (!$self->pkgs($_[0])) {
-               $self->{_pkgs}{ $_[0] } = new Pkgs $_[0];
-       }
-       $self->pkgs($_[0])->add(@_);
-}
+package PkgVer;
 
-sub new($) {
+sub new($$$) {
        my $class = shift;
        my $self = {};
+
        bless $self, $class;
+       $self->{_pkg} = $_[0];
+       $self->{_ver} = $_[1];
        return $self;
 }
 
-sub numpkgver($) {
+sub pkgname($) {
        my $self = shift;
-       scalar($self->pkgver);
+
+       $self->pkg . '-' . $self->ver;
 }
 
-sub pkgver($@) {
+sub pkg($) {
        my $self = shift;
 
-       if (@_ == 0) {
-               my (@list);
-               foreach my $pkg ($self->pkgs) {
-                       push(@list, $pkg->pkgver);
-               }
-               return (@list);
-       }
+       $self->{_pkg};
+}
 
-       if (defined $self->{_pkgs}{$_[0]}) {
-               return (@_ > 1)
-                   ? $self->{_pkgs}{$_[0]}->pkgver($_[1])
-                   : $self->{_pkgs}{$_[0]}->pkgver();
-       }
-       return;
+sub var($$$) {
+       my $self = shift;
+       my ($key, $val) = @_;
+
+       (defined $val)
+           ? ($self->{$key} = $val)
+           : $self->{$key};
 }
 
-sub pkgs($@) {
+sub ver($) {
        my $self = shift;
 
-       if (@_) {
-               return $self->{_pkgs}{$_[0]};
-       } else {
-               return (sort { $a->pkg cmp $b->pkg } values %{$self->{_pkgs}});
-       }
+       $self->{_ver};
+}
+
+sub vars($) {
+       my $self = shift;
+
+       grep(!/^_(pkg|ver)$/, keys %{$self});
 }
 
 sub store($) {
        my $self = shift;
 
-       my $pkgs = $self->{_pkgs};
-       foreach my $pkg (sort keys %$pkgs) {
-               $pkgs->{$pkg}->store();
+       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";
+       printf("package\t%s\t%s\n", $name, $ver);
+
+       foreach my $varname (sort $self->vars) {
+               my $value = $self->{$varname};
+               $varname =~ /\s/ and die "cannot store variable name '$varname'\n";
+               $value =~ /\n/ and die "cannot store variable value '$value'\n";
+               printf("var\t%s\t%s\n", $varname, $value);
        }
 }
 
@@ -142,68 +144,66 @@ sub store($) {
        }
 }
 
-# PkgVer is a unique package+version
+# PkgList is the master list of all packages in pkgsrc.
 #
-package PkgVer;
+package PkgList;
 
-sub new($$$) {
+sub add($@) {
+       my $self = shift;
+
+       if (!$self->pkgs($_[0])) {
+               $self->{_pkgs}{ $_[0] } = new Pkgs $_[0];
+       }
+       $self->pkgs($_[0])->add(@_);
+}
+
+sub new($) {
        my $class = shift;
        my $self = {};
-
        bless $self, $class;
-       $self->{_pkg} = $_[0];
-       $self->{_ver} = $_[1];
        return $self;
 }
 
-sub pkgname($) {
-       my $self = shift;
-
-       $self->pkg . '-' . $self->ver;
-}
-
-sub pkg($) {
+sub numpkgver($) {
        my $self = shift;
-
-       $self->{_pkg};
+       scalar($self->pkgver);
 }
 
-sub var($$$) {
+sub pkgver($@) {
        my $self = shift;
-       my ($key, $val) = @_;
 
-       (defined $val)
-           ? ($self->{$key} = $val)
-           : $self->{$key};
-}
-
-sub ver($) {
-       my $self = shift;
+       if (@_ == 0) {
+               my (@list);
+               foreach my $pkg ($self->pkgs) {
+                       push(@list, $pkg->pkgver);
+               }
+               return (@list);
+       }
 
-       $self->{_ver};
+       if (defined $self->{_pkgs}{$_[0]}) {
+               return (@_ > 1)
+                   ? $self->{_pkgs}{$_[0]}->pkgver($_[1])
+                   : $self->{_pkgs}{$_[0]}->pkgver();
+       }
+       return;
 }
 
-sub vars($) {
+sub pkgs($@) {
        my $self = shift;
 
-       grep(!/^_(pkg|ver)$/, keys %{$self});
+       if (@_) {
+               return $self->{_pkgs}{$_[0]};
+       } else {
+               return (sort { $a->pkg cmp $b->pkg } values %{$self->{_pkgs}});
+       }
 }
 
 sub store($) {
        my $self = shift;
 
-       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";
-       printf("package\t%s\t%s\n", $name, $ver);
-
-       foreach my $varname (sort $self->vars) {
-               my $value = $self->{$varname};
-               $varname =~ /\s/ and die "cannot store variable name '$varname'\n";
-               $value =~ /\n/ and die "cannot store variable value '$value'\n";
-               printf("var\t%s\t%s\n", $varname, $value);
+       my $pkgs = $self->{_pkgs};
+       foreach my $pkg (sort keys %$pkgs) {
+               $pkgs->{$pkg}->store();
        }
 }
 



Home | Main Index | Thread Index | Old Index