Browse Source

Support the new Makefile WWW macro.

PR:		266068
Submitted by:	se
Joe Clarke 1 year ago
parent
commit
6271783d52
1 changed files with 41 additions and 17 deletions
  1. 41 17
      portlint.pl

+ 41 - 17
portlint.pl

@@ -158,7 +158,7 @@ my @varlist =  qw(
 	PKGNAMEPREFIX PKGNAMESUFFIX DISTVERSIONPREFIX DISTVERSION
 	DISTVERSIONSUFFIX DISTNAME DISTFILES CATEGORIES MASTERDIR MAINTAINER
 	MASTER_SITES WRKDIR WRKSRC NO_WRKSUBDIR SCRIPTDIR FILESDIR
-	PKGDIR COMMENT DESCR PLIST PKGCATEGORY PKGINSTALL PKGDEINSTALL
+	PKGDIR COMMENT WWW DESCR PLIST PKGCATEGORY PKGINSTALL PKGDEINSTALL
 	PKGREQ PKGMESSAGE DISTINFO_FILE .CURDIR USE_LDCONFIG USE_AUTOTOOLS
 	USE_GNOME USE_PERL5 USE_QT USE_QT5 INDEXFILE PKGORIGIN
 	CONFLICTS CONFLICTS_BUILD CONFLICTS_INSTALL PKG_VERSION
@@ -490,7 +490,7 @@ sub checkdescr {
 	my($file) = @_;
 	my(%maxchars) = ($makevar{DESCR}, 80);
 	my(%maxlines) = ($makevar{DESCR}, 24);
-	my(%minlines) = ($makevar{DESCR}, 3);
+	my(%minlines) = ($makevar{DESCR}, 2);
 	my(%toolongerrmsg) = ($makevar{DESCR},
 					"exceeds $maxlines{$makevar{DESCR}} ".
 					"lines, make it shorter if possible.");
@@ -515,10 +515,10 @@ sub checkdescr {
 		}
 		if (/^WWW:(\s+)(\S*)/) {
 			my $wwwurl = $2;
-			if ($1 ne ' ') {
-				&perror("WARN", $file, -1, "use WWW: with a single space, ".
-					"then $wwwurl");
-			}
+			&perror("WARN", $file, -1, "the URL of the project website has been ".
+				"moved into the Makefile.  ".
+				"Remove the WWW: line from this file and add \"WWW=$wwwurl\"".
+				"to the Makefile immediately below the COMMENT line.");
 			if ($wwwurl !~ m|^https?://|) {
 				&perror("WARN", $file, -1, "WWW URL, $wwwurl should begin ".
 					"with \"http://\" or \"https://\".");
@@ -2180,6 +2180,7 @@ xargs xmkmf
 				&& $curline !~ /^NO_PACKAGE(.)?=[^\n]+$i/m
 				&& $curline !~ /^NO_CDROM(.)?=[^\n]+$i/m
 				&& $curline !~ /^MAINTAINER(.)?=[^\n]+$i/m
+				&& $curline !~ /^WWW(.)?=[^\n]+$i/m
 				&& $curline !~ /^CATEGORIES(.)?=[^\n]+$i/m
 				&& $curline !~ /^(\w+)?USES(.)?=[^\n]+$i/m
 				&& $curline !~ /^WX_COMPS(.)?=[^\n]+$i/m
@@ -2214,6 +2215,7 @@ xargs xmkmf
 				&& $lm !~ /^NO_PACKAGE(.)?=[^\n]+($i\d*)/m
 				&& $lm !~ /^NO_CDROM(.)?=[^\n]+($i\d*)/m
 				&& $lm !~ /^MAINTAINER(.)?=[^\n]+($i\d*)/m
+				&& $lm !~ /^WWW(.)?=[^\n]+($i\d*)/m
 				&& $lm !~ /^CATEGORIES(.)?=[^\n]+($i\d*)/m
 				&& $lm !~ /^USES(.)?=[^\n]+$i/m
 				&& $lm !~ /^[A-Z0-9_]+_DESC=[^\n]+($i\d*)/m
@@ -2686,15 +2688,16 @@ EOF
 			&perror("WARN", $file, -1, "Version required is no longer needed in the comment section.");
 		}
 
-		#
-		# for the rest of the checks, comment lines are not important.
-		#
-		for ($i = 0; $i < scalar(@sections); $i++) {
-			$sections[$i] = "\n" . $sections[$i];
-			$sections[$i] =~ s/\n#[^\n]*//g;
-			$sections[$i] =~ s/\n\n+/\n/g;
-			$sections[$i] =~ s/^\n//;
-		}
+	}
+
+	#
+	# for the rest of the checks, comment lines are not important.
+	#
+	for ($i = 0; $i < scalar(@sections); $i++) {
+		$sections[$i] = "\n" . $sections[$i];
+		$sections[$i] =~ s/\n#[^\n]*//g;
+		$sections[$i] =~ s/\n\n+/\n/g;
+		$sections[$i] =~ s/^\n//;
 	}
 
 	#
@@ -3185,7 +3188,7 @@ PATCH_SITES PATCHFILES PATCH_DIST_STRIP
 
 	&checkearlier($file, $tmp, @varnames);
 	&checkorder('MAINTAINER', $tmp, $file, qw(
-MAINTAINER COMMENT
+MAINTAINER COMMENT WWW
 	));
 
 	$tmp = "\n" . $tmp;
@@ -3235,10 +3238,31 @@ MAINTAINER COMMENT
 		}
 	}
 
+	# check WWW
+	if ($tmp !~ /\nWWW.?=\s*(\S+)/) {
+		&perror("WARN", $file, -1, "WWW should exist and immediately follow COMMENT.") unless ($makevar{WWW} ne '');
+	}
+
+	# check for correctness
+	{
+		my $wwwurl = $1 // $makevar{WWW};
+		if ($wwwurl and $wwwurl !~ m|^https?://|) {
+			&perror("WARN", $file, -1, "WWW URL, $wwwurl should begin with \"http://\" or \"https://\".");
+		}
+		if ($wwwurl =~ m|search.cpan.org|) {
+			if ($wwwurl =~ m|^http.?://search.cpan.org/~|) {
+				&perror("WARN", $file, -1, "consider changing WWW URL to https://search.cpan.org/dist/$makevar{PORTNAME}/");
+			}
+			if ($wwwurl =~ m,/$,) {
+				&perror("WARN", $file, -1, "end WWW CPAN URL with a \"/\"");
+			}
+		}
+	}
+
 	$idx++;
 
 	push(@varnames, qw(
-MAINTAINER COMMENT
+MAINTAINER COMMENT WWW
 	));
 
 	#