diff --git a/dropshell-build/Dockerfile b/dropshell-build/Dockerfile index c254145..f6d7521 100644 --- a/dropshell-build/Dockerfile +++ b/dropshell-build/Dockerfile @@ -9,9 +9,9 @@ RUN apt-get update && apt-get install -y \ #RUN curl -fsSL https://get.docker.com | sh -COPY --chmod=0755 ./src/install_dropshell_build_requirements.sh /usr/local/bin/ -COPY --chmod=0755 ./src/dropshell-build.sh /usr/local/bin/ +COPY --chmod=0755 ./src/*.sh /usr/local/bin/ +RUN /usr/local/bin/pre_download_musl.sh RUN /usr/local/bin/install_dropshell_build_requirements.sh WORKDIR /app diff --git a/dropshell-build/src/install_dropshell_build_requirements.sh b/dropshell-build/src/install_dropshell_build_requirements.sh index 5d9cac5..2f46276 100755 --- a/dropshell-build/src/install_dropshell_build_requirements.sh +++ b/dropshell-build/src/install_dropshell_build_requirements.sh @@ -148,7 +148,6 @@ function install_openssl_musl() { BUILD_DIR="${SCRIPT_DIR}/build" MUSL_CROSS_DIR="$HOME/.musl-cross" mkdir -p "$BUILD_DIR" - # Helper: compare versions (returns 0 if $1 >= $2) version_ge() { [ "$1" = "$2" ] && return 0 @@ -190,6 +189,12 @@ function install_openssl_musl() { AR="$MUSL_PREFIX/bin/${ARCH}-linux-musl-ar" RANLIB="$MUSL_PREFIX/bin/${ARCH}-linux-musl-ranlib" + DEST_PATH="$SYSROOT/usr/lib/libssl.a" + if [ -f "$DEST_PATH" ]; then + echo "OpenSSL $ARCH is already installed" + continue + fi + SKIP_BUILD=0 if [ -f "$SYSROOT/usr/lib/libssl.a" ]; then # Try to extract version from opensslv.h @@ -323,6 +328,8 @@ function main() { install_openssl_musl echo "$VERSION" > "$VERSION_FILE" + + echo "Done" } -main \ No newline at end of file +main "$@" \ No newline at end of file diff --git a/dropshell-build/src/pre_download_musl.sh b/dropshell-build/src/pre_download_musl.sh new file mode 100644 index 0000000..691f641 --- /dev/null +++ b/dropshell-build/src/pre_download_musl.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -euo pipefail + +#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# If the user is not root, use the home directory of the user who ran the script +USER_HOME="$HOME" +if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then + USER_HOME=$(eval echo "~${SUDO_USER}") +fi + +# Set install directory +INSTALL_DIR="$USER_HOME/.musl-cross" +mkdir -p "$INSTALL_DIR" + +TMPDIR=$(mktemp -d) +trap 'rm -rf "$TMPDIR"' EXIT + + +#---------------------------------------------------------------------------------------------------------- +# Main +#---------------------------------------------------------------------------------------------------------- + +function install_musl_cross() { + local TOOLCHAIN="$1" + local MUSL_CC_URL="https://getbin.xyz" + if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then + echo "Downloading $TOOLCHAIN musl cross toolchain..." + wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz:latest" + tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz" + fi +} + +function predownload() { + TOOLCHAIN_LIST=( + "aarch64-linux-musl-cross" + "x86_64-linux-musl-cross" + ) + + for TOOLCHAIN in "${TOOLCHAIN_LIST[@]}"; do + install_musl_cross "$TOOLCHAIN" + done +} + +predownload \ No newline at end of file