Merge branch 'dev' into feature/killswitch

This commit is contained in:
pokamest 2024-01-11 13:45:56 +00:00
commit 65a04799ef
294 changed files with 9840 additions and 85333 deletions

View file

@ -12,13 +12,14 @@ Usage:
Build AmneziaVPN android client. By default, a signed Android App Bundle (AAB) is built.
Options:
-d, --debug Build debug version
-a, --apk <abi> Build APK for the specified ABI
Available ABIs: 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
-p, --platform <platform> The SDK platform used for building the Java code of the application
By default, the latest available platform is used
-m, --move Move the build result to the root of the build directory
-h, --help Display this help
-d, --debug Build debug version
-a, --apk (<abi_list> | all) Build APKs for the specified ABIs or for all available ABIs
Available ABIs: 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
<abi_list> - list of ABIs delimited by ';'
-b, --build-platform <platform> The SDK platform used for building the Java code of the application
By default, the latest available platform is used
-m, --move Move the build result to the root of the build directory
-h, --help Display this help
EOT
}
@ -26,21 +27,25 @@ EOT
BUILD_TYPE="release"
AAB=1
opts=$(getopt -l debug,apk:,platform:,move,help -o "da:p:mh" -- "$@")
opts=$(getopt -l debug,apk:,build-platform:,move,help -o "da:b:mh" -- "$@")
eval set -- "$opts"
while true; do
case "$1" in
-d | --debug) BUILD_TYPE="debug"; shift;;
-a | --apk) ABI=$2; unset AAB; shift 2;;
-p | --platform) ANDROID_PLATFORM=$2; shift 2;;
-a | --apk) ABIS=$2; unset AAB; shift 2;;
-b | --build-platform) ANDROID_BUILD_PLATFORM=$2; shift 2;;
-m | --move) MOVE_RESULT=1; shift;;
-h | --help) usage; exit 0;;
--) shift; break;;
esac
done
if [[ -v ABI && ! "$ABI" =~ ^(x86|x86_64|armeabi-v7a|arm64-v8a)$ ]]; then
echo "The 'abi' option must be one of ['x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'], but is '$ABI'"
# Validate ABIS parameter
if [[ -v ABIS && \
! "$ABIS" = "all" && \
! "$ABIS" =~ ^((x86|x86_64|armeabi-v7a|arm64-v8a);)*(x86|x86_64|armeabi-v7a|arm64-v8a)$ ]]; then
echo "The 'apk' option must be a list of ['x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a']" \
"delimited by ';' or 'all', but is '$ABIS'"
exit 1
fi
@ -56,13 +61,19 @@ OUT_APP_DIR=$BUILD_DIR/client
echo "Project dir: $PROJECT_DIR"
echo "Build dir: $BUILD_DIR"
if [ -v AAB ]; then
# Determine path to qt bin folder with qt-cmake
if [[ -v AAB || "$ABIS" = "all" ]]; then
qt_bin_dir_suffix="x86_64"
else
case $ABI in
if [[ $ABIS = *";"* ]]; then
oneOf=$(echo $ABIS | cut -d';' -f 1)
else
oneOf=$ABIS
fi
case $oneOf in
"armeabi-v7a") qt_bin_dir_suffix="armv7";;
"arm64-v8a") qt_bin_dir_suffix="arm64_v8a";;
*) qt_bin_dir_suffix=$ABI;;
*) qt_bin_dir_suffix=$oneOf;;
esac
fi
# get real path
@ -79,10 +90,10 @@ echo "Using Android NDK in $ANDROID_NDK_ROOT"
# Run qt-cmake to configure build
qt_cmake_opts=()
if [ -v AAB ]; then
if [[ -v AAB || "$ABIS" = "all" ]]; then
qt_cmake_opts+=(-DQT_ANDROID_BUILD_ALL_ABIS=ON)
else
qt_cmake_opts+=(-DQT_ANDROID_ABIS="$ABI")
qt_cmake_opts+=(-DQT_ANDROID_ABIS="$ABIS")
fi
# QT_NO_GLOBAL_APK_TARGET_PART_OF_ALL=ON - Skip building apks as part of the default 'ALL' target
@ -95,7 +106,7 @@ $QT_BIN_DIR/qt-cmake -S $PROJECT_DIR -B $BUILD_DIR \
# Build app
cmake --build $BUILD_DIR --config $BUILD_TYPE
# Build and package APK or AAB. If this is a release, then additionally sign the result.
# Build and package APK or AAB
echo "Building APK/AAB..."
deployqt_opts=()
@ -104,32 +115,52 @@ if [ -v AAB ]; then
deployqt_opts+=(--aab)
fi
if [ -v ANDROID_PLATFORM ]; then
deployqt_opts+=(--android-platform "$ANDROID_PLATFORM")
if [ -v ANDROID_BUILD_PLATFORM ]; then
deployqt_opts+=(--android-platform "$ANDROID_BUILD_PLATFORM")
fi
if [ "$BUILD_TYPE" = "release" ]; then
deployqt_opts+=(--release --sign)
deployqt_opts+=(--release)
fi
# for gradle to skip all tasks when it is executed by androiddeployqt
# gradle is started later explicitly
export ANDROIDDEPLOYQT_RUN=1
$QT_HOST_PATH/bin/androiddeployqt \
--input $OUT_APP_DIR/android-AmneziaVPN-deployment-settings.json \
--output $OUT_APP_DIR/android-build \
--gradle \
"${deployqt_opts[@]}"
# run gradle
gradle_opts=()
if [ -v AAB ]; then
gradle_opts+=(bundle"${BUILD_TYPE^}")
else
gradle_opts+=(assemble"${BUILD_TYPE^}")
fi
$OUT_APP_DIR/android-build/gradlew \
--project-dir $OUT_APP_DIR/android-build \
-DexplicitRun=1 \
"${gradle_opts[@]}"
if [[ -v CI || -v MOVE_RESULT ]]; then
echo "Moving APK/AAB..."
if [ -v AAB ]; then
mv -u $OUT_APP_DIR/android-build/build/outputs/bundle/$BUILD_TYPE/android-build-$BUILD_TYPE.aab \
$PROJECT_DIR/deploy/build/AmneziaVPN-$BUILD_TYPE.aab
mv -u $OUT_APP_DIR/android-build/build/outputs/bundle/$BUILD_TYPE/AmneziaVPN-$BUILD_TYPE.aab \
$PROJECT_DIR/deploy/build/
else
if [ "$BUILD_TYPE" = "release" ]; then
build_suffix="release-signed"
else
build_suffix=$BUILD_TYPE
if [ "$ABIS" = "all" ]; then
ABIS="x86;x86_64;armeabi-v7a;arm64-v8a"
fi
mv -u $OUT_APP_DIR/android-build/build/outputs/apk/$BUILD_TYPE/android-build-$build_suffix.apk \
$PROJECT_DIR/deploy/build/AmneziaVPN-$ABI-$build_suffix.apk
IFS=';' read -r -a abi_array <<< "$ABIS"
for ABI in "${abi_array[@]}"
do
mv -u $OUT_APP_DIR/android-build/build/outputs/apk/$BUILD_TYPE/AmneziaVPN-$ABI-$BUILD_TYPE.apk \
$PROJECT_DIR/deploy/build/
done
fi
fi

View file

@ -146,7 +146,7 @@ if [ "${MAC_CERT_PW+x}" ]; then
fi
echo "Building DMG installer..."
hdiutil create -volname AmneziaVPN -srcfolder $BUILD_DIR/installer/$APP_NAME.app -ov -format UDZO $DMG_FILENAME
hdiutil create -size 120mb -volname AmneziaVPN -srcfolder $BUILD_DIR/installer/$APP_NAME.app -ov -format UDZO $DMG_FILENAME
if [ "${MAC_CERT_PW+x}" ]; then
echo "Signing DMG installer..."

View file

@ -2,7 +2,7 @@
# Mac name-resolution updater based on @cl's script here:
# https://blog.netnerds.net/2011/10/openvpn-update-client-dns-on-mac-os-x-using-from-the-command-line/
# Openvpn envvar parsing taken from the script in debian's openvpn package.
# Openvpn envar parsing taken from the script in debian's openvpn package.
# Smushed together and improved by @andrewgdotcom.
# Parses DHCP options from openvpn to update resolv.conf
@ -10,6 +10,8 @@
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
echo "*** starting update-resolv-config script ***"
[ "$script_type" ] || exit 0
[ "$dev" ] || exit 0
@ -34,11 +36,11 @@ update_all_dns()
echo updating dns for $adapter
# set dns server to the vpn dns server
if [[ "${SRCHS[@]}" ]]; then
networksetup -setsearchdomains "$adapter" "${SRCHS[@]}"
networksetup -setsearchdomains "$adapter" "${SRCHS[@]}"
fi
if [[ "${NMSRVRS[@]}" ]]; then
networksetup -setdnsservers "$adapter" "${NMSRVRS[@]}"
fi
networksetup -setdnsservers "$adapter" "${NMSRVRS[@]}"
fi
done
}
@ -61,7 +63,7 @@ case "$script_type" in
if [ "$part1" = "dhcp-option" ] ; then
if [ "$part2" = "DNS" ] ; then
NMSRVRS=(${NMSRVRS[@]} $part3)
elif [ "$part2" = "DOMAIN" ] ; then
elif [ "$part2" = "DOMAIN" ] || [ "$part2" = "DOMAIN-SEARCH" ]; then
SRCHS=(${SRCHS[@]} $part3)
fi
fi
@ -72,3 +74,5 @@ case "$script_type" in
clear_all_dns
;;
esac
echo "*** finished update-resolv-config script ***"

View file

@ -76,9 +76,7 @@ function raiseInstallerWindow()
function appProcessIsRunning()
{
if (runningOnWindows()) {
var cmdArgs = ["/FI", "WINDOWTITLE eq " + appName()];
var result = installer.execute("tasklist", cmdArgs);
var result = installer.execute("tasklist");
if ( Number(result[1]) === 0 ) {
if (result[0].indexOf(appExecutableFileName()) !== -1) {
return true;