pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkglint4



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sun Oct  6 10:33:34 UTC 2019

Modified Files:
        pkgsrc/pkgtools/pkglint4: Makefile
        pkgsrc/pkgtools/pkglint4/files: pkglint.pl pkglint.t
        pkgsrc/pkgtools/pkglint4/files/PkgLint: Patches.pm Shell.pm
Removed Files:
        pkgsrc/pkgtools/pkglint4: README TODO
        pkgsrc/pkgtools/pkglint4/files/doc: Makefile chap.code.xml
            chap.defs.xml chap.design.xml chap.future.xml chap.intro.xml
            chap.statemachines.xml chap.types.xml pkglint.xml
            statemachine.patch.dia statemachine.shellcmd.dia stylesheet.xsl

Log Message:
pkgtools/pkglint4: update to 4.193.0, remove check for absolute paths

The check for absolute paths is not necessary since it doesn't provide
any benefit. It had been removed from pkgtools/pkglint already.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 pkgsrc/pkgtools/pkglint4/Makefile
cvs rdiff -u -r1.1 -r0 pkgsrc/pkgtools/pkglint4/README \
    pkgsrc/pkgtools/pkglint4/TODO
cvs rdiff -u -r1.6 -r1.7 pkgsrc/pkgtools/pkglint4/files/pkglint.pl
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/pkglint4/files/pkglint.t
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm \
    pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm
cvs rdiff -u -r1.1 -r0 pkgsrc/pkgtools/pkglint4/files/doc/Makefile \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.code.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.defs.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.future.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.intro.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.statemachines.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/chap.types.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/pkglint.xml \
    pkgsrc/pkgtools/pkglint4/files/doc/statemachine.patch.dia \
    pkgsrc/pkgtools/pkglint4/files/doc/statemachine.shellcmd.dia \
    pkgsrc/pkgtools/pkglint4/files/doc/stylesheet.xsl
cvs rdiff -u -r1.2 -r0 pkgsrc/pkgtools/pkglint4/files/doc/chap.design.xml

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint4/Makefile
diff -u pkgsrc/pkgtools/pkglint4/Makefile:1.12 pkgsrc/pkgtools/pkglint4/Makefile:1.13
--- pkgsrc/pkgtools/pkglint4/Makefile:1.12      Sun Aug 11 13:22:36 2019
+++ pkgsrc/pkgtools/pkglint4/Makefile   Sun Oct  6 10:33:34 2019
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.12 2019/08/11 13:22:36 wiz Exp $
+# $NetBSD: Makefile,v 1.13 2019/10/06 10:33:34 rillig Exp $
 
-PKGNAME=       pkglint4-4.164
-PKGREVISION=   2
+PKGNAME=       pkglint4-4.193.0
 CATEGORIES=    pkgtools
 
 OWNER=         rillig%NetBSD.org@localhost
@@ -36,7 +35,7 @@ SUBST_SED.pkglint+=   -e s\|@PKGSRCDIR@\|/
 .else
 SUBST_VARS.pkglint=    PKGSRCDIR
 .endif
-SUBST_VARS.pkglint=    PREFIX
+SUBST_VARS.pkglint+=   PREFIX
 SUBST_SED.pkglint+=    -e s\|@DISTVER@\|${PKGNAME:S/pkglint-//}\|g
 SUBST_VARS.pkglint+=   MAKE
 SUBST_SED.pkglint+=    -e s\|@PERL@\|${PERL5:Q}\|g
@@ -57,7 +56,7 @@ do-build:
                && mv pkglint.pl.inlined pkglint.pl
 
 do-test:
-       cd ${WRKSRC} && prove pkglint.t
+       cd ${WRKSRC} && prove -v -I. pkglint.t
 
 do-install:
        ${INSTALL_SCRIPT} ${WRKSRC}/pkglint.pl ${DESTDIR}${PREFIX}/bin/pkglint

Index: pkgsrc/pkgtools/pkglint4/files/pkglint.pl
diff -u pkgsrc/pkgtools/pkglint4/files/pkglint.pl:1.6 pkgsrc/pkgtools/pkglint4/files/pkglint.pl:1.7
--- pkgsrc/pkgtools/pkglint4/files/pkglint.pl:1.6       Sun Oct  8 23:25:06 2017
+++ pkgsrc/pkgtools/pkglint4/files/pkglint.pl   Sun Oct  6 10:33:34 2019
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.6 2017/10/08 23:25:06 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.7 2019/10/06 10:33:34 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2247,36 +2247,6 @@ sub warn_about_PLIST_imake_mannewsuffix(
 # Subroutines to check part of a single line.
 #
 
-sub checkword_absolute_pathname($$) {
-       my ($line, $word) = @_;
-
-       $opt_debug_trace and $line->log_debug("checkword_absolute_pathname(\"${word}\")");
-
-       if ($word =~ m"^/dev/(?:null|tty|zero)$") {
-               # These are defined by POSIX.
-
-       } elsif ($word eq "/bin/sh") {
-               # This is usually correct, although on Solaris, it's pretty
-               # feature-crippled.
-
-       } elsif ($word !~ m"/(?:[a-z]|\$[({])") {
-               # Assume that all pathnames start with a lowercase letter.
-
-       } else {
-               $line->log_warning("Found absolute pathname: ${word}");
-               $line->explain_warning(
-"Absolute pathnames are often an indicator for unportable code. As",
-"pkgsrc aims to be a portable system, absolute pathnames should be",
-"avoided whenever possible.",
-"",
-"A special variable in this context is \${DESTDIR}, which is used in GNU",
-"projects to specify a different directory for installation than what",
-"the programs see later when they are executed. Usually it is empty, so",
-"if anything after that variable starts with a slash, it is considered",
-"an absolute pathname.");
-       }
-}
-
 sub check_unused_licenses() {
 
        for my $licensefile (glob("${cwd_pkgsrcdir}/licenses/*")) {
@@ -2397,31 +2367,6 @@ sub checkline_rcsid($$) {
        checkline_rcsid_regex($line, quotemeta($prefix), $prefix);
 }
 
-sub checkline_mk_absolute_pathname($$) {
-       my ($line, $text) = @_;
-       my $abspath;
-
-       $opt_debug_trace and $line->log_debug("checkline_mk_absolute_pathname(${text})");
-
-       # In the GNU coding standards, DESTDIR is defined as a (usually
-       # empty) prefix that can be used to install files to a different
-       # location from what they have been built for. Therefore
-       # everything following it is considered an absolute pathname.
-       # Another commonly used context is in assignments like
-       # "bindir=/bin".
-       if ($text =~ m"(?:^|\$\{DESTDIR\}|\$\(DESTDIR\)|[\w_]+\s*=\s*)(/(?:[^\"'\`\s]|\"[^\"*]\"|'[^']*'|\`[^\`]*\`)*)") {
-               my $path = $1;
-
-               if ($path =~ m"^/\w") {
-                       $abspath = $path;
-               }
-       }
-
-       if (defined($abspath)) {
-               checkword_absolute_pathname($line, $abspath);
-       }
-}
-
 sub checkline_relative_path($$$) {
        my ($line, $path, $must_exist) = @_;
        my ($res_path);
@@ -3242,14 +3187,12 @@ sub checkline_mk_vartype_basic($$$$$$$$)
                        if ($value_novar !~ m"^[#\-0-9A-Za-z._~+%*?/\[\]]*$") {
                                $line->log_warning("\"${value}\" is not a valid pathname mask.");
                        }
-                       checkline_mk_absolute_pathname($line, $value);
                },
 
                Pathname => sub {
                        if ($value_novar !~ m"^[#\-0-9A-Za-z._~+%/]*$") {
                                $line->log_warning("\"${value}\" is not a valid pathname.");
                        }
-                       checkline_mk_absolute_pathname($line, $value);
                },
 
                Perl5Packlist => sub {

Index: pkgsrc/pkgtools/pkglint4/files/pkglint.t
diff -u pkgsrc/pkgtools/pkglint4/files/pkglint.t:1.2 pkgsrc/pkgtools/pkglint4/files/pkglint.t:1.3
--- pkgsrc/pkgtools/pkglint4/files/pkglint.t:1.2        Mon Oct  2 14:41:21 2017
+++ pkgsrc/pkgtools/pkglint4/files/pkglint.t    Sun Oct  6 10:33:34 2019
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.t,v 1.2 2017/10/02 14:41:21 wiz Exp $
+# $NetBSD: pkglint.t,v 1.3 2019/10/06 10:33:34 rillig Exp $
 #
 
 require 'pkglint.pl';                  # so we can test its internals
@@ -58,8 +58,8 @@ sub test_program {
        if (defined $exitcode) {
                is($ret, $exitcode, qq{exits $exitcode});
        }
-       like($stdout, qr/$stdout_re/sm, qq{stdout matches $stdout_re});
-       like($stderr, qr/$stderr_re/sm, qq{stderr matches $stderr_re});
+       like($stdout, qr/$stdout_re/sm, qq{stdout $stdout matches $stdout_re});
+       like($stderr, qr/$stderr_re/sm, qq{stderr $stderr matches $stderr_re});
 
        # return @results;
 }
@@ -130,40 +130,40 @@ sub test_pkglint_main {
        @ARGV = ('-h');
        test_unit($unit, undef, 0, '^usage: pkglint ', '^$');
 
-       @ARGV = ('..');
+       @ARGV = ('@PKGSRCDIR@/pkgtools/pkglint4');
        test_unit($unit, undef, 0, '^Looks fine', '^$');
 
        @ARGV = ('.');
-       test_unit($unit, undef, 1, '^ERROR:.+how to check', '^$');
+       test_unit($unit, undef, 1, '^ERROR:.+outside a pkgsrc tree', '^$');
 
        @ARGV = ();
-       test_unit($unit, undef, 1, '^ERROR:.+how to check', '^$');
+       test_unit($unit, undef, 1, '^ERROR:.+outside a pkgsrc tree', '^$');
 
        @ARGV = ('/does/not/exist');
        test_unit($unit, undef, 1, '^ERROR:.+not exist', '^$');
 
        @ARGV = ($ENV{HOME});
-       test_unit($unit, undef, 1, '^ERROR:.+outside a pkgsrc', '^$');
+       test_unit($unit, undef, 1, '^ERROR:.+outside a pkgsrc tree', '^$');
 }
 
 sub test_lint_some_reference_packages {
        my %reference_packages = (
                'devel/syncdir' => {
                        stdout_re => <<EOT,
-^ERROR: .*Makefile: Each package must define its LICENSE\.
-ERROR: .*patches/patch-aa:[0-9]+: Comment expected\.
-2 errors and 0 warnings found\..*\$
+Looks fine\..*\$
 EOT
                        stderr_re => undef,
-                       exitcode => 1,
+                       exitcode => 0,
                },
                'mail/qmail' => {
                        stdout_re => <<EOT,
-^WARN: .*Makefile:[0-9]+: USERGROUP_PHASE is defined but not used\. Spelling mistake\\?
-0 errors and 1 warnings found\..*\$
+^WARN: .*Makefile:[0-9]+: QMAILPATCHES is defined but not used\..*
+.*
+ERROR: .*/options.mk:\\d+: Unknown dependency pattern.*
+.*\$
 EOT
                        stderr_re => undef,
-                       exitcode => 0,
+                       exitcode => 1,
                },
                'mail/getmail' => {
                        stdout_re => <<EOT,

Index: pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm
diff -u pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm:1.1 pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm:1.2
--- pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm:1.1       Wed Nov 25 16:42:21 2015
+++ pkgsrc/pkgtools/pkglint4/files/PkgLint/Patches.pm   Sun Oct  6 10:33:34 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Patches.pm,v 1.1 2015/11/25 16:42:21 rillig Exp $
+# $NetBSD: Patches.pm,v 1.2 2019/10/06 10:33:34 rillig Exp $
 #
 # Everything concerning checks for patch files.
 #
@@ -6,55 +6,6 @@
 use strict;
 use warnings;
 
-# Guess the type of file based on the filename. This is used to select
-# the proper subroutine for detecting absolute pathnames.
-#
-# Returns one of "source", "shell", "make", "text", "configure",
-# "ignore", "unknown".
-#
-sub get_filetype($$) {
-       my ($line, $fname) = @_;
-       my $basename = basename($fname);
-
-       # The trailig .in part is not needed, since it does not
-       # influence the type of contents.
-       $basename =~ s,\.in$,,;
-
-       # Let's assume that everything else that looks like a Makefile
-       # is indeed a Makefile.
-       if ($basename =~ m"^I?[Mm]akefile(?:\..*|)?|.*\.ma?k$") {
-               return "make";
-       }
-
-       # Too many false positives for shell scripts, so configure
-       # scripts get their own category.
-       if ($basename =~ m"^configure(?:|\.ac)$") {
-               $opt_debug_unchecked and $line->log_debug("Skipped check for absolute pathnames.");
-               return "configure";
-       }
-
-       if ($basename =~ m"\.(?:sh|m4)$"i) {
-               return "shell";
-       }
-
-       if ($basename =~ m"\.(?:cc?|cpp|cxx|el|hh?|hpp|l|pl|pm|py|s|t|y)$"i) {
-               return "source";
-       }
-
-       if ($basename =~ m"^.+\.(?:\d+|conf|html|info|man|po|tex|texi|texinfo|txt|xml)$"i) {
-               return "text";
-       }
-
-       # Filenames without extension are hard to guess right. :(
-       if ($basename !~ m"\.") {
-               return "unknown";
-       }
-
-       $opt_debug_misc and $line->log_debug("Don't know the file type of ${fname}.");
-
-       return "unknown";
-}
-
 sub checkline_cpp_macro_names($$) {
        my ($line, $text) = @_;
        my ($rest);
@@ -120,85 +71,11 @@ sub checkline_cpp_macro_names($$) {
        }
 }
 
-# Checks whether the line contains text that looks like absolute
-# pathnames, assuming that the file uses the common syntax with
-# single or double quotes to represent strings.
-#
-sub checkline_source_absolute_pathname($$) {
-       my ($line, $text) = @_;
-       my ($abspath);
-
-       $opt_debug_trace and $line->log_debug("checkline_source_absolute_pathname(${text})");
-
-       if ($text =~ m"(.*)([\"'])(/[^\"']*)\2") {
-               my ($before, $delim, $string) = ($1, $2, $3);
-
-               $opt_debug_misc and $line->log_debug("checkline_source_absolute_pathname(before=${before}, string=${string})");
-               if ($before =~ m"[A-Z_]+\s*$") {
-                       # allowed: PREFIX "/bin/foo"
-
-               } elsif ($string =~ m"^/[*/]") {
-                       # This is more likely to be a C or C++ comment.
-
-               } elsif ($string !~ m"^/\w") {
-                       # Assume that pathnames start with a letter or digit.
-
-               } elsif ($before =~ m"\+\s*$") {
-                       # Something like foodir + '/lib'
-
-               } else {
-                       $abspath = $string;
-               }
-       }
-
-       if (defined($abspath)) {
-               checkword_absolute_pathname($line, $abspath);
-       }
-}
-
-# Last resort if the file does not look like a Makefile or typical
-# source code. All strings that look like pathnames and start with
-# one of the typical Unix prefixes are found.
-#
-sub checkline_other_absolute_pathname($$) {
-       my ($line, $text) = @_;
-
-       $opt_debug_trace and $line->log_debug("checkline_other_absolute_pathname(\"${text}\")");
-
-       if ($text =~ m"^#[^!]") {
-               # Don't warn for absolute pathnames in comments,
-               # except for shell interpreters.
-
-       } elsif ($text =~ m"^(.*?)((?:/[\w.]+)*/(?:bin|dev|etc|home|lib|mnt|opt|proc|sbin|tmp|usr|var)\b[\w./\-]*)(.*)$") {
-               my ($before, $path, $after) = ($1, $2, $3);
-
-               if ($before =~ m"\@$") {
-                       # Something like @PREFIX@/bin
-
-               } elsif ($before =~ m"[)}]$") {
-                       # Something like ${prefix}/bin or $(PREFIX)/bin
-
-               } elsif ($before =~ m"\+\s*[\"']$") {
-                       # Something like foodir + '/lib'
-
-               } elsif ($before =~ m"\w$") {
-                       # Something like $dir/lib
-
-               } elsif ($before =~ m"\.$") {
-                       # ../foo is not an absolute pathname.
-
-               } else {
-                       $opt_debug_misc and $line->log_debug("before=${before}");
-                       checkword_absolute_pathname($line, $path);
-               }
-       }
-}
-
 sub checkfile_patch($) {
        my ($fname) = @_;
        my ($lines);
        my ($state, $redostate, $nextstate, $dellines, $addlines, $hunks);
-       my ($seen_comment, $current_fname, $current_ftype, $patched_files);
+       my ($seen_comment, $current_fname, $patched_files);
        my ($leading_context_lines, $trailing_context_lines, $context_scanning_leading);
 
        # Abbreviations used:
@@ -271,42 +148,6 @@ sub checkfile_patch($) {
                return unless $m->has(1);
                $text = $m->text(1);
                checkline_cpp_macro_names($line, $text);
-
-               # XXX: This check is not as accurate as the similar one in
-               # checkline_mk_shelltext().
-               if (defined($current_fname)) {
-                       if ($current_ftype eq "shell" || $current_ftype eq "make") {
-                               my ($mm, $rest) = match_all($text, $regex_shellword);
-
-                               foreach my $m (@{$mm}) {
-                                       my $shellword = $m->text(1);
-
-                                       if ($shellword =~ m"^#") {
-                                               last;
-                                       }
-                                       checkline_mk_absolute_pathname($line, $shellword);
-                               }
-
-                       } elsif ($current_ftype eq "source") {
-                               checkline_source_absolute_pathname($line, $text);
-
-                       } elsif ($current_ftype eq "configure") {
-                               if ($text =~ m": Avoid regenerating within pkgsrc$") {
-                                       $line->log_error("This code must not be included in patches.");
-                                       $line->explain_error(
-"It is generated automatically by pkgsrc after the patch phase.",
-"",
-"For more details, look for \"configure-scripts-override\" in",
-"mk/configure/gnu-configure.mk.");
-                               }
-
-                       } elsif ($current_ftype eq "ignore") {
-                               # Ignore it.
-
-                       } else {
-                               checkline_other_absolute_pathname($line, $text);
-                       }
-               }
        };
 
        my $check_hunk_end = sub($$$) {
@@ -431,8 +272,6 @@ sub checkfile_patch($) {
                PST_CFA() =>
                [   [re_patch_cfa, PST_CH, sub() {
                        $current_fname = $m->text(1);
-                       $current_ftype = get_filetype($line, $current_fname);
-                       $opt_debug_patches and $line->log_debug("fname=$current_fname ftype=$current_ftype");
                        $patched_files++;
                        $hunks = 0;
                }]],
@@ -500,8 +339,6 @@ sub checkfile_patch($) {
                PST_UFA() =>
                [   [re_patch_ufa, PST_UH, sub() {
                        $current_fname = $m->text(1);
-                       $current_ftype = get_filetype($line, $current_fname);
-                       $opt_debug_patches and $line->log_debug("fname=$current_fname ftype=$current_ftype");
                        $patched_files++;
                        $hunks = 0;
                }]],
@@ -558,7 +395,6 @@ sub checkfile_patch($) {
        $patched_files = 0;
        $seen_comment = false;
        $current_fname = undef;
-       $current_ftype = undef;
        $hunks = undef;
 
        for (my $lineno = 0; $lineno <= $#{$lines}; ) {
Index: pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm
diff -u pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm:1.1 pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm:1.2
--- pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm:1.1 Wed Nov 25 16:42:21 2015
+++ pkgsrc/pkgtools/pkglint4/files/PkgLint/Shell.pm     Sun Oct  6 10:33:34 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Shell.pm,v 1.1 2015/11/25 16:42:21 rillig Exp $
+# $NetBSD: Shell.pm,v 1.2 2019/10/06 10:33:34 rillig Exp $
 #
 # Parsing and checking shell commands embedded in Makefiles
 #
@@ -541,10 +541,6 @@ sub checkline_mk_shelltext($$) {
 "\"||\" operator.");
                }
 
-               if (($state != SCST_PAX_S && $state != SCST_SED_E && $state != SCST_CASE_LABEL)) {
-                       checkline_mk_absolute_pathname($line, $shellword);
-               }
-
                if (($state == SCST_INSTALL_D || $state == SCST_MKDIR) && $shellword =~ m"^(?:\$\{DESTDIR\})?\$\{PREFIX(?:|:Q)\}/") {
                        $line->log_warning("Please use AUTO_MKDIRS instead of "
                                . (($state == SCST_MKDIR) ? "\${MKDIR}" : "\${INSTALL} -d")



Home | Main Index | Thread Index | Old Index