summaryrefslogtreecommitdiff
path: root/devel/portlint/patches/patch-aa
blob: 92ea77b0d2e437d51f19ce271f87e3b2adc8c4e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
--- portlint.pl-orig	Sat Apr 25 13:19:25 1998
+++ portlint.pl	Sat Apr 25 13:32:53 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.1 1998/04/25 13:23:35 frueauf Exp $
 #
+# This version contains some changes necessary for NetBSD packages
+# done by Hubert Feyrer <hubertf@netbsd.org> and
+# Thorsten Frueauf <frueauf@netbsd.org>
+#
 
 $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/, <<EOF);
-FreeBSD	/usr/ports	Id	0	0	0		1	0
-NetBSD	/usr/pkgsrc	NetBSD	1	1	1		0	1
+FreeBSD /usr/ports	Id	0	0	0	    1		 0	/usr/local
+NetBSD	@PORTSDIR@	NetBSD	1	1	1	    0		 1	@PREFIX@
 EOF
 $osname = `uname -s`;
 $osname =~ s/\n$//;
@@ -73,7 +78,7 @@
 	if ($i =~ /^$osname\t(.*)/) {
 		print "OK: found OS config for $osname.\n" if ($verbose);
 		($portsdir, $rcsidstr, $multiplist, $ldconfigwithtrue,
-			$rcsidinplist, $mancompress, $manstrict)
+			$rcsidinplist, $mancompress, $manstrict, $localbase)
 				= split(/\t+/, $1);
 		last;
 	}
@@ -85,7 +90,8 @@
 		"ldconfigwithtrue: $ldconfigwithtrue ".
 		"rcsidinplist: $rcsidinplist ".
 		"mancompress: $mancompress ".
-		"manstrict: $manstrict\n";
+		"manstrict: $manstrict ".
+		"localbase: $localbase\n";
 }
 
 #
@@ -129,26 +135,28 @@
 #
 # check for files.
 #
-@checker = ('pkg/PLIST', 'pkg/COMMENT', 'pkg/DESCR', 'Makefile', 'files/md5');
-%checker = ('pkg/PLIST', 'checkplist', 'pkg/COMMENT', 'checkdescr',
+@checker = ('pkg/COMMENT', 'pkg/DESCR', 'Makefile', 'files/md5');
+%checker = ('pkg/COMMENT', 'checkdescr',
 	    'pkg/DESCR', 'checkdescr', 'Makefile', 'checkmakefile',
 	    'files/md5', 'TRUE');
 if ($extrafile) {
 	foreach $i ((<$portdir/scripts/*>, <$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 (<IN>) {
 		$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 (<IN>) {
-		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", <<EOF);
+	if($osname ne "NetBSD"){
+		@linestocheck = split("\n", <<EOF);
 Whom
 Version [rR]equired
 Date [cC]reated
-(New )?[pP]orts [cC]ollection [mM]akefile [fF]or
 EOF
-	$tmp = $sections[$idx++];
-	$tmp = "\n" . $tmp;	# to make the begin-of-line check easier
+		unshift(@linestocheck,'(New )?[pP]orts [cC]ollection [mM]akefile [fF]or');
+		$tmp = $sections[$idx++];
+		$tmp = "\n" . $tmp;	# to make the begin-of-line check easier
 
-	if ($tmp =~ /\n[^#]/) {
-		&perror("FATAL: non-comment line in comment section of $file.");
-	}
-	foreach $i (@linestocheck) {
-		$j = $i;
-		$j =~ s/\(.*\)\?//g;
-		$j =~ s/\[(.)[^\]]*\]/$1/g;
-		if ($tmp !~ /# $i:[ \t]+\S+/) {
-			&perror("FATAL: no \"$j\" line in ".
-				"comment section of $file.");
-		} else {
-			print "OK: \"$j\" seen in $file.\n" if ($verbose);
+		if ($tmp =~ /\n[^#]/) {
+			&perror("FATAL: non-comment line in comment section of $file.");
 		}
+		foreach $i (@linestocheck) {
+			$j = $i;
+			$j =~ s/\(.*\)\?//g;
+			$j =~ s/\[(.)[^\]]*\]/$1/g;
+			if ($tmp !~ /# $i:[ \t]+\S+/) {
+				&perror("FATAL: no \"$j\" line in ".
+					"comment section of $file.");
+			} else {
+				print "OK: \"$j\" seen in $file.\n" if ($verbose);
+			}
+		}
+	} else {
+		$tmp = $sections[$idx++];
 	}
-	if ($tmp !~ /#\n#(\s+)\$$rcsidstr([^\$]*)\$\n/) {
+	if ((($tmp !~ /#(\s+)\$$rcsidstr([^\$]*)\$/) && ($osname eq "NetBSD"))
+	    || (($tmp !~ /#\n#(\s+)\$$rcsidstr([^\$]*)\$/) &&
+	       ($osname eq "FreeBSD"))) {
 		&perror("FATAL: no \$$rcsidstr\$ line in $file comment ".
 			"section.");
 	} else {
@@ -642,10 +672,15 @@
 	$tmp = $sections[$idx++];
 
 	# check the order of items.
-	&checkorder('DISTNAME', $tmp, split(/\s+/, <<EOF));
-DISTNAME PKGNAME CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
+        @tocheck=split(/\s+/, <<EOF);
+DISTNAME PKGNAME WRKSRC NO_WRKSUBDIR CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
 EXTRACT_SUFX DISTFILES
 EOF
+	if ($osname eq "NetBSD") {
+	    push(@tocheck,"ONLY_FOR_ARCHS");
+	    push(@tocheck,"MIRROR_DISTFILES");
+	}
+        &checkorder('DISTNAME', $tmp, @tocheck);
 
 	# check the items that has to be there.
 	$tmp = "\n" . $tmp;
@@ -671,7 +706,7 @@
 					&perror("FATAL: URL \"$i\" should ".
 						"end with \"/\".");
 				}
-				if ($i =~ m#://[^/]*:/$#) {
+				if ($i =~ m#://[^/]*:/#) {
 					&perror("FATAL: URL \"$i\" contains ".
 						"extra \":\".");
 				}
@@ -721,7 +756,7 @@
 		$j = $`;
 		$k = $1;
 		if ($j =~ /[0-9]$/) {
-			&perror("WARN: is \"$j\" seems sane as package name ".
+			&perror("WARN: is \"$j\" sane as package name ".
 				"WITHOUT version number? ".
 				"if not, avoid \"-\" in version number ".
 				"part of ".
@@ -736,8 +771,8 @@
 				(($pkgname eq '')
 					? ', which is derived from DISTNAME, '
 					: ' ').
-				"looks illegal. should modify \"-$k\" to ".
-				"obey the handbook.");
+				"looks illegal. should modify \"-$k\"" .
+                                ($osname ne "NetBSD"?" to obey the handbook.":"."));
 		}
 	} else {
 		&perror("FATAL: PKGNAME".
@@ -806,13 +841,17 @@
 		if ($verbose);
 	$tmp = $sections[$idx];
 
-	if ($tmp =~ /(PATCH_SITES|PATCHFILES|PATCH_DIST_STRIP)/) {
+	if ($tmp =~ /(PATCH_SITES|PATCH_SITE_SUBDIR|PATCHFILES|PATCH_DIST_STRIP)/) {
 		&checkearlier($tmp, @varnames);
 
 		if ($tmp =~ /^PATCH_SITES=/) {
 			print "OK: seen PATCH_SITES.\n" if ($verbose);
 			$tmp =~ s/^[^\n]+\n//;
 		}
+		if ($tmp =~ /^PATCH_SITE_SUBDIR=/) {
+			print "OK: seen PATCH_SITES.\n" if ($verbose);
+			$tmp =~ s/^[^\n]+\n//;
+		}
 		if ($tmp =~ /^PATCHFILES=/) {
 			print "OK: seen PATCHFILES.\n" if ($verbose);
 			$tmp =~ s/^[^\n]+\n//;
@@ -844,6 +883,7 @@
 		$tmp =~ s/\nMAINTAINER=[^\n]+//;
 	} else {
 		&perror("FATAL: no MAINTAINER listed in $file.");
+                # Why is this fatal? There's a default in bsd.port.mk - HF
 	}
 	$tmp =~ s/\n\n+/\n/g;
 
@@ -862,6 +902,8 @@
 	@linestocheck = split(/\s+/, <<EOF);
 LIB_DEPENDS BUILD_DEPENDS RUN_DEPENDS FETCH_DEPENDS DEPENDS DEPENDS_TARGET
 EOF
+        $warn_lib_depends_backslashes=0
+            if $osname eq "NetBSD";
 	if ($tmp =~ /(LIB_|BUILD_|RUN_|FETCH_)?DEPENDS/) {
 		&checkearlier($tmp, @varnames);
 
@@ -888,10 +930,20 @@
 						"listed in $j. consider using ".
 						"USE_GMAKE.");
 				}
+                                # check for LIB_DEPENDS w/o backslashes
+                                if ($osname eq "NetBSD") {
+	                                if (("$j" eq "LIB_DEPENDS") && ($l =~ /\\\\\./)) {
+                                                $warn_lib_depends_backslashes=1;
+  	                                }
+	                        }
 
 				# check port dir existence
 				$k = (split(':', $k))[1];
-				$k =~ s/\${PORTSDIR}/$ENV{'PORTSDIR'}/;
+				if ($osname eq "NetBSD") {
+					$k =~ s/..\/../$ENV{'PORTSDIR'}/;
+				} else {
+					$k =~ s/\${PORTSDIR}/$ENV{'PORTSDIR'}/;
+				}
 				if (! -d $k) {
 					&perror("WARN: no port directory $k ".
 						"found, even though it is ".
@@ -902,6 +954,9 @@
 				}
 			}
 		}
+                if (($osname eq "NetBSD") && ($warn_lib_depends_backslashes == 1)) {
+                        &perror("WARN: use of backslashes in LIB_DEPENDS is deprecated.");
+                }
 		foreach $i (@linestocheck) {
 			$tmp =~ s/$i[?+]?=[^\n]+\n//g;
 		}
@@ -963,7 +1018,7 @@
 			if ($distname ne '' && $wrksrc eq '') {
 			    &perror("WARN: do not use DISTFILES and DISTNAME ".
 				"to control WRKSRC. how about ".
-				".\"WRKSRC=\${WRKDIR}/$distname\"?");
+				"\"WRKSRC=\${WRKDIR}/$distname\"?");
 			} else {
 			    &perror("WARN: DISTFILES/DISTNAME affects WRKSRC. ".
 				"take caution when changing them.");
@@ -993,12 +1048,14 @@
 			@mman = split(/\s+/, $1);
 			@pman = split(/\s+/, $plistmanall{$i});
 			foreach $j (@mman) {
+		                next if ($j eq '');
 				if (!grep($_ eq $j, @pman)) {
 					&perror("WARN: manpage $j in $file ".
 						"MAN$i but not in PLIST.");
 				}
 			}
 			foreach $j (@pman) {
+		                next if ($j eq '');
 				if (!grep($_ eq $j, @mman)) {
 					&perror("WARN: manpage $j in PLIST ".
 						"but not in $file MAN$i.");
@@ -1169,7 +1226,7 @@
 %cmdnames = split(/\n|\t+/, <<EOF);
 /usr/opt	\${PORTSDIR} instead
 $portsdir	\${PORTSDIR} instead
-/usr/local	\${PREFIX} or \${LOCALBASE}, as appropriate
+$localbase	\${PREFIX} or \${LOCALBASE}, as appropriate
 /usr/X11	\${PREFIX} or \${X11BASE}, as appropriate
 EOF
 	foreach $i (keys %cmdnames) {