4 # Create a mapping from symbolic component name to directory name(s).
6 # Tue Oct 16 16:48:36 PDT 2001
7 # <mcafee@netscape.com>
11 # For --option1, --option2, ...
13 Getopt
::Long
::Configure
("bundling_override");
14 Getopt
::Long
::Configure
("auto_abbrev");
17 my $list_only_mode = 0;
24 Prints out directories needed for a given list of components.
25 usage: module2dir.pl [--list-only] [--mapfile mapfile] <component-name1> <component-name2> ...
29 sub parse_map_file($) {
31 my (%mod_map, $tmp, $dir, $mod, @mod_list);
34 open (MAPFILE, "$mapfile") || die ("$mapfile: $!\n");
35 while ($tmp=<MAPFILE>) {
37 ($dir, $mod, @mod_list) = split(/:/, $tmp, 3);
38 $mod =~ s/[\s]*(\S+)[\s]*/$1/;
39 $mod_map{$mod} .= "$dir ";
42 foreach $mod (sort(keys %mod_map)) {
43 my (@dirlist, @trimlist, $found, $tdir);
44 @dirlist = split(/\s+/, $mod_map{$mod});
46 foreach $dir (@dirlist) {
48 foreach $tdir (@trimlist) {
49 $found++, last if ($dir =~ m/^$tdir\// || $dir eq $tdir);
51 push @trimlist, $dir if (!$found);
53 $map{$mod} = join(" ", @trimlist);
54 #print "$mod: $map{$mod}\n";
58 sub dir_for_required_component {
63 $dir = $map{$component};
65 # prepend "mozilla/" in front of directory names.
67 $rv =~ s/\s+/ mozilla\//g; # Hack for 2 or more directories.
76 # Add stdin to the commandline. This makes commandline-only mode hang,
77 # call it a bug. Not sure how to get around this.
78 push (@ARGV, split(' ',<STDIN>));
80 PrintUsage() if !GetOptions('list-only' => \$opt_list_only,
81 'mapfile=s' => \$mapfile);
83 # Pick up arguments, if any.
88 &parse_map_file($mapfile);
92 while ($arg = shift @ARGV) {
93 $dir = dir_for_required_component($arg);
98 print "$arg: ", $dir, "\n";
104 if($dir && $list_only_mode) {