$NetBSD: patch-aa,v 1.4 1998/08/07 10:40:27 agc Exp $ --- portlint.pl.orig Wed Jul 15 11:43:04 1998 +++ portlint.pl Wed Jul 15 12:00:43 1998 @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#!@PREFIX@/bin/perl # # portlint - lint for port directory # implemented by: @@ -12,6 +12,10 @@ # # $Id: patch-aa,v 1.4 1998/08/07 10:40:27 agc Exp $ # +# This version contains some changes necessary for NetBSD packages +# done by Hubert Feyrer and +# Thorsten Frueauf +# $err = $warn = 0; $extrafile = $parenwarn = $committer = $verbose = $newport = 0; @@ -27,6 +31,7 @@ $mancompress = 1; $manstrict = 0; $manchapters = '123456789ln'; +$localbase = "/usr/local"; #select(STDERR); while (@ARGV > 0) { @@ -62,10 +67,10 @@ } # OS dependent configs -# os portsdir rcsid mplist ldcfg plist-rcsid mancompresss strict +# os portsdir rcsid mplist ldcfg plist-rcsid mancompresss strict localbase @osdep = split(/\n/, <, <$portdir/pkg/*>)) { next if (! -T $i); - $i =~ s/^$portdir\///; + $i =~ s/^\Q$portdir\E\///; next if (defined $checker{$i}); - push(@checker, $i); - if ($multiplist && $i =~ /pkg\/PLIST/) { + if ($i =~ /pkg\/PLIST$/ || + ($multiplist && $i =~ /pkg\/PLIST/)) { + unshift(@checker, $i); $checker{$i} = 'checkplist'; } else { + push(@checker, $i); $checker{$i} = 'checkpathname'; } } } foreach $i (<$portdir/patches/patch-??>) { next if (! -T $i); - $i =~ s/^$portdir\///; + $i =~ s/^\Q$portdir\E\///; next if (defined $checker{$i}); push(@checker, $i); $checker{$i} = 'checkpatch'; @@ -229,7 +237,7 @@ # sub checkplist { local($file) = @_; - local($curdir) = ('/usr/local'); # XXX + local($curdir) = ($localbase); local($inforemoveseen, $infoinstallseen, $infoseen) = (0, 0, 0); local($infobeforeremove, $infoafterinstall) = (0, 0); local($infooverwrite) = (0); @@ -246,16 +254,26 @@ $_ =~ s/\s+$//; $_ =~ s/\n$//; + + if (($osname eq "NetBSD") && ($_ =~ /<\$ARCH>/)) { + &perror("WARN: $file $.: use of <\$ARCH> ". + "deprecated, use \${MACHINE_ARCH instead}."); + } + if ($_ =~ /^\@/) { if ($_ =~ /^\@(cwd|cd)[ \t]+(\S+)/) { $curdir = $2; } elsif ($_ =~ /^\@unexec[ \t]+rmdir/) { &perror("WARN: use \"\@dirrm\" ". "instead of \"\@unexec rmdir\"."); - } elsif ($_ =~ /^\@exec[ \t]+install-info/) { - $infoinstallseen = $.; - } elsif ($_ =~ /^\@unexec[ \t]+install-info[ \t]+--delete/) { - $inforemoveseen = $.; + } elsif ($_ =~ /^\@exec[ \t]+(.*\/)?install-info/) { + $infoinstallseen = $. + if (($osname ne "NetBSD") || ("$1" eq "%D/bin/")); + # On NetBSD, we enforce %D/bin/... + } elsif ($_ =~ /^\@unexec[ \t]+(.*\/)?install-info[ \t]+--delete/) { + $inforemoveseen = $. + if (($osname ne "NetBSD") || ("$1" eq "%D/bin/")); + # On NetBSD, we enforce %D/bin/... } elsif ($_ =~ /^\@(exec|unexec)/) { if ($ldconfigwithtrue && /ldconfig/ @@ -293,37 +311,39 @@ $infooverwrite++; } - if ($_ =~ m#man/([^/]+/)?man([$manchapters])/([^\.]+\.[$manchapters])(\.gz)?$#) { - if ($4 eq '') { - $plistman{$2} .= ' ' . $3; - if ($mancompress) { - &perror("FATAL: $file $.: ". - "unpacked man file $3 ". - "listed. must be gzipped."); - } - } else { - $plistmangz{$2} .= ' ' . $3; - if (!$mancompress) { - &perror("FATAL: $file $.: ". - "gzipped man file $3$4 ". - "listed. unpacked one should ". - "be installed."); - } - } + if ($_ =~ m#man/([^/]+/)?man([$manchapters])/(.+\.[$manchapters])(\.gz)?#) { # was bugg for manpages w/ . in name - HF + if ($osname eq "FreeBSD") { + if ($4 eq '') { + $plistman{$2} .= ' ' . $3; + if ($mancompress) { + &perror("FATAL: $file $.: ". + "unpacked man file $3 ". + "listed. must be gzipped."); + } + } else { + $plistmangz{$2} .= ' ' . $3; + if (!$mancompress) { + &perror("FATAL: $file $.: ". + "gzipped man file $3$4 ". + "listed. unpacked one should ". + "be installed."); + } + } + } $plistmanall{$2} .= ' ' . $3; if ($1 ne '') { $manlangs{substr($1, 0, length($1) - 1)}++; } } - if ($curdir !~ m#^/usr/local# + if ($curdir !~ m#^$localbase# && $curdir !~ m#^/usr/X11R6#) { &perror("WARN: $file $.: installing to ". "directory $curdir discouraged. ". "could you please avoid it?"); } - if ("$curdir/$_" =~ m#^/usr/local/share/doc#) { + if ("$curdir/$_" =~ m#^$localbase/share/doc#) { print "OK: seen installation to share/doc in $file. ". "($curdir/$_)\n" if ($verbose); $sharedocused++; @@ -341,21 +361,21 @@ } if (!$infoinstallseen) { if ($infooverwrite) { - &perror("FATAL: install-info must be used to ". + &perror("FATAL: \"\@exec ".(($osname eq "NetBSD")?"%D/bin/":"")."install-info must be used to ". "add/delete entries into \"info/dir\"."); } - &perror("FATAL: \"\@exec install-info\" must be placed ". + &perror("FATAL: \"\@exec ".(($osname eq "NetBSD")?"%D/bin/":"")."install-info\" must be placed ". "after all the info files."); } elsif ($infoafterinstall) { - &perror("FATAL: move \"\@exec install-info\" line to make ". + &perror("FATAL: move \"\@exec ".(($osname eq "NetBSD")?"%D/bin/":"")."install-info\" line to make ". "sure that it is placed after all the info files. ". "(currently on line $infoinstallseen in $file)"); } if (!$inforemoveseen) { - &perror("FATAL: \"\@unexec install-info --delete\" must ". + &perror("FATAL: \"\@unexec ".(($osname eq "NetBSD")?"%D/bin/":"")."install-info --delete\" must ". "be placed before any of the info files listed."); } elsif ($infobeforeremove) { - &perror("FATAL: move \"\@exec install-info --delete\" ". + &perror("FATAL: move \"\@exec ".(($osname eq "NetBSD")?"%D/bin/":"")."install-info --delete\" ". "line to make sure ". "that it is placed before any of the info files. ". "(currently on line $inforemoveseen in $file)"); @@ -409,7 +429,10 @@ while () { $whole .= $_; } - if ($committer && $whole =~ /\$([A-Za-z0-9]+)[:\$]/) { + if ($committer && $whole =~ /.\$([A-Za-z0-9]+)[:\$]/) { # XXX + # RCS ID in very first line is ok, to identify version + # of patch (-> only warn if there's something before the + # actual $RCS_ID$, not on BOF - '.' won't match there) &perror("WARN: $file includes possible RCS tag \"\$$1\$\". ". "use binary mode (-ko) on commit/import."); } @@ -435,7 +458,7 @@ $rawwhole = ''; $tmp = 0; while () { - if ($_ =~ /[ \t]+\n?$/) { + if ($_ =~ /[ \t]+\n?$/ && !/^#/) { &perror("WARN: $file $.: whitespace before ". "end of line."); } @@ -514,9 +537,10 @@ } print "OK: checking for use of NOPORTDOCS.\n" if ($verbose); if ($sharedocused && $whole !~ /defined\(NOPORTDOCS\)/ - && $whole !~ m#(\$[\{\(]PREFIX[\}\)]|/usr/local)/share/doc#) { + && $whole !~ m#(\$[\{\(]PREFIX[\}\)]|$localbase)/share/doc#) { &perror("WARN: use \".if !defined(NOPORTDOCS)\" to wrap ". - "installation of files into /usr/local/share/doc."); + "installation of files into $localbase/share/doc.") + if $osname ne "NetBSD"; # how do you get this out of PLIST? } # @@ -581,30 +605,36 @@ # section 1: comment lines. # print "OK: checking comment section of $file.\n" if ($verbose); - @linestocheck = split("\n", <