Files
status-app/mobile/scripts/buildOpenSSL.sh
T
Siddarth Kumar 7afb60d1b9 init: fdroid setup
- `mobile/Makefile` -> Added `apk-fdroid` build target, used by
`fdroid/build-app.sh`. F-Droid requires an unsigned APK without Google
Play services.

  - `mobile/android/qt6/build.gradle` -> Added F-Droid gradle build
flavor, used during `apk-fdroid` target. Separates F-Droid builds from
Play Store builds and no signing configuration since it's supposed to be
unsigned.

  - `mobile/scripts/buildApp.sh` -> Updated to copy F-Droid APK instead
of usual locations from Jenkins build.

  - `mobile/scripts/buildOpenSSL.sh` -> Moved from iOS dir, shared
between iOS and F-Droid builds. Reusing the OpenSSL build logic that was
previously iOS-only but is now needed for F-Droid's from-source
requirement.

  - `mobile/scripts/Common.mk` -> Updated path to `buildOpenSSL.sh`
which is no longer inside iOS dir.

  - `mobile/scripts/openssl-patch.diff` -> Moved from iOS dir, applied
by `buildOpenSSL.sh`, so that the patch is co-located with the script
that uses it.

  - `ci/Jenkinsfile.fdroid` -> Had to make a new pipeline script because
integrating this into `ci/Jenkinsfile.android` was causing issues with
the generated `AppImage` and steps had to be fully sequential, so I
figured it's good to separate them out.

  - `fdroid/entrypoint-fdroid.sh` -> Docker entrypoint, used by
`fdroid/Dockerfile`. Sets up the container user/permissions before the
F-Droid build starts.

  - `fdroid/Dockerfile` -> A minimalistic Docker image for the F-Droid
Jenkins build environment, used by `ci/Jenkinsfile.fdroid`. I didn't add
to existing Qt Android `Dockerfile` because this one only needs a
minimal environment with Docker-in-Docker to run the `fdroidserver` VM.

  - `fdroid/build-app.sh` -> Called by `fdroiddata` metadata build step.
Sets up Qt and Android NDK environment, detects `JAVA_HOME`, configures
`Go`/`Nim` env vars, and runs the `make` targets for the F-Droid APK.

  - `fdroid/build-openssl.sh` -> F-Droid requires OpenSSL to be built
from source rather than using prebuilt binaries.

  - `fdroid/build-qt-android.sh` -> F-Droid requires Qt to be built from
source; this handles the Android cross-compilation.

  - `fdroid/build-qt-host.sh` -> Qt's cross-compilation requires host
tools (`moc`, `rcc`, etc.) to be built first.

  - `fdroid/cleanup-binaries.sh` -> Removes binaries flagged by `fdroid`
scanner, called by `fdroiddata` metadata `prebuild` step. F-Droid's
scanner rejects repos containing prebuilt binaries in test/vendor
directories.

  - `fdroid/cleanup-fdroiddata.sh` -> Removes stale `fdroiddata` clones,
called by `ci/Jenkinsfile.fdroid`. Prevents disk space issues from
accumulating `fdroiddata` clones across builds.

  - `fdroid/fdroid-container-build.sh` -> Runs `fdroid build` inside
Docker container, called by `scripts/fdroid-local-build.sh`. Isolates
the build in a container to match F-Droid's official build environment.

  - `scripts/fdroid-local-build.sh` -> A handy script to build F-Droid
locally, also called by `ci/Jenkinsfile.fdroid`. Manages the full
lifecycle of cloning `fdroiddata`, launching the `fdroidserver`, and
extracting the output APK.

  - `fdroid/generate-keystore.sh` -> Generates a single-use keystore for
signing the F-Droid APK. Sourced by `buildApp.sh` to export signing
credentials into the build environment.

fixes: https://github.com/status-im/status-app/issues/19741
2026-03-14 20:54:15 +05:30

101 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -ef pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPENSSL=${OPENSSL:-"../vendors/openssl"}
OS=${OS:-"ios"}
ARCH=${ARCH:-"x86_64"}
SDK=${SDK:-"iphonesimulator"}
LIB_PATH=${LIB_PATH:-"../lib/ios"}
LIB_EXT=${LIB_EXT:-".a"}
ANDROID_API=${ANDROID_API:-28}
BUILD_DIR=${BUILD_DIR:-"build-${TARGET}"}
TARGET="${OS}-${ARCH}"
SSL_BUILD_DIR=${BUILD_DIR}/openssl-${TARGET}
CRYPTO_OUTPUT_LIB=${LIB_PATH}/libcrypto_3${LIB_EXT}
SSL_OUTPUT_LIB=${LIB_PATH}/libssl_3${LIB_EXT}
PLATFORM_CONFIG_ARGS=()
PLATFORM_BUILD_ARGS=()
if [[ "$OS" == "ios" ]]; then
if [[ "$SDK" == "iphonesimulator" ]]; then
case ${ARCH} in
"x86_64") TARGET="iossimulator-x86_64-xcrun" ;;
"arm64") TARGET="iossimulator-arm64-xcrun" ;;
"x86") TARGET="iossimulator-i386-xcrun" ;;
# default to system architecture
# missing armv7 support for ios simulator
*) TARGET="iossimulator-xcrun" ;;
esac
elif [[ "$SDK" == "iphoneos" ]]; then
case ${ARCH} in
"arm64") TARGET="ios64-xcrun" ;;
*) TARGET="ios-xcrun" ;;
esac
fi
fi
if [[ "$OS" == "android" ]]; then
PLATFORM_CONFIG_ARGS=("-U__ANDROID_API__" "-D__ANDROID_API__=${ANDROID_API}")
PLATFORM_BUILD_ARGS=("SHLIB_VERSION_NUMBER=")
cleanup() {
patch -d "${OPENSSL}" -R -p0 <"${SCRIPT_DIR}/openssl-patch.diff"
}
trap cleanup EXIT
patch -d "${OPENSSL}" -p0 <"${SCRIPT_DIR}/openssl-patch.diff"
fi
echo "Building OpenSSL for $TARGET with platform config args ${PLATFORM_CONFIG_ARGS[*]}"
mkdir -p "${SSL_BUILD_DIR}"
(
cd "${SSL_BUILD_DIR}"
# - no-module: Makes legacy provider built-in to libcrypto (not a separate module)
# - enable-legacy: Enables legacy algorithms including DES
# This is required for GlobalPlatform SCP02 which uses single-DES
# Reference: https://github.com/openssl/openssl/discussions/25793
# Platform-specific config
if [[ "$OS" == "ios" ]]; then
# iOS uses static libraries (.a files)
SHARED_FLAG="no-shared"
else
# Android uses shared libraries (.so files)
SHARED_FLAG="shared"
fi
"${OPENSSL}"/Configure --release "$TARGET" "${PLATFORM_CONFIG_ARGS[@]}" \
no-module \
enable-legacy \
enable-des \
enable-md2 \
enable-rc5 \
"$SHARED_FLAG" \
no-tests \
no-ui-console
# Rebuilding isn't working with the default target, so we need to clean and build again
make clean
make -j$(sysctl -n hw.ncpu) $PLATFORM_BUILD_ARGS build_libs
)
mkdir -p "$LIB_PATH"
# For shared libraries (.so), OpenSSL creates libcrypto_3.so and libssl_3.so
# For static libraries (.a), it creates libcrypto.a and libssl.a
if [[ "$LIB_EXT" == ".so" ]]; then
SRC_CRYPTO="${SSL_BUILD_DIR}/libcrypto_3${LIB_EXT}"
SRC_SSL="${SSL_BUILD_DIR}/libssl_3${LIB_EXT}"
else
SRC_CRYPTO="${SSL_BUILD_DIR}/libcrypto${LIB_EXT}"
SRC_SSL="${SSL_BUILD_DIR}/libssl${LIB_EXT}"
fi
cp "${SRC_CRYPTO}" "$CRYPTO_OUTPUT_LIB"
cp "${SRC_SSL}" "$SSL_OUTPUT_LIB"