| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! @PERL@ | | 1 | #! @PERL@ |
2 | # $NetBSD: pkglint.pl,v 1.839 2012/07/10 10:27:23 wiz Exp $ | | 2 | # $NetBSD: pkglint.pl,v 1.840 2012/07/10 10:53:05 wiz 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 | # |
| @@ -1322,27 +1322,27 @@ my (@options) = ( | | | @@ -1322,27 +1322,27 @@ my (@options) = ( |
1322 | [ "-s|--source", "Show the source lines together with diagnostics", | | 1322 | [ "-s|--source", "Show the source lines together with diagnostics", |
1323 | "source|s", | | 1323 | "source|s", |
1324 | sub { | | 1324 | sub { |
1325 | PkgLint::Logging::set_show_source_flag(); | | 1325 | PkgLint::Logging::set_show_source_flag(); |
1326 | } ], | | 1326 | } ], |
1327 | ); | | 1327 | ); |
1328 | | | 1328 | |
1329 | # | | 1329 | # |
1330 | # Commonly used regular expressions. | | 1330 | # Commonly used regular expressions. |
1331 | # | | 1331 | # |
1332 | | | 1332 | |
1333 | use constant regex_dependency_gt => qr"^((?:\$\{[\w_]+\}|[\w_\.]|-[^\d])+)>=(\d[^-]*)$"; | | 1333 | use constant regex_dependency_gt => qr"^((?:\$\{[\w_]+\}|[\w_\.]|-[^\d])+)>=(\d[^-]*)$"; |
1334 | use constant regex_dependency_wildcard | | 1334 | use constant regex_dependency_wildcard |
1335 | => qr"^((?:\$\{[\w_]+\}|[\w_\.]|-[^\d\[])+)-(?:\[0-9\]|\d[^-]*)$"; | | 1335 | => qr"^((?:\$\{[\w_]+\}|[\w_\.]|-[^\d\[])+)-(?:\[0-9\]\*|\d[^-]*)$"; |
1336 | use constant regex_gnu_configure_volatile_vars | | 1336 | use constant regex_gnu_configure_volatile_vars |
1337 | => qr"^(?:.*_)?(?:CFLAGS||CPPFLAGS|CXXFLAGS|FFLAGS|LDFLAGS|LIBS)$"; | | 1337 | => qr"^(?:.*_)?(?:CFLAGS||CPPFLAGS|CXXFLAGS|FFLAGS|LDFLAGS|LIBS)$"; |
1338 | use constant regex_mk_comment => qr"^ *\s*#(.*)$"; | | 1338 | use constant regex_mk_comment => qr"^ *\s*#(.*)$"; |
1339 | use constant regex_mk_cond => qr"^\.(\s*)(if|ifdef|ifndef|else|elif|endif|for|endfor|undef)(?:\s+([^\s#][^#]*?))?\s*(?:#.*)?$"; | | 1339 | use constant regex_mk_cond => qr"^\.(\s*)(if|ifdef|ifndef|else|elif|endif|for|endfor|undef)(?:\s+([^\s#][^#]*?))?\s*(?:#.*)?$"; |
1340 | use constant regex_mk_dependency=> qr"^([^\s:]+(?:\s*[^\s:]+)*)(\s*):\s*([^#]*?)(?:\s*#.*)?$"; | | 1340 | use constant regex_mk_dependency=> qr"^([^\s:]+(?:\s*[^\s:]+)*)(\s*):\s*([^#]*?)(?:\s*#.*)?$"; |
1341 | use constant regex_mk_include => qr"^\.\s*(s?include)\s+\"([^\"]+)\"\s*(?:#.*)?$"; | | 1341 | use constant regex_mk_include => qr"^\.\s*(s?include)\s+\"([^\"]+)\"\s*(?:#.*)?$"; |
1342 | use constant regex_mk_sysinclude=> qr"^\.\s*s?include\s+<([^>]+)>\s*(?:#.*)?$"; | | 1342 | use constant regex_mk_sysinclude=> qr"^\.\s*s?include\s+<([^>]+)>\s*(?:#.*)?$"; |
1343 | use constant regex_mk_shellvaruse => qr"(?:^|[^\$])\$\$\{?(\w+)\}?"; # XXX: not perfect | | 1343 | use constant regex_mk_shellvaruse => qr"(?:^|[^\$])\$\$\{?(\w+)\}?"; # XXX: not perfect |
1344 | use constant regex_pkgname => qr"^([\w\-.+]+)-(\d(?:\w|\.\d)*)$"; | | 1344 | use constant regex_pkgname => qr"^([\w\-.+]+)-(\d(?:\w|\.\d)*)$"; |
1345 | use constant regex_mk_shellcmd => qr"^\t(.*)$"; | | 1345 | use constant regex_mk_shellcmd => qr"^\t(.*)$"; |
1346 | use constant regex_rcs_conflict => qr"^(<<<<<<<|=======|>>>>>>>)"; | | 1346 | use constant regex_rcs_conflict => qr"^(<<<<<<<|=======|>>>>>>>)"; |
1347 | use constant regex_unresolved => qr"\$\{"; | | 1347 | use constant regex_unresolved => qr"\$\{"; |
1348 | use constant regex_validchars => qr"[\011\040-\176]"; | | 1348 | use constant regex_validchars => qr"[\011\040-\176]"; |
| @@ -3140,26 +3140,27 @@ sub parse_mk_cond($$) { | | | @@ -3140,26 +3140,27 @@ sub parse_mk_cond($$) { |
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 | |
3149 | sub parse_licenses($) { | | 3149 | sub parse_licenses($) { |
3150 | my ($licenses) = @_; | | 3150 | my ($licenses) = @_; |
3151 | | | 3151 | |
3152 | # XXX: this is clearly cheating | | 3152 | # XXX: this is clearly cheating |
| | | 3153 | $licenses =~ s,\${PERL5_LICENSE},gnu-gpl-v2 OR artistic,g; |
3153 | $licenses =~ s,[()]|AND|OR,,g; | | 3154 | $licenses =~ s,[()]|AND|OR,,g; |
3154 | my @licenses = split(/\s+/, $licenses); | | 3155 | my @licenses = split(/\s+/, $licenses); |
3155 | return \@licenses; | | 3156 | return \@licenses; |
3156 | } | | 3157 | } |
3157 | | | 3158 | |
3158 | # This procedure fills in the extra fields of a line, depending on the | | 3159 | # This procedure fills in the extra fields of a line, depending on the |
3159 | # line type. These fields can later be queried without having to parse | | 3160 | # line type. These fields can later be queried without having to parse |
3160 | # them again and again. | | 3161 | # them again and again. |
3161 | # | | 3162 | # |
3162 | sub parseline_mk($) { | | 3163 | sub parseline_mk($) { |
3163 | my ($line) = @_; | | 3164 | my ($line) = @_; |
3164 | my $text = $line->text; | | 3165 | my $text = $line->text; |
3165 | | | 3166 | |