pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files pkglint: cleanup: group clas...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/42cbc1bb5ecd
branches:  trunk
changeset: 382532:42cbc1bb5ecd
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 30 15:11:26 2022 +0000

description:
pkglint: cleanup: group classes from small to big

No functional change.

diffstat:

 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  246 ++++++++++++++++----------------
 1 files changed, 123 insertions(+), 123 deletions(-)

diffs (269 lines):

diff -r 0d5682233805 -r 42cbc1bb5ecd pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 14:55:51 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 15:11:26 2022 +0000
@@ -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,6 +22,128 @@
 use IPC::Open3;
 use Cwd 'realpath', 'getcwd';
 
+# PkgVer is a unique package + version.
+#
+package PkgVer;
+
+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($) {
+       my $self = shift;
+
+       $self->{_pkg};
+}
+
+sub var($$$) {
+       my $self = shift;
+       my ($key, $val) = @_;
+
+       (defined $val)
+           ? ($self->{$key} = $val)
+           : $self->{$key};
+}
+
+sub ver($) {
+       my $self = shift;
+
+       $self->{_ver};
+}
+
+sub vars($) {
+       my $self = shift;
+
+       grep(!/^_(pkg|ver)$/, keys %{$self});
+}
+
+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);
+       }
+}
+
+# Pkgs is all versions of a given package (eg: apache-1.x and apache-2.x)
+#
+package Pkgs;
+
+sub add($@) {
+       my $self = shift;
+
+       $self->{_pkgver}{$_[1]} = new PkgVer @_;
+}
+
+sub new($@) {
+       my $class = shift;
+       my $self = {};
+
+       bless $self, $class;
+       $self->{_pkg} = $_[0];
+       return $self;
+}
+
+sub versions($) {
+       my $self = shift;
+
+       return sort { $b cmp $a } keys %{$self->{_pkgver}};
+}
+
+sub pkg($) {
+       my $self = shift;
+       $self->{_pkg};
+}
+
+sub pkgver($@) {
+       my $self = shift;
+
+       if (@_) {
+               if ($self->{_pkgver}{$_[0]}) {
+                       return ($self->{_pkgver}{$_[0]});
+               }
+               return;
+       }
+       return sort { $b->ver() cmp $a->ver() } values %{$self->{_pkgver}};
+}
+
+sub latestver($) {
+       my $self = shift;
+
+       ($self->pkgver())[0];
+}
+
+sub store($) {
+       my $self = shift;
+
+       my $pkgvers = $self->{_pkgver};
+       foreach my $pkgver (sort keys %$pkgvers) {
+               $pkgvers->{$pkgver}->store();
+       }
+}
+
 # PkgList is the master list of all packages in pkgsrc.
 #
 package PkgList;
@@ -85,128 +207,6 @@
        }
 }
 
-# Pkgs is all versions of a given package (eg: apache-1.x and apache-2.x)
-#
-package Pkgs;
-
-sub add($@) {
-       my $self = shift;
-
-       $self->{_pkgver}{$_[1]} = new PkgVer @_;
-}
-
-sub new($@) {
-       my $class = shift;
-       my $self = {};
-
-       bless $self, $class;
-       $self->{_pkg} = $_[0];
-       return $self;
-}
-
-sub versions($) {
-       my $self = shift;
-
-       return sort { $b cmp $a } keys %{$self->{_pkgver}};
-}
-
-sub pkg($) {
-       my $self = shift;
-       $self->{_pkg};
-}
-
-sub pkgver($@) {
-       my $self = shift;
-
-       if (@_) {
-               if ($self->{_pkgver}{$_[0]}) {
-                       return ($self->{_pkgver}{$_[0]});
-               }
-               return;
-       }
-       return sort { $b->ver() cmp $a->ver() } values %{$self->{_pkgver}};
-}
-
-sub latestver($) {
-       my $self = shift;
-
-       ($self->pkgver())[0];
-}
-
-sub store($) {
-       my $self = shift;
-
-       my $pkgvers = $self->{_pkgver};
-       foreach my $pkgver (sort keys %$pkgvers) {
-               $pkgvers->{$pkgver}->store();
-       }
-}
-
-# PkgVer is a unique package+version
-#
-package PkgVer;
-
-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($) {
-       my $self = shift;
-
-       $self->{_pkg};
-}
-
-sub var($$$) {
-       my $self = shift;
-       my ($key, $val) = @_;
-
-       (defined $val)
-           ? ($self->{$key} = $val)
-           : $self->{$key};
-}
-
-sub ver($) {
-       my $self = shift;
-
-       $self->{_ver};
-}
-
-sub vars($) {
-       my $self = shift;
-
-       grep(!/^_(pkg|ver)$/, keys %{$self});
-}
-
-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);
-       }
-}
-
 package main;
 
 # Buildtime configuration



Home | Main Index | Thread Index | Old Index