This repository has been archived on 2021-11-19. You can view files and clone it, but cannot push or open issues or pull requests.
ctc-patcher/patch.sh

70 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
###################################################
# "THE DRINK-WARE LICENSE" (Revision 42): #
# #
# As long as you retain this notice you can #
# do whatever you want with this stuff. #
# If we meet some day, and you think this stuff #
# is worth it, you can buy me a drink in return. #
# #
# -- Observer of Time <chronobserver@disroot.org> #
###################################################
set -euo pipefail
trap 'exit 130' INT
: "$KEYSTORE_PATH" "$KEYSTORE_ALIAS" "$VERCODE" "$COMMIT_HASH"
_dab() (curl --progress-bar -Lf "https://gitdab.com/distok/$1/archive/$2.tar.gz")
printf 'Downloading Discord...\n'
_dab apkfuckery "$COMMIT_HASH" | tar xzf - --strip-components=1
printf 'Downloading CutTheCord...\n'
_dab cutthecord master | tar xzf -
printf 'Editing patches...\n'
sed -i cutthecord/patches/squareavatars/"$VERCODE".patch -e 's/3dp/5dp/'
sed -i cutthecord/patches/branding/"$VERCODE".patch \
-e 's/CTCNAME/Discord (CTC)/g;s/CTCBRANCH/chronobserver/g' \
-e "s/-CTCBUILD/-$(date --iso-8601)/g;s/CTCBUILD//g"
sed -i cutthecord/patches/branding/customicon.sh -e 's/#rm/rm/'
for p in necessary noblocked nocamerabutton squareavatars branding customversion; do
printf 'Applying %s patch...\n' "$p"
patch -d com.discord -p1 < "cutthecord/patches/$p/$VERCODE.patch"
done
printf 'Replacing files...\n'
pushd com.discord >/dev/null
bash ../cutthecord/patches/branding/customicon.sh
bash ../cutthecord/patches/branding/customdynamicicon.sh
bash ../cutthecord/patches/bettertm/bettertm.sh ../cutthecord/patches/bettertm
popd >/dev/null
curl -LSsfo com.discord/res/font/whitney_semibold.ttf \
https://github.com/google/fonts/raw/master/ofl/asap/Asap-Medium.ttf
curl -LSsfo com.discord/res/font/whitney_bold.ttf \
https://github.com/google/fonts/raw/master/ofl/asap/Asap-SemiBold.ttf
curl -LSsfo com.discord/res/font/whitney_medium.ttf \
https://github.com/google/fonts/raw/master/ofl/asap/Asap-Regular.ttf
curl -LSsfo com.discord/res/font/sourcecodepro_semibold.ttf \
https://github.com/thiagolucio/code-editor-fonts/raw/master/Hasklig.ttf/Hasklig-Medium.ttf
apktool b com.discord
while ! jarsigner -keystore "$KEYSTORE_PATH" \
"com.discord/dist/com.discord-$VERCODE.apk" "$KEYSTORE_ALIAS"
do :; done
if [[ -z ${SKIP_INSTALL+x} ]]; then
adb install -r "com.discord/dist/com.discord-$VERCODE.apk"
rm -rf com.discord/ cutthecord/
fi