1#!/usr/local/bin/perl
2#
3# Copyright (c) 2003 Oliver Eikemeier. All rights reserved.
4#
5# BSD licensed.
6#
7
8#
9# List all the ports with FATAL errors:
10#
11# portlintgrep ^FATAL:
12#
13
14require 5.005;
15use diagnostics;
16use strict;
17use Carp;
18
19my $make     = $ENV{MAKE}     ? $ENV{MAKE}     : '/usr/bin/make';
20my $portlint = $ENV{PORTLINT} ? $ENV{PORTLINT} : '/usr/local/bin/portlint';
21my $portsdir = $ENV{PORTSDIR} ? $ENV{PORTSDIR} : '/usr/dports';
22my $portlint_args = $ENV{PORTLINT_ARGS} ? $ENV{PORTLINT_ARGS} : '';
23
24die "Usage: portlintgrep <regex>\n" if $#ARGV != 0;
25my $regex = qr/$ARGV[0]/;
26
27my %failedports;
28
29my @categories = split ' ', `cd $portsdir; $make -VSUBDIR`;
30foreach my $category (@categories) {
31        my @ports = split ' ', `cd "$portsdir/$category"; $make -VSUBDIR`;
32        foreach my $port (@ports) {
33                my @result =
34                    `cd "$portsdir/$category/$port"; $portlint $portlint_args`;
35                map chomp, @result;
36                my @filteredresult = grep /$regex/o, @result;
37                if (@filteredresult) {
38                        my $maintainer =
39                            `cd "$portsdir/$category/$port"; $make -VMAINTAINER`;
40                        chomp $maintainer;
41                        push @{$failedports{$maintainer}}, "$category/$port";
42                        print join("\n  ",
43                                "$category/$port <$maintainer>:",
44                                @filteredresult),
45                            "\n";
46                }
47        }
48}
49
50print "\nPorts sorted by maintainer:\n";
51foreach my $maintainer (sort { lc $a cmp lc $b } keys %failedports) {
52        print join("\n - ", $maintainer, @{$failedports{$maintainer}}), "\n";
53}
54