-
Notifications
You must be signed in to change notification settings - Fork 1
/
builder.sh
executable file
·151 lines (137 loc) · 5.81 KB
/
builder.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
#!/usr/bin/env sh
##
# builder.sh
#
# Authors: Sidney PEPO (aka sysb1n)
# Last change: 2022-10-23
#
# Description: that's Steins;Zapp auto-builder script. Guide yourself
# by reading "status" function messages present in code after some
# commands or Shell Script instructions.
#
# ~El Psy Kongroo
##
# Status variables to be uses at "status" function.
normal_text="\e[0m"
info="\n\e[1;34m[i]${normal_text}"
success="\e[1;32m[+]${normal_text}"
error="\e[1;31m[!]${normal_text}"
# Those variable are used to make Steins;Zapp file updates easier, for
# example, on release name, base apk, etc.
release="Makise Kurisu"
wago_ver="v0.22.10L"
base_apk="./dependencies/com.soula2_${wago_ver}.apk"
base_dir="source"
apktool="./dependencies/apktool_2.6.1.jar"
zipalign="./dependencies/zipalign"
apksigner="./dependencies/apksigner.jar"
# After or before any procedure, this function is called to present an
# information about it.
status() {
s_value=${1}
s_message=${2}
echo -e "${s_message}"
if [[ ${s_value} -ne 0 ]]; then
exit ${s_value}
fi
}
status 0 "${info} Checking files and decompiling base APK..."
if [[ ! -d "./dependencies" ]] || [[ ! -d "./patches" ]]; then
status 1 "${error} Missing files. Try pull the repository."
fi
status 0 "${success} Files successfully checked."
if [[ -d "./${base_dir}" ]]; then
rm -rf "./${base_dir}" > /dev/null
fi
java -jar ${apktool} -q d ${base_apk} -o ${base_dir}
if [[ ${?} -ne 0 ]]; then
status ${?} "${error} Failed to decompile."
fi
status 0 "${success} Base APK successfully decompiled."
status 0 "${info} Removing bloated files..."
# TODO - Fix removing Goodle's bloated shit.
# cd ${base_dir}/
# rm -r unknown/* 2> /dev/null
# cd - > /dev/null
# Important non-bloated file list that SHOULD be previously backed up
# to patches/assets/ directory:
# - ./${base_dir}/assets/cldr_strings.pack
# - ./${base_dir}/assets/country_names_en.tsv
# - ./${base_dir}/assets/ephemeral_settings_lottie_animation.lottie
# - ./${base_dir}/assets/version.properties
# - ./${base_dir}/assets/compressed/armeabi-v7a/
# - ./${base_dir}/assets/compressed/emojis/
# - ./${base_dir}/assets/compressed/strings/cldr_strings.spk.br
# - ./${base_dir}/assets/compressed/strings/strings_en.spk.br
# - ./${base_dir}/assets/emoji/
# - ./${base_dir}/assets/fonts/
# - ./${base_dir}/assets/graphics/
# - ./${base_dir}/assets/npci/
rm -r ./${base_dir}/assets/* 2> /dev/null
status ${?} "${success} Removed bloated files."
./dependencies/value_list.sh source 2> /dev/null
status 0 "${success} Removed translations files."
status 0 "${info} Copying modified files..."
cp -rf ./patches/* ./${base_dir} 2> /dev/null
status ${?} "${success} Patches copied and applied."
./dependencies/light_theme.sh ${base_dir}
status 0 "${success} Light theme copied and applied."
./dependencies/dark_theme.sh ${base_dir}
status 0 "${success} Dark theme copied and applied."
# Cleaning output directory.
rm -rf ./steins-zapp/* > /dev/null
# Declaring an array and storing the Steins;Zapp symbols in it.
declare -A symbols
symbols[0]="0"
symbols[1]="β"
symbols[2]="α"
symbols[3]="γ"
symbols[4]="δ"
for divergence in {0..4}; do
status 0 "${info} Building, aligning and signing com.steinszapp${divergence}.apk..."
cp -r ./${base_dir} ./build
./dependencies/general.sh build ${divergence}
for apk_paths in $(grep -s -r -o "com\.soula2" ./build | cut -d ":" -f 1 | uniq); do
sed -i "s/com\.soula2/com\.steinszapp${divergence}/g" ${apk_paths} > /dev/null
done
for smali_paths in $(grep -s -r -o "Lcom\/soula2" ./build | cut -d ":" -f 1 | uniq); do
sed -i "s/Lcom\/soula2/Lcom\/steinszapp${divergence}/g" ${smali_paths} > /dev/null
done
sed -i "s/<string name=\"launcher_app_name\">WhatsApp<\/string>/<string name=\"launcher_app_name\">${symbols[${divergence}]} Steins;Zapp ${release}<\/string>/g" ./build/res/values/strings.xml > /dev/null
sed -i "s/<string name=\"wa_go_name\">Soula2<\/string>/<string name=\"wa_go_name\">${symbols[${divergence}]} Steins;Zapp ${release}<\/string>/g" ./build/res/values-v1/strings.xml > /dev/null
sed -i "s/<string name=\"wa_go_version\">${wago_ver}<\/string>/<string name=\"wa_go_version\">${release}<\/string>/g" ./build/res/values-v1/strings.xml > /dev/null
sed -i "s/<string name=\"wa_go_name_title\">Steins;Zapp ${wago_ver}<\/string>/<string name=\"wa_go_name_title\">Steins;Zapp ${release}<\/string>/g" ./build/res/values-v1/strings.xml > /dev/null
java -jar ${apktool} -q b ./build -o build.apk
if [[ ${?} -ne 0 ]]; then
status ${?} "${error} Failed to build."
break
fi
status ${?} "${success} Successfully builded."
${zipalign} -p -f -v 4 build.apk ./steins-zapp/com.steinszapp${divergence}.apk > /dev/null
if [[ ${?} -ne 0 ]]; then
status ${?} "${error} Failed to align."
break
fi
status ${?} "${success} Successfully aligned."
java -jar ${apksigner} sign --ks ./dependencies/key.keystore --ks-key-alias steins-zapp --ks-pass pass:elpsykongroo ./steins-zapp/com.steinszapp${divergence}.apk
if [[ ${?} -ne 0 ]]; then
status ${?} "${error} Failed to sign."
break
fi
status ${?} "${success} Successfully signed."
# Removing the generated temp files.
rm -rf ./steins-zapp/com.steinszapp${divergence}.apk.idsig ./build.apk ./build > /dev/null
status ${?} "${success} com.steinszapp${divergence}.apk done!"
done
status 0 "${info} All APK's were successfully generated!"
status 0 "${info} Generating CHECKSUM and zipping files..."
touch CHECKSUM
echo "SHA256SUM |FILENAME" > CHECKSUM
sha256sum ./steins-zapp/* | sed "s/\.\/steins-zapp\///g" >> CHECKSUM
status ${?} "${success} CHECKSUM successfully generated."
mv CHECKSUM ./steins-zapp
zip -q steins-zapp ./steins-zapp/*
status ${?} "${success} Files successfully ziped."
mv ./steins-zapp.zip ./steins-zapp
status 0 "${info} Everything is done! APK's are into ./steins-zapp. Enjoy your Steins;Zapp!"
status 0 "\e[3m~El Psy Kongroo${normal_text}"