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: format code



details:   https://anonhg.NetBSD.org/pkgsrc/rev/809f087165bc
branches:  trunk
changeset: 382504:809f087165bc
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 30 06:21:17 2022 +0000

description:
lintpkgsrc: format code

No functional change.

diffstat:

 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  2858 +++++++++++++++---------------
 1 files changed, 1395 insertions(+), 1463 deletions(-)

diffs (truncated from 3328 to 300 lines):

diff -r fe610df48a5b -r 809f087165bc pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 01:22:38 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 06:21:17 2022 +0000
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.23 2022/07/29 19:00:36 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.24 2022/07/30 06:21:17 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -23,19 +23,19 @@
 use Cwd 'realpath', 'getcwd';
 
 # Buildtime configuration
-my $conf_make       = '@MAKE@';
-my $conf_pkgsrcdir  = '@PKGSRCDIR@';
-my $conf_prefix     = '@PREFIX@';
+my $conf_make = '@MAKE@';
+my $conf_pkgsrcdir = '@PKGSRCDIR@';
+my $conf_prefix = '@PREFIX@';
 my $conf_sysconfdir = '@PKG_SYSCONFDIR@';
 
 my (
-    $pkglist,                     # list of Pkg packages
-    $pkg_installver,              # installed version of pkg_install pseudo-pkg
-    $default_vars,                # Set for Makefiles, inc PACKAGES & PKGSRCDIR
-    %opt,                         # Command line options
-    @matched_prebuiltpackages,    # List of obsolete prebuilt package paths
-    @prebuilt_pkgdirs,            # Use to follow symlinks in prebuilt pkgdirs
-    %prebuilt_pkgdir_cache,       # To avoid symlink loops in prebuilt_pkgdirs
+    $pkglist,                  # list of Pkg packages
+    $pkg_installver,           # installed version of pkg_install pseudo-pkg
+    $default_vars,             # Set for Makefiles, inc PACKAGES & PKGSRCDIR
+    %opt,                      # Command line options
+    @matched_prebuiltpackages, # List of obsolete prebuilt package paths
+    @prebuilt_pkgdirs,         # Use to follow symlinks in prebuilt pkgdirs
+    %prebuilt_pkgdir_cache,    # To avoid symlink loops in prebuilt_pkgdirs
 );
 
 sub usage_and_exit();
@@ -45,33 +45,28 @@
 sub parse_makefile_pkgsrc($);
 
 $ENV{PATH} .=
-  ":/bin:/usr/bin:/sbin:/usr/sbin:${conf_prefix}/sbin:${conf_prefix}/bin";
+    ":/bin:/usr/bin:/sbin:/usr/sbin:${conf_prefix}/sbin:${conf_prefix}/bin";
 
 if (
-       !getopts( 'BDE:I:K:LM:OP:RSVdg:himopruyz', \%opt )
-    || $opt{h}
-    || !(
-           defined $opt{d}
-        || defined $opt{g}
-        || defined $opt{i}
-        || defined $opt{m}
-        || defined $opt{o}
-        || defined $opt{p}
-        || defined $opt{r}
-        || defined $opt{u}
-        || defined $opt{B}
-        || defined $opt{D}
-        || defined $opt{R}
-        || defined $opt{O}
-        || defined $opt{S}
-        || defined $opt{E}
-        || defined $opt{y}
-        || defined $opt{z}
-    )
-  )
-{
-
-    usage_and_exit();
+    !getopts('BDE:I:K:LM:OP:RSVdg:himopruyz', \%opt)
+       || $opt{h}
+       || !(defined $opt{d}
+       || defined $opt{g}
+       || defined $opt{i}
+       || defined $opt{m}
+       || defined $opt{o}
+       || defined $opt{p}
+       || defined $opt{r}
+       || defined $opt{u}
+       || defined $opt{B}
+       || defined $opt{D}
+       || defined $opt{R}
+       || defined $opt{O}
+       || defined $opt{S}
+       || defined $opt{E}
+       || defined $opt{y}
+       || defined $opt{z})) {
+       usage_and_exit();
 }
 $| = 1;
 
@@ -79,630 +74,598 @@
 # gets removed in the final evaluation
 my $magic_undefined = 'M_a_G_i_C_uNdEfInEd';
 
-get_default_makefile_vars();    # $default_vars
+get_default_makefile_vars(); # $default_vars
 
-if ( $opt{D} && @ARGV ) {
-    foreach my $file (@ARGV) {
-        if ( -d $file ) {
-            $file .= "/Makefile";
-        }
-        if ( !-f $file ) {
-            fail("No such file: $file");
-        }
-        my ( $pkgname, $vars ) = parse_makefile_pkgsrc($file);
-        $pkgname ||= 'uNDEFINEd';
-        print "$file -> $pkgname\n";
-        foreach my $varname ( sort keys %{$vars} ) {
-            print "\t$varname = $vars->{$varname}\n";
-        }
+if ($opt{D} && @ARGV) {
+       foreach my $file (@ARGV) {
+               if (-d $file) {
+                       $file .= "/Makefile";
+               }
+               if (!-f $file) {
+                       fail("No such file: $file");
+               }
+               my ($pkgname, $vars) = parse_makefile_pkgsrc($file);
+               $pkgname ||= 'uNDEFINEd';
+               print "$file -> $pkgname\n";
+               foreach my $varname (sort keys %{$vars}) {
+                       print "\t$varname = $vars->{$varname}\n";
+               }
 
-        #if ($opt{d}) {
-        #      pkgsrc_check_depends();
-        #}
-    }
-    exit;
+               #if ($opt{d}) {
+               #       pkgsrc_check_depends();
+               #}
+       }
+       exit;
 }
 
 sub main() {
-    my ( $pkgsrcdir, $pkgdistdir );
-
-    $pkgsrcdir  = $default_vars->{PKGSRCDIR};
-    $pkgdistdir = $default_vars->{DISTDIR};
+       my ($pkgsrcdir, $pkgdistdir);
 
-    if ( $opt{r} && !$opt{o} && !$opt{m} && !$opt{p} ) {
-        $opt{o} = $opt{m} = $opt{p} = 1;
-    }
-    if ( $opt{o} || $opt{m} ) {
-        my (@baddist);
+       $pkgsrcdir = $default_vars->{PKGSRCDIR};
+       $pkgdistdir = $default_vars->{DISTDIR};
 
-        @baddist =
-          scan_pkgsrc_distfiles_vs_distinfo( $pkgsrcdir, $pkgdistdir, $opt{o},
-            $opt{m} );
-        if ( $opt{r} ) {
-            verbose("Unlinking 'bad' distfiles\n");
-            foreach my $distfile (@baddist) {
-                unlink("$pkgdistdir/$distfile");
-            }
-        }
-    }
+       if ($opt{r} && !$opt{o} && !$opt{m} && !$opt{p}) {
+               $opt{o} = $opt{m} = $opt{p} = 1;
+       }
+       if ($opt{o} || $opt{m}) {
+               my (@baddist);
 
-    # Remove all distfiles that are / are not part of an installed package
-    if ($opt{y} || $opt{z})
-       {
-       my(@pkgs, @installed, %distfiles, @pkgdistfiles, @dldistfiles);
-       my(@tmpdistfiles, @orphan, $found, @parent);
-
-       @pkgs = list_installed_packages();
-       scan_pkgsrc_makefiles($pkgsrcdir);
+               @baddist = scan_pkgsrc_distfiles_vs_distinfo(
+                   $pkgsrcdir, $pkgdistdir, $opt{o}, $opt{m});
+               if ($opt{r}) {
+                       verbose("Unlinking 'bad' distfiles\n");
+                       foreach my $distfile (@baddist) {
+                               unlink("$pkgdistdir/$distfile");
+                       }
+               }
+       }
 
-       # list the installed packages and the directory they live in
-       foreach my $pkgname (sort @pkgs)
-           {
-           if ($pkgname =~ /^([^*?[]+)-([\d*?[].*)/)
-               {
-               foreach my $pkgver ($pkglist->pkgver($1))
-                   {
-                   $pkgver->var('dir') =~ /-current/ && next;
-                   push(@installed, $pkgver);
-                   last;
-                   }
-               }
-           }
+       # Remove all distfiles that are / are not part of an installed package
+       if ($opt{y} || $opt{z}) {
+               my (@pkgs, @installed, %distfiles, @pkgdistfiles, @dldistfiles);
+               my (@tmpdistfiles, @orphan, $found, @parent);
+
+               @pkgs = list_installed_packages();
+               scan_pkgsrc_makefiles($pkgsrcdir);
 
-       # distfiles belonging to the currently installed packages
-       foreach my $pkgver (sort @installed)
-           {
-           if (open(DISTINFO, "$pkgsrcdir/" .$pkgver->var('dir'). "/distinfo"))
-               {
-               while( <DISTINFO> )
-                   {
-                   if (m/^(\w+) ?\(([^\)]+)\) = (\S+)/)
-                       {
-                       my($dn);
-                       if ($2 =~ /^patch-[\w.+\-]+$/)
-                           { next; }
-                       $dn = $2;
-                       # Strip leading ./ which sometimes gets added
-                       # because of DISTSUBDIR=.
-                       $dn =~ s/^(\.\/)*//;
-                       if (!defined $distfiles{$dn})
-                           {
-                           $distfiles{$dn}{name} = $dn;
-                           push (@pkgdistfiles, $dn);
-                           }
+               # list the installed packages and the directory they live in
+               foreach my $pkgname (sort @pkgs) {
+                       if ($pkgname =~ /^([^*?[]+)-([\d*?[].*)/) {
+                               foreach my $pkgver ($pkglist->pkgver($1)) {
+                                       $pkgver->var('dir') =~ /-current/ && next;
+                                       push(@installed, $pkgver);
+                                       last;
+                               }
                        }
-                   }
-               close(DISTINFO);
                }
-           }
 
-       # distfiles downloaded on the current system
-       @tmpdistfiles = listdir("$pkgdistdir", undef);
-       foreach my $tmppkg (@tmpdistfiles)
-           {
-           if ($tmppkg ne "pkg-vulnerabilities")
-              { push (@dldistfiles, $tmppkg); }
-           }
-
-       # sort the two arrays to make searching a bit faster
-       @dldistfiles = sort { $a cmp $b } @dldistfiles;
-       @pkgdistfiles = sort { $a cmp $b } @pkgdistfiles;
-
-       if ($opt{y})
-           {
-           # looking for files that are downloaded on the current system
-           # but do not belong to any currently installed package i.e. orphaned
-           $found = 0;
-           foreach my $dldf (@dldistfiles)
-               {
-                foreach my $pkgdf (@pkgdistfiles)
-                   {
-                    if ($dldf eq $pkgdf)
-                       { $found = 1; }
-                   }
-                   if ($found != 1)
-                       {
-                       push (@orphan, $dldf);
-                       print "Orphaned file: $dldf\n";
+               # distfiles belonging to the currently installed packages
+               foreach my $pkgver (sort @installed) {
+                       if (open(DISTINFO, "$pkgsrcdir/" . $pkgver->var('dir') . "/distinfo")) {
+                               while (<DISTINFO>) {
+                                       if (m/^(\w+) ?\(([^\)]+)\) = (\S+)/) {
+                                               my ($dn);
+                                               if ($2 =~ /^patch-[\w.+\-]+$/) { next; }
+                                               $dn = $2;
+                                               # Strip leading ./ which sometimes gets added
+                                               # because of DISTSUBDIR=.
+                                               $dn =~ s/^(\.\/)*//;
+                                               if (!defined $distfiles{$dn}) {
+                                                       $distfiles{$dn}{name} = $dn;
+                                                       push(@pkgdistfiles, $dn);
+                                               }
+                                       }
+                               }
+                               close(DISTINFO);
                        }
-                   $found = 0;
                }
 
-       if ($opt{r})
-           {



Home | Main Index | Thread Index | Old Index