From Tom Brezinski:
[obnox/wireshark/wip.git] / packaging / ws-manifest.pl
1 #
2 # ws-manifest.pl - create a generic manifest file (including u3 information) from the wireshark.nsi 
3 # $Id$
4 #
5
6 # These are the known directories in the distribution and where they should live on a U3 device
7
8 my %u3locs = qw(
9         $INSTDIR device
10         $INSTDIR\${GTK_WIMP_DLLDST_DIR} host
11         $INSTDIR\${GTK_WIMP_RCDST_DIR} host
12         $INSTDIR\diameter device
13         $INSTDIR\dtds device
14         $INSTDIR\etc\gtk-2.0 host
15         $INSTDIR\etc\pango host
16         $INSTDIR\help device
17         $INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\engines host
18         $INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\immodules host
19         $INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\loaders host
20         $INSTDIR\lib\gtk-2.0\modules host
21         $INSTDIR\plugins\${VERSION} device
22         $INSTDIR\radius device
23         $INSTDIR\snmp\mibs device
24         $INSTDIR\tpncp device
25         $INSTDIR\ui device
26         $INSTDIR\wimaxasncp device
27         );
28
29 my @dirs; # the directories in the manifest
30 my @defines; # stack of defines
31
32 while ($line = <>) {
33     if($line =~ /^SetOutPath (.+)$/) {
34         $outpath = $1;
35         $outpath =~ s/^'(.*)'$/$1/;
36         if($outpath ne '$PROFILE') { # ignore the PROFILE
37             push(@dirs, $outpath);
38         }
39     } elsif ($line =~ /!ifdef (.*)$/) {
40         push(@defines, $1);
41     } elsif ($line =~ /!endif/) {
42         pop(@defines);
43         if(scalar(@defines) == 0) {
44             undef @defines;
45         }
46     } elsif ($line =~ /^File[^\"]+\"([^\"]+)\"/) {
47         $file = $1;
48         # make things relative to the root rather than the NSIS directory
49         if($file =~ /^[^\.\$]/) { $file = "packaging\\nsis\\" . $file; }
50         $file =~ s/\.\.\\\.\.\\//; # remove ../../
51         push(@$outpath, $file);
52
53         if(defined @defines) {
54             push(@$file, "ifdef=" . $defines[-1]);
55         }
56
57         # there may be a parameter - copy it across
58         if($line =~ /\/(\S+)/) {
59             push(@$file, $1);
60         }
61     }
62 }
63
64 print "#\n# DO NOT EDIT - autogenerated from wireshark.nsi\n#\n";
65
66 foreach $dir(sort @dirs) {
67
68     if($prev ne $dir) {
69         $loc = $u3locs{$dir};
70
71         if(defined $loc) { 
72             
73             print "[". $dir . " u3loc=" . $loc . "]\n";
74
75             foreach $file(sort @$dir) {
76                 print "\t" . $file;
77
78                 foreach $param (sort(@$file)) {
79                     print " " . $param;
80                 }
81
82                 if($dir eq '$INSTDIR') { # try and find a better location
83                     if($file =~ /\.dll$|\.exe$|EXE}$|DLL}$/ && !($file =~ /WinPcap/) && !($file =~ /VCREDIST_EXE/)) {
84                         print " u3loc=host";
85                     }
86         }
87
88                 print "\n";
89             }
90         } else {
91             
92             push(@ignored, $dir);
93             
94         }
95     }
96     $prev = $dir;
97 }
98
99 if(defined @ignored) {
100
101     print STDERR "ERROR\nThe following directories have no known location on a U3 device:\n";
102
103     foreach $dir(sort @ignored) {
104         print STDERR "\t" . $dir . " ";
105     }
106     
107     print STDERR "\n";
108
109     exit -1;
110 }