New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

root/users/pipping/find_dependents.pl

Revision 24509, 1.1 KB (checked in by pipping@…, 5 years ago)
  • fix bug reported by boeyms@ (thanks a lot!): \b matches a dash, hence 'gimp-print' would match gimp\b
  • Property svn:executable set to *
Line 
1#! /usr/bin/env perl
2
3use strict;
4use warnings;
5
6my $port = $ARGV[0];
7
8# prepare frequently used regexes
9my $trailing_comment      = qr{;(?>\s*)#(?>.*)};
10my $leading_comment       = qr{(?:^|\n)(?>\s*)#(?>.*)};
11my $connecting_backslash  = qr{\s*\\\n\s*};
12
13my $quick_check = qr{:$port}io;
14my $dependency  = qr{
15                    (?=[plb])(?:port|(?:path|lib|bin):[^:]+)  # kind
16                    :                                         # separator
17                    (?i:$port)(\s|\n|$)                       # name
18                  }xo;
19
20$/ = ".\n";
21
22while (defined(my $portfile = <*/*/Portfile>)) { 
23  @ARGV = $portfile;
24
25  while (<>) {
26    # make a quick and dirty check if the port has a remote chance of
27    # depending on $port
28    if ( m{$quick_check} ) {
29
30      s{$connecting_backslash}{ };    # merge backslash-connected lines
31      s{$leading_comment}{};          # remove leading comments
32      s{$trailing_comment}{};         # remove trailing comments
33
34      if ( m{$dependency} ) {
35        $portfile =~ s{/Portfile$}{}; # remove trailing '/Portfile'
36        print "$portfile\n";
37      }
38    }
39  }
40}
Note: See TracBrowser for help on using the browser.