summaryrefslogtreecommitdiffstats
path: root/contrib/local/make-installer-html-table.pl
blob: 63154047a4290dfefe5ea6fee710d7e4846665ee (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/usr/bin/perl -w

use strict;
use Cwd 'abs_path';      # abs_path
use Cwd;                 # getcwd
use File::Spec;          # abs2rel
use Data::Dumper;        # recursively dump data structures via Dumper($foo)
use File::Path;          # make_path
use File::Path qw(make_path);
use File::Temp qw/ tempfile tempdir /;
use File::Basename;

my $script_dir = dirname(abs_path($0));
my $orig_cwd = getcwd;

# get last version where we bumped the version string (ignoring pre, rc, beta ..)
my $cmake_edits = `git log --follow -p $script_dir/../../CMakeLists.txt`;
my $commit_hash;
foreach my $line (split("\n", $cmake_edits)) {
	if ($line =~ /^commit ([\dabcdef]+)/) {
		$commit_hash = $1;
	}
	last if ($commit_hash and $line =~ /\+SET\(UMUNDO_VERSION_PATCH \"\d+\"\)/);
}
my $change_log = `git log --pretty=format:"%H %h @@@ %ai: %s ### %b" $commit_hash..`;
# remove empty bodies
#$change_log =~ s/\n\n/\n/g;
# link to commit on github
$change_log =~ s/([\dabcdef]+) ([\dabcdef]+) @@@/<a href="https:\/\/github\.com\/tklab-tud\/umundo\/commit\/$1">$2<\/a>/g;
# put body below commit message
$change_log =~ s/###\s\n/\n/g;
$change_log =~ s/###\s/\n\n    /g;
$change_log =~ s/\n([^<])/\n    $1/g;


my $installer_dir = shift or die("Expected directory as first argument\n");
if (!File::Spec->file_name_is_absolute($installer_dir)) {
	$installer_dir = File::Spec->rel2abs($installer_dir, getcwd);
}

my $descriptions = {
	'./bin/protoc-umundo-cpp-rpc.*' => 'ProtoBuf RPC plugin for C++',
	'./bin/protoc-umundo-java-rpc.*' => 'ProtoBuf RPC plugin for Java',
	'./bin/umundo-monitor.*' => 'Diagnosis tool (somewhat unmaintained)',
	'./bin/umundo-pingpong.*' => 'Test deployments (i=incoming, o=outgoing)',
	'./include/umundo/core.h' => 'C++ headers for core layer',
	'./include/umundo/rpc.h' => 'C++ headers for remote procedure calls',
	'./include/umundo/s11n.h' => 'C++ headers for object serialization',
	'./include/umundo/util.h' => 'C++ headers for utilities',
	'./lib' => 'Pure C++ libraries',
	'./lib/libumundoNativeJava[\.6].*' => 'SWIG generated JNI wrapper (included in JAR)',
	'./lib/libumundocore[\.6].*' => 'C++ library for core',
	'./lib/libumundorpc[\.6].*' => 'C++ library for remote procedure calls',
	'./lib/libumundoserial[\.6].*' => 'C++ library for serialization',
	'./lib/libumundoutil[\.6].*' => 'C++ library with utilities',
	'./lib/umundo-monitor.lib' => 'not sure',
	'./lib/umundo-pingpong.lib' => 'not sure',
	'./lib/umundoNativeCSharp[\.6].*' => 'SWIG generated C# backend for DLLInvoke',
	'./share/umundo/android-8' => 'Cross compiled binaries for Android',
	'./share/umundo/android-8/armv5te/libumundoNativeJava.so' => 'SWIG generated JNI wrapper',
	'./share/umundo/android-8/umundo.jar' => 'JAR for Android (without JNI inside)',
	'./share/umundo/lib/umundo.jar' => 'JAR for desktops (auto-loading JNI code inside)',
	'./share/umundo/lib/umundoCSharp.dll' => 'C# library with managed code',
	'./share/umundo/prebuilt' => 'Prebuilt libraries in case we forgot something',
	'./share/umundo/samples' => 'Sample programs and IDE templates',
	'./share/umundo/samples/android' => 'Sample programs for Android',
	'./share/umundo/samples/android/umundo-pingpong/libs' => 'These are just placehoders!',
	'./share/umundo/samples/android/umundo-pingpong/libs/armeabi/libumundoNativeJava.so' => 'Replace with real library from above!',
	'./share/umundo/samples/android/umundo-pingpong/libs/armeabi/libumundoNativeJava_d.so' => 'Replace with real library from above!',
	'./share/umundo/samples/android/umundo-pingpong/libs/umundo.jar' => 'Replace with real library from above!',
	'./share/umundo/samples/csharp' => 'Sample programs for C#',
	'./share/umundo/samples/csharp/umundo-pingpong' => 'The simplest umundo program in C#',
	'./share/umundo/samples/csharp/umundo-s11ndemo' => 'Serialization in C# (Dirk is working on it)',
	'./share/umundo/samples/csharp/umundo.s11n' => 'My initial attempts at serialization with C# (deprecated)',
	'./share/umundo/samples/ios' => 'Sample programs for iOS',
	'./share/umundo/samples/ios/umundo-pingpong' => 'The simplest umundo program for iOS',
	'./share/umundo/samples/java' => 'Sample programs for Java',
	'./share/umundo/samples/java/core/chat' => 'Chat using the core layer',
	'./share/umundo/samples/java/core/chat/build.properties' => 'Adapt these for your system',
	'./share/umundo/samples/java/rpc/chat' => 'Chat using the RPC layer',
	'./share/umundo/samples/java/rpc/chat/build.properties' => 'Adapt these for your system',
	'./share/umundo/samples/java/rpc/chat/proto/ChatS11N.proto' => 'ProtoBuf file for chat services',
	'./share/umundo/samples/java/s11n/chat' => 'Chat using the serialization layer',
	'./share/umundo/samples/java/s11n/chat/build.properties' => 'Adapt these for your system',
	'./share/umundo/samples/java/s11n/chat/proto/ChatS11N.proto' => 'ProtoBuf file for chat message objects',
	'./share/umundo/samples/cpp' => 'Sample programs for C++',
	'./share/umundo/samples/cpp/core/chat' => 'Chat using the core layer',
	'./share/umundo/samples/cpp/rpc/chat' => 'Chat using the RPC layer',
	'./share/umundo/samples/cpp/s11n/chat' => 'Chat using the serialization layer',
	'./share/umundo/samples/cpp/s11n/chat/proto/ChatS11N.proto' => 'ProtoBuf file for chat message objects',
	'./share/umundo/samples/cpp/rpc/chat/proto/ChatS11N.proto' => 'ProtoBuf file for chat services',
	'./share/umundo/cmake/FindUMundo.cmake' => 'CMake module to find umundo once it is installed',
	'./share/umundo/cmake/UseUMundo.cmake' => 'CMake macros for protobuf',
};

my ($mac_archive, $linux32_archive, $linux64_archive, $win32_archive, $win64_archive);
my ($mac_files, $linux32_files, $linux64_files, $win32_files, $win64_files);

chdir $installer_dir;
foreach (sort <*>) {
	next if m/^\./;
	$mac_archive         = File::Spec->rel2abs($_, getcwd) if (m/.*darwin.*\.tar\.gz/i);
	$linux32_archive     = File::Spec->rel2abs($_, getcwd) if (m/.*linux-i686.*\.tar\.gz/i);
	$linux64_archive     = File::Spec->rel2abs($_, getcwd) if (m/.*linux-x86_64.*\.tar\.gz/i);
	$win32_archive       = File::Spec->rel2abs($_, getcwd) if (m/.*windows-x86-.*\.zip/i);
	$win64_archive       = File::Spec->rel2abs($_, getcwd) if (m/.*windows-x86_64.*\.zip/i);
}

print STDERR "No archive for MacOSX found!\n" if (!$mac_archive);
print STDERR "No archive for Linux 32Bit found!\n" if (!$linux32_archive);
print STDERR "No archive for Linux 64Bit found!\n" if (!$linux64_archive);
print STDERR "No archive for Windows 32Bit found!\n" if (!$win32_archive);
print STDERR "No archive for Windows 64Bit found!\n" if (!$win64_archive);

$mac_archive =~ m/.*darwin-i386-(.*)\.tar\.gz/;
my $version = $1;

#                    make a hash     remove first element      split into array at newline
%{$mac_files}      = map { $_ => 1 } map { s/^[^\/]*\///; $_ } split("\n", `tar tzf $mac_archive`)      if $mac_archive;
%{$linux32_files}  = map { $_ => 1 } map { s/^[^\/]*\///; $_ } split("\n", `tar tzf $linux32_archive`)  if $linux32_archive;
%{$linux64_files}  = map { $_ => 1 } map { s/^[^\/]*\///; $_ } split("\n", `tar tzf $linux64_archive`)  if $linux64_archive;
%{$win32_files}    = map { $_ => 1 } map { s/^[^\/]*\///; $_ } split("\n", `unzip -l $win32_archive`)   if $win32_archive;
%{$win64_files}    = map { $_ => 1 } map { s/^[^\/]*\///; $_ } split("\n", `unzip -l $win64_archive`)   if $win64_archive;

# print Dumper($mac_files);
# exit;
my $tmpdir = File::Temp->newdir() or die($!);
#print STDERR $tmpdir."\n";
chdir $tmpdir or die($!);

system("tar", "xzf", $mac_archive)      if $mac_archive;
system("tar", "xzf", $linux32_archive)  if $linux32_archive;
system("tar", "xzf", $linux64_archive)  if $linux64_archive;
system("unzip", "-q", $win32_archive)         if $win32_archive;
system("unzip", "-q", $win64_archive)         if $win64_archive;

my $rv;
mkdir("content") or die($!);
foreach (sort <*>) {
	next if m/^\./;
	next if m/.*content/;
	if ($_ !~ /.*windows.*/i) {
		$rv = `ditto $_/usr/local content`;
	} else {
		$rv = `ditto $_ content`;		
	}
	$rv = `rm -rf $_`;
}

# remove duplicates and uninteresting directories
# $rv = `rm -rf content/bin/protoc-umundo-cpp-rpc.exe`;
# $rv = `rm -rf content/bin/protoc-umundo-java-rpc.exe`;
# $rv = `rm -rf content/bin/umundo-monitor.exe`;
# $rv = `rm -rf content/bin/umundo-pingpong.exe`;

$rv = `rm -rf content/include/umundo/common`;
$rv = `rm -rf content/include/umundo/connection`;
$rv = `rm -rf content/include/umundo/discovery`;
$rv = `rm -rf content/include/umundo/protobuf`;
$rv = `rm -rf content/include/umundo/rpc`;
$rv = `rm -rf content/include/umundo/s11n`;
$rv = `rm -rf content/include/umundo/thread`;
$rv = `rm -rf content/include/umundo/util`;
$rv = `rm -rf content/include/umundo-objc`;

chdir "content/" or die($!);

my $tree_list = `tree -a -h --noreport --charset ISO-8859-1`;
my $flat_list = `find -s .`;

print '<html><body>'."\n";

print '<h1>Changelog</h1>'."\n";
print '<pre>'."\n";
print $change_log;
print '</pre>'."\n";

print '<h1>Contents</h1>';
print <<EOF;
<p>The following table is an excerpt of all the files in the individual installer 
packages (detailled C++ headers are not shown). All the different archives/installers 
for a given platform contain the same files, it is only a matter of taste and 
convenience. There are differences between the contents for each platform though 
and they are listed in the <i>availability</i> column.</p>

<p><tt>Mac</tt> are all the darwin installers, <tt>L32</tt> and <tt>L64</tt> is short for Linux 32 and 64Bit
respectively, same with <tt>W32</tt> and <tt>W64</tt> for Windows. Only the first occurence of a 
library is commented, the <tt>_d</tt> suffix signifies debug libraries, the <tt>64</tt> 
suffix is for 64Bit builds and the Windows libraries have no <tt>lib</tt> prefix.</p>

EOF
print '<table>'."\n";
print '<tr><th align="left">Availability</th><th align="left">Filename</th><th align="left">Description</th></tr>';
print '<tr><td valign="top">'."\n";
print '<pre>'."\n";

foreach my $file (split("\n", $flat_list)) {
	if ($file eq '.') {
		print '<font bgcolor="#ccc">MAC</font>|L32|L64|W32|W64'."\n";
		next;
	}
	if (-d $file) {
		print "\n";
		next;
	}
	$file =~ s/\.\///;
#	print STDERR $file."\n";
	(exists($mac_files->{"usr/local/$file"}) ? print " X  " : print " -  ");
	(exists($linux32_files->{"usr/local/$file"}) ? print " X  " : print " -  ");
	(exists($linux64_files->{"usr/local/$file"}) ? print " X  " : print " -  ");
	(exists($win32_files->{"$file"}) ? print " X  " : print " -  ");
	(exists($win64_files->{"$file"}) ? print " X  " : print " -  ");
	print "\n";
}

print '</pre>'."\n";
print '</td><td valign="top">'."\n";
print '<pre>'."\n";

print $tree_list;

print '</pre>'."\n";
print '</td><td valign="top">'."\n";
print '<pre>'."\n";

foreach my $file (split("\n", $flat_list)) {
	my $has_description = 0;
	foreach my $desc (keys %{$descriptions}) {
		if ($file =~ /^$desc$/) {
			print $descriptions->{$desc}."\n";
			delete $descriptions->{$desc};
			$has_description = 1;
		}
	}
	if (!$has_description) {
		print "\n";
	}
}

print '</pre>'."\n";
print '</td></tr>'."\n";
print '</table>'."\n";
print '</body></html>'."\n";

chdir $orig_cwd;