pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Apply patch from Roland Illig, ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/a830c2c1a334
branches: trunk
changeset: 479227:a830c2c1a334
user: wiz <wiz%pkgsrc.org@localhost>
date: Sun Aug 08 22:57:04 2004 +0000
description:
Apply patch from Roland Illig, in private mail:
- replaced literal "1" and "0" by "true" and "false" where appropriate
No functional change, thus no PKGREVISION bump.
diffstat:
pkgtools/pkglint/files/pkglint.pl | 155 ++++++++++++++++++++++---------------
1 files changed, 92 insertions(+), 63 deletions(-)
diffs (truncated from 479 to 300 lines):
diff -r 79eb2f447fc3 -r a830c2c1a334 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sun Aug 08 21:42:56 2004 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sun Aug 08 22:57:04 2004 +0000
@@ -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.114 2004/07/14 17:43:43 wiz Exp $
+# $NetBSD: pkglint.pl,v 1.115 2004/08/08 22:57:04 wiz Exp $
#
# This version contains lots of changes necessary for NetBSD packages
# done by Hubert Feyrer <hubertf%netbsd.org@localhost>,
@@ -19,6 +19,30 @@
# Roland Illig <roland.illig%gmx.de@localhost> and others.
#
+#==========================================================================
+# Some comments on the overall structure: The @EXPORT clauses in the pack-
+# ages must be in a BEGIN block, because otherwise the names starting with
+# an uppercase letter are not recognized as subroutines but as file handles.
+#==========================================================================
+
+package PkgLint::Utils;
+#==========================================================================
+# This package is a catch-all for everything that does not fit in any other
+# package. Currently it contains the boolean constants C<false> and C<true>.
+#==========================================================================
+BEGIN {
+ use Exporter;
+ use vars qw(@ISA @EXPORT_OK);
+ @ISA = qw(Exporter);
+ @EXPORT_OK = qw(false true);
+}
+
+use constant {
+ false => 0,
+ true => 1,
+};
+#== End of PkgLint::Utils =================================================
+
use strict;
use Getopt::Std;
@@ -26,6 +50,10 @@
use FileHandle;
use Cwd;
+BEGIN {
+ import PkgLint::Utils qw(false true);
+}
+
# Start of configuration area
my $conf_rcsidstr = 'NetBSD';
my $conf_portsdir = '@PORTSDIR@';
@@ -34,15 +62,15 @@
my $conf_make = '@MAKE@';
# End of configuration area
-# Command line options
-my $opt_extrafile = 1; #
-my $opt_parenwarn = 1; #
-my $opt_committer = 1; #
-my $opt_verbose = 0; #
-my $opt_newpackage = 0; #
-my $opt_dumpmakefile = 0; #
-my $opt_contblank = 1; # number of allowed contigoous blank lines
-my $opt_packagedir = "."; #
+# Command Line Options
+my $opt_extrafile = true; # check all files we can find for simple errors
+my $opt_parenwarn = true; # warn about use for $(VAR) instead of ${VAR}
+my $opt_committer = true; # check items especially for package developers
+my $opt_newpackage = false; # consider this package new (uncommitted)
+my $opt_dumpmakefile = false; # dump the Makefile after parsing
+my $opt_contblank = 1; # number of allowed contiguous blank lines
+my $opt_packagedir = "."; # directory to check
+my $opt_verbose = false; # print status messages while processing
# Constants
my $regex_rcsidstr = qr"\$($conf_rcsidstr)(?::[^\$]*|)\$";
@@ -61,11 +89,11 @@
my $seen_PKG_REGISTER = undef;
my $category = undef;
my %cmdnames = ();
-my $seen_PLIST_SRC = 0;
-my $seen_NO_PKG_REGISTER = 0;
-my $seen_NO_CHECKSUM = 0;
-my $seen_USE_PKGLOCALEDIR = 0;
-my $seen_USE_BUILDLINK3 = 0;
+my $seen_PLIST_SRC = false;
+my $seen_NO_PKG_REGISTER= false;
+my $seen_NO_CHECKSUM = false;
+my $seen_USE_PKGLOCALEDIR = false;
+my $seen_USE_BUILDLINK3 = false;
my %predefined;
my $pkgname = "";
@@ -117,16 +145,16 @@
EOF
exit 0;
}
- if ($opts{"v"}) { $opt_verbose = 1; }
- if ($opts{"N"}) { $opt_newpackage = 1; }
- if ($opts{"I"}) { $opt_dumpmakefile = 1; }
+ if ($opts{"v"}) { $opt_verbose = true; }
+ if ($opts{"N"}) { $opt_newpackage = true; }
+ if ($opts{"I"}) { $opt_dumpmakefile = true; }
if ($opts{"B"}) { $opt_contblank = $opts{"B"}; }
if (scalar(@ARGV)) { $opt_packagedir = shift(@ARGV); }
if ($opts{"V"}) {
print "$conf_distver\n";
exit;
}
- return 1;
+ return true;
}
sub main() {
@@ -232,11 +260,11 @@
}
{
# Make sure there's a distinfo if there are patches
- my $patches=0;
+ my $patches = false;
patch:
foreach my $i (<$opt_packagedir/$patchdir/patch-*>) {
if ( -T "$i" ) {
- $patches=1;
+ $patches = true;
last patch;
}
}
@@ -303,7 +331,7 @@
"patch backup files before committing the package.");
}
}
- return 1;
+ return true;
} # check_package
#
@@ -336,7 +364,7 @@
if (length($line->[2]) > $maxlength) {
log_warning($line->[0], $line->[1], "Line too long (should be no more than $maxlength characters).");
}
- return 1;
+ return true;
}
sub checkline_valid_characters($$) {
@@ -349,7 +377,7 @@
log_warning($line->[0], $line->[1],
sprintf("Line contains invalid characters (%s).", join(", ", @chars)));
}
- return 1;
+ return true;
}
sub checkline_trailing_whitespace($) {
@@ -357,7 +385,7 @@
if ($line =~ /\s+$/) {
log_warning($line->[0], $line->[1], "Trailing white space.");
}
- return 1;
+ return true;
}
#
@@ -372,7 +400,7 @@
checkperms($fname);
if (!defined($descr = load_file($fname))) {
log_error($fname, NO_LINE_NUMBER, "Error while reading.");
- return 0;
+ return false;
}
foreach my $line (@$descr) {
@@ -385,7 +413,7 @@
log_warning($fname, NO_LINE_NUMBER, "File too long (should be no more than $maxlines lines).");
}
- return 1;
+ return true;
}
sub checkfile_distinfo($) {
@@ -396,12 +424,12 @@
checkperms($fname);
if (!defined($distinfo = load_file($fname))) {
log_error($fname, NO_LINE_NUMBER, "Error while reading.");
- return 0;
+ return false;
}
if (scalar(@$distinfo) == 0) {
log_error($fname, NO_LINE_NUMBER, "May not be empty.");
- return 0;
+ return false;
}
if ($distinfo->[0]->[2] !~ /^$regex_rcsidstr$/) {
@@ -426,7 +454,7 @@
} else {
log_error($line->[0], $line->[1], "$patch does not exist.");
}
- $in_distinfo{$patch} = 1;
+ $in_distinfo{$patch} = true;
}
}
@@ -436,7 +464,7 @@
log_error($fname, NO_LINE_NUMBER, "$patch is not recorded. Rerun '$conf_make makepatchsum'.");
}
}
- return 1;
+ return true;
}
sub checkfile_MESSAGE($) {
@@ -447,12 +475,12 @@
checkperms($fname);
if (!defined($message = load_file($fname))) {
log_error($fname, NO_LINE_NUMBER, "error while reading.");
- return 0;
+ return false;
}
if (scalar(@$message) < 3) {
log_warning($fname, NO_LINE_NUMBER, "file too short.");
- return 0;
+ return false;
}
if ($message->[0]->[2] ne "=" x 75) {
log_warning($message->[0]->[0], $message->[0]->[1], "expected a line of exactly 75 \"=\" characters.");
@@ -468,7 +496,7 @@
if ($message->[-1]->[2] ne "=" x 75) {
log_warning($message->[-1]->[0], $message->[-1]->[1], "expected a line of exactly 75 \"=\" characters.");
}
- return 1;
+ return true;
}
sub checkfile_PLIST($) {
@@ -479,7 +507,7 @@
checkperms($fname);
if (!defined($plist = load_file($fname))) {
log_error($fname, NO_LINE_NUMBER, "error while reading.");
- return 0;
+ return false;
}
$curdir = $conf_localbase;
@@ -569,7 +597,7 @@
if (!$rcsid_seen) {
log_error($file, NO_LINE_NUMBER, "Expected a \@comment \"\$$conf_rcsidstr\$\" line.");
}
- return 1;
+ return true;
}
sub checkperms($) {
@@ -578,7 +606,7 @@
if (-f $file && -x $file) {
log_warning($file, NO_LINE_NUMBER, "should not be executable.");
}
- return 1;
+ return true;
}
#
@@ -593,15 +621,15 @@
if ($file =~ /$filesdir\//) {
# ignore
- return 1;
+ return true;
}
# FIXME: convert to load_file.
- open(IN, "< $opt_packagedir/$file") || return 0;
+ open(IN, "< $opt_packagedir/$file") || return false;
{ local $/; $whole = <IN>; }
close(IN);
abspathname($whole, $file);
- return 1;
+ return true;
}
sub checklastline($) {
@@ -611,7 +639,7 @@
if (!open(IN, "< $fname")) {
log_error($fname, NO_LINE_NUMBER, "could not open: $!");
- return 0;
+ return false;
}
{ local $/; $whole = <IN>; }
close(IN);
@@ -623,7 +651,7 @@
} elsif ($whole =~ /\r*\n(?:[ \t]*\r*\n)+$/) {
log_warning($fname, NO_LINE_NUMBER, "perhaps unnecessary blank lines at end of file.");
Home |
Main Index |
Thread Index |
Old Index