-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-zip.sh
executable file
·214 lines (170 loc) · 6.19 KB
/
make-zip.sh
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
#!/bin/bash
LEINUBERJAR=0
UPLOAD=0
# keep track of the build version
VERSION=`date +'%Y.%m.%d-%H.%M.%S'`'-'`git rev-parse --short HEAD`
while getopts "luv:" opt;
do
echo "Got opt $opt"
case "$opt" in
l) LEINUBERJAR=1;;
u) UPLOAD=1;;
v) VERSION=$OPTARG'-'`git rev-parse --short HEAD`;;
esac
done
declare -A PLATFORMS
PLATFORMS[linux-x64]='openjdk-14-ea+26_linux-x64_bin.tar.gz'
PLATFORMS[osx-x64]='openjdk-14-ea+26_osx-x64_bin.tar.gz'
PLATFORMS[windows-x64]='openjdk-14-ea+26_windows-x64_bin.zip'
declare -A JAVA_HOMES
JAVA_HOMES[linux-x64]='jvms/linux-x64/jdk-14/'
JAVA_HOMES[osx-x64]='jvms/osx-x64/jdk-14.jdk/Contents/Home/'
JAVA_HOMES[windows-x64]='jvms/windows-x64/jdk-14/'
#clean
find target -name 'robinson-*.zip' -delete
rm -rf target/robinson-*
function upload() {
local file_path=$1
local file_name=$(basename $file_path)
if [[ $UPLOAD == 1 ]] ; then
S3_URL=s3://aaron-santos.com.robinson/download/$file_name
s3cmd put -P $file_path $S3_URL
echo "Wrote $file_name"
fi
}
MACOS_STUB_URL='https://raw.githubusercontent.com/tofi86/universalJavaApplicationStub/v3.0.4/src/universalJavaApplicationStub'
function osx-package-extra() {
local target_path=$1
local platform=$2
local app_root=$target_path/../dmg/Robinson.app
# Download universalJavaApplicationStub
wget $MACOS_STUB_URL -nc -O "jvms/universalJavaApplicationStub"
mkdir -p $app_root/Contents/{MacOS,Resources}
cp -r $target_path/* $app_root/Contents/Resources
# copy jlink image into Robinson.app/Contents/Java
cp -r $target_path/../jlink $app_root/Contents/Java
# copy univeralJavaApplicationStub into Robinson.app/Contents/MacOS
cp jvms/universalJavaApplicationStub $app_root/Contents/MacOS/
chmod +x $app_root/Contents/MacOS/universalJavaApplicationStub
# copy Info.plist
cp dev-resources/Info.plist $app_root/Contents/
# create PkgInfo
echo "APPL????" > $app_root/Contents/MacOS/PkgInfo
# copy .icns to Resources...
cp images/AppIcon.icns $app_root/Contents/Resources/
# Create dmg
genisoimage -V robinson -D -R -apple -no-pad -o target/robinson-$VERSION.dmg $target_path/../dmg
upload target/robinson-$VERSION.dmg
}
function windows-package-extra() {
local target_path=$1
local platform=$2
# copy jvm image into target_path
cp -r $target_path/../jlink/* $target_path
# make exe launcher
lein launch4j
mv dev-resources/robinson.exe $target_path
# make zip
cd $target_path/..
mv $(basename $target_path) robinson-$platform-$VERSION
zip -r robinson-$platform-$VERSION.zip robinson-$platform-$VERSION
cd -
upload target/$platform/robinson-$platform-$VERSION.zip
}
function linux-package-extra() {
local target_path=$1
local platform=$2
# copy jvm image into target_path
cp -r $target_path/../jlink/* $target_path
# cp run.sh
cp dev-resources/run.sh $target_path
# make tar.gz
cd $target_path/..
mv $(basename $target_path) robinson-$platform-$VERSION
tar -zcvf robinson-$platform-$VERSION.tar.gz robinson-$platform-$VERSION
cd -
upload target/$platform/robinson-$platform-$VERSION.tar.gz
}
# Moves resouces into $target_path and then calls platform-specific bundling function
function package()
{
local target_path=$1
local platform=$2
# Copy binary into dist
cp "target/$platform-robinson.jar" $target_path/robinson.jar
chmod +x $target_path/robinson.jar
#copy resources
echo $VERSION >> $target_path/VERSION
cp LICENSE $target_path
cp README.md $target_path
cp PRIVACY.md $target_path
mkdir -p $target_path/config/fonts
cp config/*.edn $target_path/config/
cp config/*.clj $target_path/config/
cp config/fonts/boxy-16.edn $target_path/config/fonts/
cp config/fonts/boxy-24.edn $target_path/config/fonts/
cp -R data $target_path
cp -R fonts $target_path
cp -R images $target_path
cp -R quests $target_path
mkdir $target_path/log
mkdir $target_path/save
# Move over production config settings
rm $target_path/config/settings.edn
mv $target_path/config/production-settings.edn $target_path/config/settings.edn
# Move over fresh(empty) scores file
rm $target_path/scores/scores.edn
mv $target_path/scores/production-scores.edn $target_path/scores/scores.edn
# Remove and userid file
rm $target_path/config/.userid
# set configuration to upload saves
touch $target_path/config/.feedbackparticipant
if [[ "$platform" == "osx-x64" ]]; then
osx-package-extra $target_path $platform
elif [[ "$platform" == "windows-x64" ]]; then
windows-package-extra $target_path $platform
elif [[ "$platform" == "linux-x64" ]]; then
linux-package-extra $target_path $platform
else
echo "Platform not recognized $platform"
fi
}
if [[ $LEINUBERJAR == 1 ]]; then
mkdir -p "jvms"
# Download jdks
for PLATFORM in "${!PLATFORMS[@]}"; do
echo $PLATFORM
FILENAME=${PLATFORMS[$PLATFORM]}
URL="https://download.java.net/java/early_access/jdk14/26/GPL/$FILENAME"
# Download jdk
wget $URL -nc -O "jvms/$FILENAME"
# Decompress jdk
if [[ -d "jvms/$PLATFORM" ]];
then
echo "jvm: $PLATFORM already exists. Skipping decompress."
else
mkdir -p "jvms/$PLATFORM"
if [[ "$FILENAME" == *"tar"* ]];
then
echo "Untar-ing $FILENAME"
tar xvf "jvms/$FILENAME" --directory "jvms/$PLATFORM"
else
echo "Unzipping $FILENAME"
unzip -o "jvms/$FILENAME" -d "jvms/$PLATFORM"
fi
fi
if [[ ! -f "target/$PLATFORM-robinson.jar" ]]; then
# Build standalone binary
lein with-profile bin-$PLATFORM bin
fi
# build jlink image
echo "lein with-profile $PLATFORM jlink init"
export JAVA_HOME=${JAVA_HOMES[$PLATFORM]}
echo "jlink JAVA_HOME=$JAVA_HOME"
lein with-profile jlink-$PLATFORM jlink init
mkdir -p target/$PLATFORM/dist
#copy assets/conf to target dir
package target/$PLATFORM/dist $PLATFORM
done
fi
exit 1