From 3bb5ef6f040e1162d98a793a7bb0f4ac299a2d15 Mon Sep 17 00:00:00 2001 From: rillig Date: Mon, 14 Nov 2005 04:05:22 +0000 Subject: Updated pkglint to 4.41. - Documented the --recursive option. - Added an option -Cmk for checking .mk files besides buildlink3.mk. - pkglint can handle individual files on the command line, not only packages. (experimental) - Replaced checkfile_buildlink3_mk() with checkfile_mk(). - Factored out the checkfile() subroutine from checkdir_package(). --- pkgtools/pkglint/Makefile | 4 +- pkgtools/pkglint/files/pkglint.0 | 8 ++ pkgtools/pkglint/files/pkglint.1 | 11 ++- pkgtools/pkglint/files/pkglint.pl | 183 ++++++++++++++++++++++---------------- 4 files changed, 127 insertions(+), 79 deletions(-) (limited to 'pkgtools') diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index fbee40f145b..56b71a3ba2d 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.293 2005/11/13 17:39:05 rillig Exp $ +# $NetBSD: Makefile,v 1.294 2005/11/14 04:05:22 rillig Exp $ # -DISTNAME= pkglint-4.40 +DISTNAME= pkglint-4.41 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkglint/files/pkglint.0 b/pkgtools/pkglint/files/pkglint.0 index 07f15ac9fd9..5941932e662 100644 --- a/pkgtools/pkglint/files/pkglint.0 +++ b/pkgtools/pkglint/files/pkglint.0 @@ -36,6 +36,10 @@ DDEESSCCRRIIPPTTIIOONN --RR|----rrccssiiddssttrriinngg Allow other RCS Id strings than NetBSD. Multi- ple strings may be concatenated with `|'. + --rr Check subdirectories, too. The subdirectories + are those that are mentioned in a `SUBDIR+=' + line. + --vv|----vveerrbboossee Be verbose. Show the progress report for items that are being checked. @@ -55,10 +59,14 @@ DDEESSCCRRIIPPTTIIOONN [[nnoo--]]PPLLIISSTT Check PLIST files. + [[nnoo--]]bbll33 Check buildlink3 Makefiles. + [[nnoo--]]ddiissttiinnffoo Check the distinfo file. [[nnoo--]]eexxttrraa Check remaining files in the package directory. + [[nnoo--]]mmkk Check Makefile fragments besides buildlink3. + [[nnoo--]]ppaattcchheess Check the pkgsrc specific patch files. WWaarrnniinnggss diff --git a/pkgtools/pkglint/files/pkglint.1 b/pkgtools/pkglint/files/pkglint.1 index 0d17ee65d65..8df253daa1a 100644 --- a/pkgtools/pkglint/files/pkglint.1 +++ b/pkgtools/pkglint/files/pkglint.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkglint.1,v 1.25 2005/11/10 14:30:56 rillig Exp $ +.\" $NetBSD: pkglint.1,v 1.26 2005/11/14 04:05:22 rillig Exp $ .\" From FreeBSD: portlint.1,v 1.8 1997/11/25 14:53:14 itojun Exp .\" .\" Copyright (c) 1997 by Jun-ichiro Itoh . @@ -48,6 +48,11 @@ Don't print the errors and warnings summary before terminating. Allow other RCS Id strings than NetBSD. Multiple strings may be concatenated with .Ql | . +.It Fl r +Check subdirectories, too. +The subdirectories are those that are mentioned in a +.Ql SUBDIR+= +line. .It Fl v Ns | Ns Fl -verbose Be verbose. Show the progress report for items that are being checked. @@ -68,10 +73,14 @@ Check the package Makefile, including all included files. Check MESSAGE files. .It Cm [no-]PLIST Check PLIST files. +.It Cm [no-]bl3 +Check buildlink3 Makefiles. .It Cm [no-]distinfo Check the distinfo file. .It Cm [no-]extra Check remaining files in the package directory. +.It Cm [no-]mk +Check Makefile fragments besides buildlink3. .It Cm [no-]patches Check the pkgsrc specific patch files. .El diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index b5292ef62d9..7e940dec423 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.347 2005/11/10 19:47:41 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.348 2005/11/14 04:05:22 rillig Exp $ # # This version contains lots of changes necessary for NetBSD packages # done by: @@ -506,6 +506,7 @@ my $opt_check_distinfo = true; my $opt_check_extra = true; my $opt_check_Makefile = true; my $opt_check_MESSAGE = true; +my $opt_check_mk = true; my $opt_check_patches = true; my $opt_check_PLIST = true; my (%checks) = ( @@ -515,6 +516,7 @@ my (%checks) = ( "extra" => [\$opt_check_extra, "check various additional files"], "Makefile" => [\$opt_check_Makefile, "check Makefiles"], "MESSAGE" => [\$opt_check_MESSAGE, "check MESSAGE files"], + "mk" => [\$opt_check_mk, "check other .mk files"], "patches" => [\$opt_check_patches, "check patches"], "PLIST" => [\$opt_check_PLIST, "check PLIST files"], ); @@ -615,7 +617,7 @@ my $pkgname; # PKGNAME from the package Makefile my $seen_USE_PKGLOCALEDIR; # Does the package use PKGLOCALEDIR? my $seen_Makefile_common; # Does the package have any .includes? -my @todo_dirs; # The list of directories that still need +my @todo_items; # The list of directory entries that still need # to be checked. Mostly relevant with # --recursive. @@ -1187,21 +1189,6 @@ sub checkfile_PLIST($) { checklines_trailing_empty_lines($plist); } -sub checkfile_buildlink3_mk($) { - my ($fname) = @_; - my ($lines); - - log_subinfo("checkfile_buildlink3_mk", $fname, NO_LINE_NUMBER, undef); - - if (!($lines = load_file($fname))) { - log_error($fname, NO_LINE_NUMBER, "Cannot be read."); - return; - } - checklines_deprecated_variables($lines); - checklines_trailing_empty_lines($lines); - checklines_direct_tools($lines); -} - sub checkfile_extra($) { my ($fname) = @_; my ($lines); @@ -2267,6 +2254,24 @@ sub load_package_Makefile($$$) { return true; } +sub checkfile_mk($) { + my ($fname) = @_; + my ($lines); + + log_subinfo("checkfile_mk", $fname, NO_LINE_NUMBER, undef); + + checkperms($fname); + if (!($lines = load_file($fname))) { + log_error($fname, NO_LINE_NUMBER, "Cannot be read."); + return; + } + + checklines_deprecated_variables($lines); + checklines_direct_tools($lines); + checklines_package_Makefile($lines); + checklines_Makefile_varuse($lines); +} + sub checkfile_package_Makefile($$$) { my ($fname, $rawwhole, $lines) = @_; my ($distname, $category, $distfiles, @@ -2594,7 +2599,7 @@ sub checkdir_root() { } if ($opt_recursive) { - push(@todo_dirs, @subdirs); + push(@todo_items, @subdirs); } } @@ -2780,7 +2785,50 @@ sub checkdir_category() { } if ($opt_recursive) { - unshift(@todo_dirs, @subdirs); + unshift(@todo_items, @subdirs); + } +} + +sub checkfile($) { + my ($fname) = @_; + + if ($fname =~ qr"(?:work[^/]*|~|\.orig|\.rej)$") { + if ($opt_import) { + log_error($fname, NO_LINE_NUMBER, "Must be cleaned up before committing the package."); + } + + } elsif (!-f $fname) { + # We don't have a check for non-regular files yet. + + } elsif ($fname =~ qr"(?:^|/)buildlink3\.mk$") { + $opt_check_bl3 and checkfile_mk($fname); + + } elsif ($fname =~ qr"\.mk$") { + $opt_check_mk and checkfile_mk($fname); + + } elsif ($fname =~ qr"(?:^|/)DESCR[^/]*$") { + $opt_check_DESCR and checkfile_DESCR($fname); + + } elsif ($fname =~ qr"(?:^|/)distinfo$") { + $opt_check_distinfo and checkfile_distinfo($fname); + + } elsif ($fname =~ qr"(?:^|/)MESSAGE[^/]*$") { + $opt_check_MESSAGE and checkfile_MESSAGE($fname); + + } elsif ($fname =~ qr"(?:^|/)PLIST[^/]*$") { + $opt_check_PLIST and checkfile_PLIST($fname); + + } elsif ($fname =~ qr"(?:^|/)patches/patch-[A-Za-z0-9]*$") { + $opt_check_patches and checkfile_patches_patch($fname); + + } elsif ($fname =~ qr"(?:^|/)patches/[^/]*$") { + log_warning($fname, NO_LINE_NUMBER, "Patch files should be named \"patch-\", followed by letters and digits only."); + + } elsif (-T $fname) { + $opt_check_extra and checkfile_extra($fname); + + } else { + log_warning($fname, NO_LINE_NUMBER, "Unexpectedly found a binary file."); } } @@ -2813,46 +2861,16 @@ sub checkdir_package() { } $have_distinfo = false; $have_patches = false; - foreach my $f (@files) { - if ($f =~ qr"(?:work[^/]*|~|\.orig|\.rej)$") { - if ($opt_import) { - log_error($f, NO_LINE_NUMBER, "Must be cleaned up before committing the package."); - } - - } elsif (!-f $f) { - # We don't have a check for non-regular files yet. - - } elsif ($f eq "${current_dir}/Makefile") { - $opt_check_Makefile and checkfile_package_Makefile($f, $whole, $lines); - - } elsif ($f =~ qr"/buildlink3.mk$") { - $opt_check_bl3 and checkfile_buildlink3_mk($f); - - } elsif ($f =~ qr"/DESCR[^/]*$") { - $opt_check_DESCR and checkfile_DESCR($f); - - } elsif ($f =~ qr"/distinfo$") { - $have_distinfo = true; - $opt_check_distinfo and checkfile_distinfo($f); - - } elsif ($f =~ qr"/MESSAGE[^/]*$") { - $opt_check_MESSAGE and checkfile_MESSAGE($f); - - } elsif ($f =~ qr"/PLIST[^/]*$") { - $opt_check_PLIST and checkfile_PLIST($f); - - } elsif ($f =~ qr"/patches/patch-[A-Za-z0-9]*$") { - $have_patches = true; - $opt_check_patches and checkfile_patches_patch($f); - - } elsif ($f =~ qr"/patches/[^/]*$") { - log_warning($f, NO_LINE_NUMBER, "Patch files should be named \"patch-\", followed by letters and digits only."); - - } elsif (-T $f) { - $opt_check_extra and checkfile_extra($f); - + foreach my $fname (@files) { + if ($fname eq "${current_dir}/Makefile") { + $opt_check_Makefile and checkfile_package_Makefile($fname, $whole, $lines); } else { - log_warning($f, NO_LINE_NUMBER, "Unexpectedly found a binary file."); + checkfile($fname); + } + if ($fname =~ qr"/patches/patch-[A-Za-z0-9]*$") { + $have_patches = true; + } elsif ($fname =~ qr"/distinfo$") { + $have_distinfo = true; } } @@ -2867,27 +2885,40 @@ sub checkdir_package() { } } -sub checkdir($) { - my ($dir) = @_; +sub checkitem($) { + my ($item) = @_; + my ($is_dir); - $current_dir = $dir; - $is_wip = !$opt_import && (Cwd::abs_path($dir) =~ qr"/wip(?:/|$)"); + $is_dir = (-d $item) ? true : false; - if (-f "${dir}/../../mk/bsd.pkg.mk") { - $pkgsrcdir = "${dir}/../.."; - checkdir_package(); + $current_dir = $is_dir ? $item : dirname($item); + $is_wip = !$opt_import && (Cwd::abs_path($current_dir) =~ qr"/wip(?:/|$)"); - } elsif (-f "${dir}/../mk/bsd.pkg.mk") { - log_info(NO_FILE, NO_LINE_NUMBER, "Checking category Makefile."); - $pkgsrcdir = "${dir}/.."; - checkdir_category(); + if (-f "${current_dir}/../../mk/bsd.pkg.mk") { + $pkgsrcdir = "${current_dir}/../.."; + if ($is_dir) { + checkdir_package(); + } else { + checkfile($item); + } - } elsif (-f "${dir}/mk/bsd.pkg.mk") { - $pkgsrcdir = $dir; - checkdir_root(); + } elsif (-f "${current_dir}/../mk/bsd.pkg.mk") { + $pkgsrcdir = "${current_dir}/.."; + if ($is_dir) { + checkdir_category(); + } else { + checkfile($item); + } + } elsif (-f "${current_dir}/mk/bsd.pkg.mk") { + $pkgsrcdir = $current_dir; + if ($is_dir) { + checkdir_root(); + } else { + checkfile($item); + } } else { - log_error($dir, NO_LINE_NUMBER, "Not a pkgsrc directory."); + log_error($item, NO_LINE_NUMBER, sprintf("Don't know how to check this %s.", ($is_dir) ? "directory" : "file")); } } @@ -2899,9 +2930,9 @@ sub main() { parse_command_line(); - @todo_dirs = (@ARGV != 0) ? @ARGV : ("."); - while (@todo_dirs != 0) { - checkdir(shift(@todo_dirs)); + @todo_items = (@ARGV != 0) ? @ARGV : ("."); + while (@todo_items != 0) { + checkitem(shift(@todo_items)); } print_summary_and_exit($opt_quiet); -- cgit v1.2.3