From owner-freebsd-ports Tue Dec 12 13: 0:45 2000 From owner-freebsd-ports@FreeBSD.ORG Tue Dec 12 13:00:39 2000 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mail.rdc1.kt.home.ne.jp (ha1.rdc1.kt.home.ne.jp [203.165.9.242]) by hub.freebsd.org (Postfix) with ESMTP id 191DA37B400; Tue, 12 Dec 2000 13:00:35 -0800 (PST) Received: from daemon.local.idaemons.org ([203.165.161.10]) by mail.rdc1.kt.home.ne.jp (InterMail vM.4.01.02.00 201-229-116) with ESMTP id <20001212210033.YYGR20233.mail.rdc1.kt.home.ne.jp@daemon.local.idaemons.org>; Tue, 12 Dec 2000 13:00:33 -0800 Received: by daemon.local.idaemons.org (8.11.1/3.7W) id eBCL0Wd08464; Wed, 13 Dec 2000 06:00:32 +0900 (JST) Date: Wed, 13 Dec 2000 06:00:32 +0900 Message-ID: <868zplwe1b.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: Peter Pentchev Cc: mharo@FreeBSD.org, knu@FreeBSD.org, ports@FreeBSD.org Subject: Re: portlint - minor patches In-Reply-To: <20001212174943.C36405@ringworld.oblivion.bg> References: <20001212174943.C36405@ringworld.oblivion.bg> User-Agent: Wanderlust/2.5.4 (Smooth) SEMI/1.14.0 (Iburihashi) FLIM/1.14.0 (Ninokuchi) APEL/10.2 MULE XEmacs/21.1 (patch 12) (Channel Islands) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.0 - "Iburihashi") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi, At Tue, 12 Dec 2000 17:49:43 +0200, Peter Pentchev wrote: > Firstly, for quite some time portlint -abcNv has not worked because > the getopt parameter string incorrectly specified a ':' after 'N' > instead of after 'B', thus also disabling the -B# functionality. Good catch! And that confirms me in my longstanding vague suspicion that the -N option hasn't been working. :( When you do this: $ portlint -abcN -N isn't properly recognized because it has no following argument that getopt() expects. > Then, there's the other thing - when checking for contiguous blank > lines, portlint makes an additional effort to not check patchfiles - > it is legitimate for a patch to end with one or more blank lines of > context. However, the check is slightly broken - it assumes that > filenames are taken relative to the port's directory, while now filenames > are absolute. Thus, the /^files\/patch-/ match fails, and patchfiles > are also checked for blank lines at the end. I drastically changed that part to check more effectively and strictly in an extensible way using File::Find module. I added some extra checks for the existence of symlinks, dotfiles, core files, and CVS directories (only when -N is given), and more possible backup files like *~, #*, and *.bak. While I was at it, I also did a trivial cosmetic change against "OK: checking th section of $file ..." messages to make them be uniform. Michael, would you review the attached patch when you've got the time? I've fully tested it, but possibly I am missing something. Feel free to point out anything you notice. Regards, -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "We're only at home when we're on the run, on the wing, on the fly" Index: portlint.pl =================================================================== RCS file: /home/ncvs/ports/devel/portlint/src/portlint.pl,v retrieving revision 1.24 diff -u -u -r1.24 portlint.pl --- portlint.pl 2000/12/12 14:24:12 1.24 +++ portlint.pl 2000/12/12 20:34:06 @@ -22,6 +22,7 @@ use vars qw/ $opt_a $opt_b $opt_c $opt_h $opt_t $opt_v $opt_M $opt_N $opt_B $opt_V /; use Getopt::Std; +use File::Find; use IPC::Open2; #use strict; @@ -97,7 +98,7 @@ } -getopts('abchtvBM:N:V'); +getopts('abchtvB:M:NV'); &usage if $opt_h; &version if $opt_V; @@ -274,26 +275,49 @@ } else { my $proc = $checker{$i}; &$proc($i) || &perror("Cannot open the file $i\n"); - if ($i !~ /^files\/patch-/) { + if ($proc ne 'checkpatch') { &checklastline($i) || &perror("Cannot open the file $i\n"); } } } if ($committer) { - if (scalar(@_ = ) || -d "work") { - &perror("FATAL: be sure to cleanup $portdir/work ". - "before committing the port."); - } - if (scalar(@_ = <*/*~>) || scalar(@_ = <*~>)) { - &perror("FATAL: for safety, be sure to cleanup ". - "editor backup files before committing the port."); - } - if (scalar(@_ = <*/*.orig>) || scalar(@_ = ) - || scalar(@_ = <*/*.rej>) || scalar(@_ = <*.rej>)) { - &perror("FATAL: for safety, be sure to cleanup ". - "patch backup files before committing the port."); - } + sub find_proc { + return if /^\.\.?$/; + + (my $fullname = $File::Find::name) =~ s#^\./##; + + print "OK: checking the file name of $fullname.\n" if ($verbose); + + if ($fullname eq 'work') { + &perror("FATAL: $fullname: be sure to cleanup the working directory ". + "before committing the port."); + + $File::Find::prune = 1; + } elsif (-l) { + &perror("Warning: $fullname: this is a symlink. ". + "CVS will ignore it."); + } elsif (/^\./) { + &perror("Warning: $fullname: dotfiles are not preferred. ". + "If this file is a sample dotfile to be installed, ". + "consider importing it as \"dot$_\"."); + } elsif (/\.(orig|rej|bak)$/ || /~$/ || /^\#/) { + &perror("FATAL: $fullname: for safety, be sure to cleanup ". + "backup files before committing the port."); + } elsif (/(^|\.)core$/) { + &perror("FATAL: $fullname: for safety, be sure to cleanup ". + "core files before committing the port."); + } elsif ($_ eq 'CVS' && -d) { + if ($newport) { + &perror("FATAL: $fullname: for safety, be sure to cleanup ". + "CVS directories before importing the new port."); + } + + $File::Find::prune = 1; + } + } + + find(\&find_proc, '.'); } if ($err || $warn) { print "$err fatal errors and $warn warnings found.\n" @@ -898,7 +922,7 @@ # # section 2: PORTNAME/PORTVERSION/... # - print "OK: checking first section of $file. (PORTNAME/...)\n" + print "OK: checking first section of $file (PORTNAME/...).\n" if ($verbose); $tmp = $sections[$idx++]; @@ -1122,7 +1146,7 @@ # # section 3: PATCH_SITES/PATCHFILES(optional) # - print "OK: checking second section of $file, (PATCH*: optinal).\n" + print "OK: checking second section of $file (PATCH*: optinal).\n" if ($verbose); $tmp = $sections[$idx]; @@ -1178,7 +1202,7 @@ # # section 5: *_DEPENDS (may not be there) # - print "OK: checking fourth section of $file(*_DEPENDS).\n" + print "OK: checking fourth section of $file (*_DEPENDS).\n" if ($verbose); $tmp = $sections[$idx]; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message