forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosx-setup
executable file
·95 lines (80 loc) · 3.16 KB
/
osx-setup
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
#! /usr/bin/env perl -I./bin
use strict;
use warnings;
use Cwd 'getcwd';
use File::Copy 'copy';
use File::Copy::Recursive 'rcopy';
use File::Find 'find';
use File::Path 'remove_tree';
use String::Util 'trim';
use Metabase::Util;
use constant JRE_DEST => getcwd() . '/OSX/Metabase/jre';
use constant JRE_HOME => trim(`/usr/libexec/java_home`) . '/jre';
use constant UBERJAR_SRC => getcwd() . '/target/uberjar/metabase.jar';
use constant UBERJAR_DEST => getcwd() . '/OSX/Resources/metabase.jar';
use constant RESET_PW_SRC => getcwd() . '/reset-password-artifacts/reset-password/reset-password.jar';
use constant RESET_PW_DEST => getcwd() . '/OSX/Resources/reset-password.jar';
use constant ENABLE_JAR_PACKING => 0;
use constant ENABLE_JAR_OPTIONAL_FILE_STRIPPING => 0;
sub remove_jre_optional_files {
my @optional_files = ('bin/keytool',
'bin/orbd',
'bin/policytool',
'bin/rmid',
'bin/rmiregistry',
'bin/servertool',
'bin/tnameserv',
'lib/cmm/PYCC.pf',
'lib/deploy.jar',
'lib/ext',
'lib/fonts',
'lib/javaws.jar',
'lib/jfr',
'lib/jfr.jar',
'lib/libglass.dylib',
'lib/libglib-lite.dylib',
'lib/libgstreamer-lite.dylib',
'lib/libjavafx_font_t2k.dylib',
'lib/libjfxmedia.dylib',
'lib/libjfxwebkit.dylib',
'lib/libprism_common.dylib',
'lib/libprism_sw.dylib',
'lib/plugin.jar',
'lib/javafx.properties',
'lib/jfxswt.jar'
);
for my $file (@optional_files) {
$file = JRE_DEST . '/' . $file;
remove_tree($file) if -e $file;
}
}
# Finds all the .jar files in JRE_DEST and replaces them with packed .pack.gz files.
sub pack_jre_jars {
sub pack_jar {
if (/\.jar$/) {
s/(^.*)\.jar$/$1/; # stip off extension
print "Packing $_.jar...\n";
system('pack200', '--gzip', '--strip-debug', '--effort=9', $_ . '.pack.gz', $_ . '.jar') == 0 or die $!;
remove_tree($_ . '.jar');
}
}
find(\&pack_jar, JRE_DEST . '/lib');
}
# Copy the JRE if needed
(rcopy(JRE_HOME, JRE_DEST) or die $!) unless -d JRE_DEST;
# Remove optional files from JRE dest
remove_jre_optional_files() if ENABLE_JAR_OPTIONAL_FILE_STRIPPING;
# Pack JARs in JRE if applicable
pack_jar() if ENABLE_JAR_PACKING;
# Build jars if needed
(system('./bin/build') or die $!) unless -f UBERJAR_SRC;
(system('lein', 'with-profile', 'reset-password', 'jar') or die $!) unless -f RESET_PW_SRC;
# Copy jars over
sub copy_jar {
my ($src, $dest) = @_;
announce 'Copying jar ' . $src . ' -> ' . $dest;
copy(get_file_or_die($src), $dest) or die $!;
}
copy_jar(UBERJAR_SRC, UBERJAR_DEST);
copy_jar(RESET_PW_SRC, RESET_PW_DEST);
print_giant_success_banner();