diff options
author | rillig <rillig> | 2005-11-14 05:57:54 +0000 |
---|---|---|
committer | rillig <rillig> | 2005-11-14 05:57:54 +0000 |
commit | 0aeed200d6495e549f44a28e70a319b412eeaeb4 (patch) | |
tree | f858596c565ed13ad329a5a14426c023727258e0 /pkgtools | |
parent | 2088bc6d52d035e7d11aa25fb5bcb6608c14c57e (diff) | |
download | pkgsrc-0aeed200d6495e549f44a28e70a319b412eeaeb4.tar.gz |
- File::stat is used instead of the -d and -f operators to get the file
mode in checkitem().
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/files/pkglint.pl | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index 4412095b01a..cc77d09b26e 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.352 2005/11/14 04:47:44 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.353 2005/11/14 05:57:54 rillig Exp $ # # This version contains lots of changes necessary for NetBSD packages # done by: @@ -474,7 +474,9 @@ use strict; use warnings; use Getopt::Long qw(:config no_ignore_case bundling require_order); +use Fcntl qw(:mode); use File::Basename; +use File::stat; use Cwd; BEGIN { @@ -2873,9 +2875,19 @@ sub checkdir_package() { sub checkitem($) { my ($item) = @_; - my ($is_dir); + my ($st, $is_dir, $is_reg); - $is_dir = (-d $item) ? true : false; + if (!($st = lstat($item))) { + log_error($item, NO_LINE_NUMBER, "Does not exist."); + return; + } + + $is_dir = S_ISDIR($st->mode); + $is_reg = S_ISREG($st->mode); + if (!$is_reg && !$is_dir) { + log_error($item, NO_LINE_NUMBER, "Must be a file or directory."); + return; + } # Initialize global variables. $pkgdir = "."; @@ -2893,27 +2905,26 @@ sub checkitem($) { $pkgsrcdir = "${current_dir}/../.."; if ($is_dir) { checkdir_package(); - } else { - checkfile($item); } } 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($item, NO_LINE_NUMBER, sprintf("Don't know how to check this %s.", ($is_dir) ? "directory" : "file")); + return; + } + + if ($is_reg) { + checkfile($item); } } |