aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/ws-manifest.pl
blob: fd9a0e20ea4c78791da28b6eaebae1e4e9f3cb7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# ws-manifest.pl - create a generic manifest file (including u3 information) from the wireshark.nsi 
# $Id$
#

# These are the known directories in the distribution and where they should live on a U3 device

my %u3locs = qw(
	$INSTDIR device
	$INSTDIR\${GTK_WIMP_DLLDST_DIR} host
	$INSTDIR\${GTK_WIMP_RCDST_DIR} host
	$INSTDIR\diameter device
	$INSTDIR\dtds device
	$INSTDIR\etc\gtk-2.0 host
	$INSTDIR\etc\pango host
	$INSTDIR\help device
	$INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\engines host
	$INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\immodules host
	$INSTDIR\lib\gtk-2.0\${GTK_LIB_DIR}\loaders host
	$INSTDIR\lib\gtk-2.0\modules host
	$INSTDIR\plugins\${VERSION} device
	$INSTDIR\radius device
	$INSTDIR\snmp\mibs device
	$INSTDIR\tpncp device
	$INSTDIR\ui device
	$INSTDIR\wimaxasncp device
	);

my @dirs; # the directories in the manifest
my @defines; # stack of defines

while ($line = <>) {
    if($line =~ /^SetOutPath (.+)$/) {
	$outpath = $1;
	$outpath =~ s/^'(.*)'$/$1/;
	if($outpath ne '$PROFILE') { # ignore the PROFILE
	    push(@dirs, $outpath);
	}
    } elsif ($line =~ /!ifdef (.*)$/) {
	push(@defines, $1);
    } elsif ($line =~ /!endif/) {
	pop(@defines);
	if(scalar(@defines) == 0) {
	    undef @defines;
	}
    } elsif ($line =~/^File.*uninstall/i) {
	next;
    } elsif ($line =~ /^File[^\"]+\"([^\"]+)\"/) {
	$file = $1;
	# make things relative to the root rather than the NSIS directory
	if($file =~ /^[^\.\$]/) { $file = "packaging\\nsis\\" . $file; }
	$file =~ s/\.\.\\\.\.\\//; # remove ../../
	push(@$outpath, $file);

	if(defined @defines) {
	    push(@$file, "ifdef=" . $defines[-1]);
	}

	# there may be a parameter - copy it across
	if($line =~ /\/(\S+)/) {
	    push(@$file, $1);
	}
    }
}

print "#\n# DO NOT EDIT - autogenerated from wireshark.nsi\n#\n";

foreach $dir(sort @dirs) {

    if($prev ne $dir) {
	$loc = $u3locs{$dir};

	if(defined $loc) { 
	    
	    print "[". $dir . " u3loc=" . $loc . "]\n";

	    foreach $file(sort @$dir) {
		print "\t" . $file;

		foreach $param (sort(@$file)) {
		    print " " . $param;
		}

		if($dir eq '$INSTDIR') { # try and find a better location
		    if($file =~ /\.dll$|\.exe$|EXE}$|DLL}$/ && !($file =~ /WinPcap/) && !($file =~ /VCREDIST_EXE/)) {
			print " u3loc=host";
		    }
	}

		print "\n";
	    }
	} else {
	    
	    push(@ignored, $dir);
	    
	}
    }
    $prev = $dir;
}

if(defined @ignored) {

    print STDERR "ERROR\nThe following directories have no known location on a U3 device:\n";

    foreach $dir(sort @ignored) {
	print STDERR "\t" . $dir . " ";
    }
    
    print STDERR "\n";

    exit -1;
}