forked from xa/RetroWrapper
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathremoveDirectoryEntries.sh
executable file
·100 lines (98 loc) · 4.29 KB
/
removeDirectoryEntries.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
#!/bin/bash
# Rezips all built .jar files, to remove directory entries.
# This reduces the file size by a small amount.
# TODO Re-use output in other steps
for file in ./build/libs/*.jar ./build/libs/*.zip
do
unzip "$file" -d ./build/libs/temp
rm "$file"
shopt -s nullglob
for jarJar in ./build/libs/temp/libraries/*.jar
do
unzip "$jarJar" -d ./build/libs/temp/libraries/temp
rm "$jarJar"
advzip "$jarJar" --shrink-store --pedantic -a ./build/libs/temp/libraries/temp/**
rm -rf ./build/libs/temp/libraries/temp/
strip-nondeterminism "$jarJar"
advzip --shrink-extra -kzp "$jarJar"
if [[ "$BUILD_RELEASE" == "true" ]]; then
advzip --shrink-insane -kzi 9 -p "$jarJar"
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./ci-tools/ect-ubuntu-x86-64 --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-ubuntu-x86-64 -9 --disable-png --disable-jpg -strip -zip "$jarJar"
if [[ "$BUILD_RELEASE" == "true" ]]; then
./ci-tools/ect-ubuntu-x86-64 -99 --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-ubuntu-x86-64 -30060 --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-ubuntu-x86-64 -90032 --disable-png --disable-jpg -strip -zip "$jarJar"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
./ci-tools/ect-0.9.4-mac --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-0.9.4-mac -9 --disable-png --disable-jpg -strip -zip "$jarJar"
if [[ "$BUILD_RELEASE" == "true" ]]; then
./ci-tools/ect-0.9.4-mac -99 --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-0.9.4-mac -30060 --disable-png --disable-jpg -strip -zip "$jarJar"
./ci-tools/ect-0.9.4-mac -90032 --disable-png --disable-jpg -strip -zip "$jarJar"
fi
fi
if [[ "$BUILD_RELEASE" == "true" ]]; then
java -jar ./ci-tools/JarTighten-1.2.11-all.jar -x -o -c -E -S -t -z -j --mode=MULTI_CHEAP "$jarJar" "$jarJar"
else
java -jar ./ci-tools/JarTighten-1.2.11-all.jar -x -o -c -E -S -t --mode=MULTI_CHEAP "$jarJar" "$jarJar"
fi
done
echo "test $file"
for jsonFile in ./build/libs/**/**/**.json ./build/libs/**/**.json ./build/libs/**.json
do
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v gsed &> /dev/null
then
echo "Please install GNU sed as gsed"
else
echo "json $jsonFile"
jq -c . < "$jsonFile" | gsed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
else
jq -c . < "$jsonFile" | sed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
mv "$jsonFile-tempOut" "$jsonFile"
done
# TODO replace this with standard zip
advzip "$file" --shrink-store --pedantic -a ./build/libs/temp/**
rm -rf ./build/libs/temp/
done
for file in ./build/libs/*.jar ./build/libs/*.zip
do
strip-nondeterminism "$file"
advzip --shrink-extra -kzp "$file"
if [[ "$BUILD_RELEASE" == "true" ]]; then
advzip --shrink-insane -kzi 9 -p "$file"
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./ci-tools/ect-ubuntu-x86-64 --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-ubuntu-x86-64 -9 --disable-png --disable-jpg -strip -zip "$file"
if [[ "$BUILD_RELEASE" == "true" ]]; then
./ci-tools/ect-ubuntu-x86-64 -99 --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-ubuntu-x86-64 -30060 --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-ubuntu-x86-64 -90032 --disable-png --disable-jpg -strip -zip "$file"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
./ci-tools/ect-0.9.4-mac --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-0.9.4-mac -9 --disable-png --disable-jpg -strip -zip "$file"
if [[ "$BUILD_RELEASE" == "true" ]]; then
./ci-tools/ect-0.9.4-mac -99 --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-0.9.4-mac -30060 --disable-png --disable-jpg -strip -zip "$file"
./ci-tools/ect-0.9.4-mac -90032 --disable-png --disable-jpg -strip -zip "$file"
fi
fi
if [[ $file == *.jar ]]; then
extra_args="-x"
else
extra_args=""
fi
if [[ "$BUILD_RELEASE" == "true" ]]; then
java -jar ./ci-tools/JarTighten-1.2.11-all.jar $extra_args -o -c -E -S -t -z -j --mode=MULTI_CHEAP "$file" "$file"
else
java -jar ./ci-tools/JarTighten-1.2.11-all.jar $extra_args -o -c -E -S -t --mode=MULTI_CHEAP "$file" "$file"
fi
done