Wed Mar 10 14:42:22 2010 UTC ()
Updated the handling of the LICENSE variable. It is no longer a simple identifier,
but may be a complex boolean expression.


(rillig)
diff -r1.821 -r1.822 pkgsrc/pkgtools/pkglint/files/pkglint.pl

cvs diff -r1.821 -r1.822 pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl 2009/11/20 12:02:33 1.821
+++ pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl 2010/03/10 14:42:22 1.822
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PERL@ 1#! @PERL@
2# $NetBSD: pkglint.pl,v 1.821 2009/11/20 12:02:33 rillig Exp $ 2# $NetBSD: pkglint.pl,v 1.822 2010/03/10 14:42:22 rillig Exp $
3# 3#
4 4
5# pkglint - static analyzer and checker for pkgsrc packages 5# pkglint - static analyzer and checker for pkgsrc packages
6# 6#
7# Written by: 7# Written by:
8# Roland Illig <rillig@NetBSD.org> 8# Roland Illig <rillig@NetBSD.org>
9# 9#
10# Based on work by: 10# Based on work by:
11# Hubert Feyrer <hubertf@NetBSD.org> 11# Hubert Feyrer <hubertf@NetBSD.org>
12# Thorsten Frueauf <frueauf@NetBSD.org> 12# Thorsten Frueauf <frueauf@NetBSD.org>
13# Thomas Klausner <wiz@NetBSD.org> 13# Thomas Klausner <wiz@NetBSD.org>
14# and others. 14# and others.
15# 15#
@@ -3136,26 +3136,35 @@ sub parse_mk_cond($$) { @@ -3136,26 +3136,35 @@ sub parse_mk_cond($$) {
3136 } elsif ($cond =~ s/^empty\((${re_simple_varname})\)$//) { 3136 } elsif ($cond =~ s/^empty\((${re_simple_varname})\)$//) {
3137 return ["empty", $1]; 3137 return ["empty", $1];
3138 } elsif ($cond =~ s/^empty\((${re_simple_varname}):M([^\$:{})]+)\)$//) { 3138 } elsif ($cond =~ s/^empty\((${re_simple_varname}):M([^\$:{})]+)\)$//) {
3139 return ["empty", ["match", $1, $2]]; 3139 return ["empty", ["match", $1, $2]];
3140 } elsif ($cond =~ s/^\$\{(${re_simple_varname})\}\s+(==|!=)\s+"([^"\$\\]*)"$//) { 3140 } elsif ($cond =~ s/^\$\{(${re_simple_varname})\}\s+(==|!=)\s+"([^"\$\\]*)"$//) {
3141 return [$2, ["var", $1], ["string", $3]]; 3141 return [$2, ["var", $1], ["string", $3]];
3142 } else { 3142 } else {
3143 $opt_debug_unchecked and $line->log_debug("parse_mk_cond: ${cond}"); 3143 $opt_debug_unchecked and $line->log_debug("parse_mk_cond: ${cond}");
3144 return ["unknown", $cond]; 3144 return ["unknown", $cond];
3145 } 3145 }
3146 } 3146 }
3147} 3147}
3148 3148
 3149sub parse_licenses($) {
 3150 my ($licenses) = @_;
 3151
 3152 # XXX: this is clearly cheating
 3153 $licenses =~ s,[()]|AND|OR,,g;
 3154 my @licenses = split(/\s+/, $licenses);
 3155 return \@licenses;
 3156}
 3157
3149# This procedure fills in the extra fields of a line, depending on the 3158# This procedure fills in the extra fields of a line, depending on the
3150# line type. These fields can later be queried without having to parse 3159# line type. These fields can later be queried without having to parse
3151# them again and again. 3160# them again and again.
3152# 3161#
3153sub parseline_mk($) { 3162sub parseline_mk($) {
3154 my ($line) = @_; 3163 my ($line) = @_;
3155 my $text = $line->text; 3164 my $text = $line->text;
3156 3165
3157 if ($text =~ regex_varassign) { 3166 if ($text =~ regex_varassign) {
3158 my ($varname, $op, $value, $comment) = ($1, $2, $3, $4); 3167 my ($varname, $op, $value, $comment) = ($1, $2, $3, $4);
3159 3168
3160 # In variable assignments, a '#' character is preceded 3169 # In variable assignments, a '#' character is preceded
3161 # by a backslash. In shell commands, it is interpreted 3170 # by a backslash. In shell commands, it is interpreted
@@ -5097,38 +5106,41 @@ sub checkline_mk_vartype_basic($$$$$$$$) @@ -5097,38 +5106,41 @@ sub checkline_mk_vartype_basic($$$$$$$$)
5097 5106
5098 } else { 5107 } else {
5099 $line->log_warning("Linker flag \"${value}\" does not start with a dash."); 5108 $line->log_warning("Linker flag \"${value}\" does not start with a dash.");
5100 } 5109 }
5101 5110
5102 } elsif ($type eq "License") { 5111 } elsif ($type eq "License") {
5103 5112
5104 use constant deprecated_licenses => array_to_hash(qw( 5113 use constant deprecated_licenses => array_to_hash(qw(
5105 fee-based-commercial-use 5114 fee-based-commercial-use
5106 no-commercial-use no-profit no-redistribution 5115 no-commercial-use no-profit no-redistribution
5107 shareware 5116 shareware
5108 )); 5117 ));
5109 5118
5110 my $license_file = "${cwd_pkgsrcdir}/licenses/${value}"; 5119 my $licenses = parse_licenses($value);
5111 if (defined($pkgctx_vardef) && exists($pkgctx_vardef->{"LICENSE_FILE"})) { 5120 foreach my $license (@$licenses) {
5112 my $license_file_line = $pkgctx_vardef->{"LICENSE_FILE"}; 5121 my $license_file = "${cwd_pkgsrcdir}/licenses/${license}";
 5122 if (defined($pkgctx_vardef) && exists($pkgctx_vardef->{"LICENSE_FILE"})) {
 5123 my $license_file_line = $pkgctx_vardef->{"LICENSE_FILE"};
5113 5124
5114 $license_file = "${current_dir}/" . resolve_relative_path($license_file_line->get("value"), false); 5125 $license_file = "${current_dir}/" . resolve_relative_path($license_file_line->get("value"), false);
5115 } 5126 }
5116 if (!-f $license_file) { 5127 if (!-f $license_file) {
5117 $line->log_warning("License file ".normalize_pathname($license_file)." does not exist."); 5128 $line->log_warning("License file ".normalize_pathname($license_file)." does not exist.");
5118 } 5129 }
5119 5130
5120 if (exists(deprecated_licenses->{$value})) { 5131 if (exists(deprecated_licenses->{$license})) {
5121 $line->log_warning("License ${value} is deprecated."); 5132 $line->log_warning("License ${license} is deprecated.");
 5133 }
5122 } 5134 }
5123 5135
5124 } elsif ($type eq "Mail_Address") { 5136 } elsif ($type eq "Mail_Address") {
5125 if ($value =~ m"^([+\-.0-9A-Z_a-z]+)\@([-\w\d.]+)$") { 5137 if ($value =~ m"^([+\-.0-9A-Z_a-z]+)\@([-\w\d.]+)$") {
5126 my ($localpart, $domain) = ($1, $2); 5138 my ($localpart, $domain) = ($1, $2);
5127 if ($domain =~ m"^NetBSD.org"i && $domain ne "NetBSD.org") { 5139 if ($domain =~ m"^NetBSD.org"i && $domain ne "NetBSD.org") {
5128 $line->log_warning("Please write NetBSD.org instead of ${domain}."); 5140 $line->log_warning("Please write NetBSD.org instead of ${domain}.");
5129 } 5141 }
5130 if ("${localpart}\@${domain}" =~ m"^(tech-pkg|packages)\@NetBSD\.org$"i) { 5142 if ("${localpart}\@${domain}" =~ m"^(tech-pkg|packages)\@NetBSD\.org$"i) {
5131 $line->log_warning("${localpart}\@${domain} is deprecated. Use pkgsrc-users\@NetBSD.org instead."); 5143 $line->log_warning("${localpart}\@${domain} is deprecated. Use pkgsrc-users\@NetBSD.org instead.");
5132 } 5144 }
5133 5145
5134 } else { 5146 } else {