From 2bcf87f2d5fec3c09864bac61d0539da5b75d91d Mon Sep 17 00:00:00 2001 From: rillig Date: Thu, 1 Dec 2005 14:01:59 +0000 Subject: - Added the subroutine checkline_relative_path(). - Added a check for .include lines in all Makefiles and *.mk files to make sure that only existant files are referenced and that pkgsrc packages do not contain references to packages in pkgsrc-wip. --- pkgtools/pkglint/files/pkglint.pl | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'pkgtools/pkglint/files') diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index d16f4c59075..bb3a16c1668 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -11,7 +11,7 @@ # Freely redistributable. Absolutely no warranty. # # From Id: portlint.pl,v 1.64 1998/02/28 02:34:05 itojun Exp -# $NetBSD: pkglint.pl,v 1.401 2005/12/01 13:40:39 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.402 2005/12/01 14:01:59 rillig Exp $ # # This version contains lots of changes necessary for NetBSD packages # done by: @@ -1147,6 +1147,19 @@ sub checkline_rcsid($$) { checkline_rcsid_regex($line, quotemeta($prefix), $prefix); } +sub checkline_relative_path($$) { + my ($line, $path) = @_; + my ($fname); + + if (!$is_wip && $path =~ qr"/wip/") { + $line->log_error("A pkgsrc package must not depend on any outside package."); + } + ($fname = $path) =~ s/^\.\.\/\.\.\//${pkgsrcdir}\//; + if (!-d $fname && !-f $fname) { + $line->log_error("\"${path}\" does not exist."); + } +} + # # Procedures to check an array of lines, part 1. # @@ -1836,16 +1849,10 @@ sub checkline_basic_vartype($$$$$) { } elsif ($type eq "DependencyWithPath") { if ($value =~ regex_unresolved) { # don't even try to check anything - } elsif ($value =~ qr":\.\./\.\./([^/]+)/([^/]+)$") { - my ($cat, $pkg) = ($1, $2); - - if (!$is_wip && $cat eq "wip") { - $line->log_error("A pkgsrc package must not depend on any outside package."); - } + } elsif ($value =~ qr":(\.\./\.\./([^/]+)/([^/]+))$") { + my ($relpath, $cat, $pkg) = ($1, $2, $3); - if (!-d "${pkgsrcdir}/${cat}/${pkg}") { - $line->log_error("The package ${cat}/${pkg} does not exist."); - } + checkline_relative_path($line, $relpath); if ($pkg eq "msgfmt" || $pkg eq "gettext") { $line->log_warning("Please use BUILD_USES_MSGFMT=yes instead of this dependency."); @@ -2682,7 +2689,7 @@ sub checklines_package_Makefile($) { my ($includefile) = ($1); $line->log_debug("includefile=${includefile}"); - # TODO: check the includefile. + checkline_relative_path($line, $includefile); } elsif ($text =~ qr"^\.\s*(if|ifdef|ifndef|else|elif|endif|for|endfor|undef)(?:\s+([^\s#][^#]*?))?\s*(?:#.*)?$") { my ($directive, $args) = ($1, $2); -- cgit v1.2.3