Android build for ungoogled-chromium. https://uc.droidware.info
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.1 KiB
150 lines
5.1 KiB
2 years ago
|
#!/bin/bash
|
||
|
# Modified from Vanadium
|
||
|
|
||
|
set -o errexit -o nounset -o pipefail
|
||
|
|
||
2 years ago
|
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||
|
source "${SCRIPT_PATH}/.build_config"
|
||
2 years ago
|
|
||
2 years ago
|
KEYSTORE=$PWD/../../uc_keystore/uc-release-key.keystore
|
||
|
KEYSTORE_PASS=$PWD/../../uc_keystore/keystore_pass
|
||
1 year ago
|
APKSIGNER=$PWD/third_party/android_sdk/public/build-tools/31.0.0/apksigner
|
||
2 years ago
|
BUNDLETOOL=$PWD/build/android/gyp/bundletool.py
|
||
|
AAPT2=$PWD/third_party/android_build_tools/aapt2/aapt2
|
||
|
|
||
|
# Argument parser from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash/29754866#29754866
|
||
|
# -allow a command to fail with !’s side effect on errexit
|
||
|
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
|
||
|
! getopt --test > /dev/null
|
||
|
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
||
|
echo 'I’m sorry, `getopt --test` failed in this environment.'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
2 years ago
|
OPTIONS=o:a:t:
|
||
|
LONGOPTS=output:,arch:,target:
|
||
2 years ago
|
|
||
|
# -regarding ! and PIPESTATUS see above
|
||
|
# -temporarily store output to be able to check for errors
|
||
|
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
|
||
|
# -pass arguments only via -- "[email protected]" to separate them correctly
|
||
|
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "[email protected]")
|
||
|
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||
|
# e.g. return value is 1
|
||
|
# then getopt has complained about wrong arguments to stdout
|
||
|
exit 2
|
||
|
fi
|
||
|
# read getopt’s output this way to handle the quoting right:
|
||
|
eval set -- "$PARSED"
|
||
|
|
||
|
OUTPUT=- TARGET=-
|
||
|
|
||
|
# now enjoy the options in order and nicely split until we see --
|
||
|
while true; do
|
||
|
case "$1" in
|
||
|
-o|--output)
|
||
|
OUTPUT="$2"
|
||
|
shift 2
|
||
|
;;
|
||
2 years ago
|
-a|--arch)
|
||
|
ARCH="$2"
|
||
|
shift 2
|
||
|
;;
|
||
2 years ago
|
-t|--target)
|
||
|
TARGET="$2"
|
||
|
shift 2
|
||
|
;;
|
||
|
--)
|
||
|
shift
|
||
|
break
|
||
|
;;
|
||
|
*)
|
||
|
echo "Programming error"
|
||
|
exit 3
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
2 years ago
|
if [[ "$ARCH" != "arm64" ]] && [[ "$ARCH" != "arm" ]] && [[ "$ARCH" != "x86" ]]; then
|
||
|
echo "Wrong architecture"
|
||
|
exit 4
|
||
|
fi
|
||
|
|
||
2 years ago
|
if [[ "$TARGET" != "$chrome_modern_target" ]] && [[ "$TARGET" != "$trichrome_chrome_bundle_target" ]] && [[ "$TARGET" != "$trichrome_chrome_64_bundle_target" ]] \
|
||
2 years ago
|
&& [[ "$TARGET" != "$trichrome_chrome_apk_target" ]] && [[ "$TARGET" != "$trichrome_chrome_64_apk_target" ]] \
|
||
|
&& [[ "$TARGET" != "$trichrome_webview_target" ]] && [[ "$TARGET" != "$trichrome_webview_64_target" ]]; then
|
||
2 years ago
|
echo "Wrong target"
|
||
|
exit 4
|
||
|
fi
|
||
|
|
||
|
if [[ ! -d $OUTPUT ]]; then
|
||
|
echo "Output folder doesn't exist"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
case "$TARGET" in
|
||
|
"$chrome_modern_target")
|
||
|
FILENAME="ChromeModernPublic"
|
||
2 years ago
|
FILENAME_OUT="ChromeModernPublic"
|
||
2 years ago
|
;;
|
||
|
"$trichrome_chrome_bundle_target")
|
||
|
FILENAME="TrichromeChrome"
|
||
2 years ago
|
FILENAME_OUT="TrichromeChrome"
|
||
|
;;
|
||
|
"$trichrome_chrome_64_bundle_target")
|
||
|
FILENAME="TrichromeChrome64"
|
||
|
FILENAME_OUT="TrichromeChrome"
|
||
2 years ago
|
;;
|
||
2 years ago
|
"$trichrome_chrome_apk_target")
|
||
|
FILENAME="TrichromeChrome"
|
||
|
FILENAME_OUT="TrichromeChrome"
|
||
|
;;
|
||
2 years ago
|
"$trichrome_chrome_64_apk_target")
|
||
|
FILENAME="TrichromeChrome64"
|
||
|
FILENAME_OUT="TrichromeChrome"
|
||
|
;;
|
||
2 years ago
|
"$trichrome_webview_target")
|
||
|
FILENAME="TrichromeWebView"
|
||
|
FILENAME_OUT="TrichromeWebView"
|
||
|
;;
|
||
|
"$trichrome_webview_64_target")
|
||
|
FILENAME="TrichromeWebView64"
|
||
|
FILENAME_OUT="TrichromeWebView"
|
||
|
;;
|
||
2 years ago
|
*)
|
||
|
echo "Filename parsing error"
|
||
|
exit 3
|
||
|
;;
|
||
|
esac
|
||
|
|
||
2 years ago
|
echo "output: $OUTPUT, arch: $ARCH, target: $TARGET, filename: $FILENAME"
|
||
2 years ago
|
|
||
|
cd $OUTPUT/apks
|
||
|
|
||
|
rm -rf release
|
||
|
mkdir release
|
||
|
cd release
|
||
|
|
||
2 years ago
|
if [[ "$TARGET" != "$trichrome_webview_target" ]] && [[ "$TARGET" != "$trichrome_webview_64_target" ]] \
|
||
|
&& [[ "$TARGET" != "$trichrome_chrome_apk_target" ]] && [[ "$TARGET" != "$trichrome_chrome_64_apk_target" ]]; then
|
||
2 years ago
|
$BUNDLETOOL build-apks --aapt2 $AAPT2 --bundle ../"$FILENAME".aab --output "$FILENAME".apks --mode=universal --ks $KEYSTORE --ks-pass file:$KEYSTORE_PASS --ks-key-alias uc
|
||
|
unzip "$FILENAME".apks universal.apk
|
||
|
mv universal.apk "${FILENAME_OUT}".apk
|
||
|
$APKSIGNER sign --ks $KEYSTORE --ks-pass file:$KEYSTORE_PASS --ks-key-alias uc --in "${FILENAME_OUT}".apk --out "${FILENAME_OUT}".apk
|
||
|
fi
|
||
2 years ago
|
|
||
2 years ago
|
if [[ "$TARGET" == "$trichrome_chrome_bundle_target" ]] || [[ "$TARGET" == "$trichrome_webview_target" ]] || [[ "$TARGET" == "$trichrome_chrome_apk_target" ]]; then
|
||
|
for app in TrichromeLibrary TrichromeWebView TrichromeChrome; do
|
||
2 years ago
|
if [ -f "../${app}.apk" ]; then
|
||
2 years ago
|
$APKSIGNER sign --ks $KEYSTORE --ks-pass file:$KEYSTORE_PASS --ks-key-alias uc --in "../${app}.apk" --out "${app}.apk"
|
||
2 years ago
|
fi
|
||
2 years ago
|
done
|
||
|
fi
|
||
2 years ago
|
if [[ "$TARGET" == "$trichrome_chrome_64_bundle_target" ]] || [[ "$TARGET" == "$trichrome_webview_64_target" ]] || [[ "$TARGET" == "$trichrome_chrome_64_apk_target" ]]; then
|
||
|
for app in TrichromeLibrary TrichromeWebView TrichromeChrome; do
|
||
2 years ago
|
if [ -f "../${app}64.apk" ]; then
|
||
2 years ago
|
$APKSIGNER sign --ks $KEYSTORE --ks-pass file:$KEYSTORE_PASS --ks-key-alias uc --in "../${app}64.apk" --out "${app}.apk"
|
||
2 years ago
|
fi
|
||
2 years ago
|
done
|
||
|
fi
|