portlintgrep.pl 1.7 KB

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