From 3dc82c682c95af31e6b8eabb30d4eb7ee90ffc43 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 May 2025 22:21:39 +1200 Subject: [PATCH] dropshell release 2025.0526.2221 --- install.sh | 4 +-- source/Dockerfile | 30 ++++++++++++++++++++--- source/build_static.sh | 35 --------------------------- source/install_build_prerequisites.sh | 2 +- source/multibuild.sh | 33 +++++++++++++++++++++++++ source/publish.sh | 18 ++++++++------ 6 files changed, 73 insertions(+), 49 deletions(-) delete mode 100755 source/build_static.sh create mode 100755 source/multibuild.sh diff --git a/install.sh b/install.sh index a54577b..7cafff5 100755 --- a/install.sh +++ b/install.sh @@ -8,9 +8,9 @@ set -e ARCH=$(uname -m) if [[ "$ARCH" == "x86_64" ]]; then - BIN=dropshell.amd64 + BIN=dropshell.x86_64 elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then - BIN=dropshell.arm64 + BIN=dropshell.aarch64 else echo "Unsupported architecture: $ARCH" >&2 exit 1 diff --git a/source/Dockerfile b/source/Dockerfile index f8d0f31..4d4b3b5 100644 --- a/source/Dockerfile +++ b/source/Dockerfile @@ -17,6 +17,14 @@ RUN apk add --no-cache \ ninja \ linux-headers +# Install cross-compilation tools for ARM64 +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + apk add --no-cache \ + crossbuild-essential-arm64 \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu; \ + fi + # Set working directory WORKDIR /build @@ -26,13 +34,29 @@ COPY . . # Configure and build RUN mkdir -p build_static +# Set up cross-compilation environment for ARM64 +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + export CC=aarch64-linux-gnu-gcc \ + export CXX=aarch64-linux-gnu-g++ \ + export CMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake; \ + fi + +# Create toolchain file for ARM64 +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + echo "set(CMAKE_SYSTEM_NAME Linux)" > toolchain.cmake && \ + echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake && \ + echo "set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)" >> toolchain.cmake && \ + echo "set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)" >> toolchain.cmake && \ + echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> toolchain.cmake && \ + echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> toolchain.cmake && \ + echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> toolchain.cmake; \ + fi + RUN cmake -G Ninja -B build_static -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER=gcc \ - -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_EXE_LINKER_FLAGS="-static" \ -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_SYSTEM_PROCESSOR=${TARGETPLATFORM#linux/} + ${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE} RUN cmake --build build_static diff --git a/source/build_static.sh b/source/build_static.sh deleted file mode 100755 index 5807935..0000000 --- a/source/build_static.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# Create output directory -mkdir -p output - -# Create and use a new builder instance -docker buildx create --name multiarch-builder --use || true - -# Build for amd64 -docker buildx build --platform linux/amd64 \ - --build-arg TARGETPLATFORM=linux/amd64 \ - --build-arg BUILDPLATFORM=linux/amd64 \ - --tag dropshell-static-builder \ - --output type=local,dest=./output/amd64 \ - --target dropshell \ - . - -# Build for arm64 -docker buildx build --platform linux/arm64 \ - --build-arg TARGETPLATFORM=linux/arm64 \ - --build-arg BUILDPLATFORM=linux/amd64 \ - --tag dropshell-static-builder \ - --output type=local,dest=./output/arm64 \ - --target dropshell \ - . - -# Move the binaries to the output directory with architecture-specific names -cp output/amd64/dropshell output/dropshell.amd64 -cp output/arm64/dropshell output/dropshell.arm64 - -# Clean up intermediate directories -rm -rf output/amd64 output/arm64 - -echo "Static binaries have been created:" -ls -la output diff --git a/source/install_build_prerequisites.sh b/source/install_build_prerequisites.sh index 2e6ed3a..8cf06e5 100755 --- a/source/install_build_prerequisites.sh +++ b/source/install_build_prerequisites.sh @@ -41,7 +41,7 @@ print_status "Detected OS: $OS $VER" case $OS in "Ubuntu"|"Debian GNU/Linux") # Common packages for both Ubuntu and Debian - PACKAGES="cmake make g++ devscripts debhelper" + PACKAGES="cmake make g++ devscripts debhelper build-essential upx" ;; *) print_error "Unsupported distribution: $OS" diff --git a/source/multibuild.sh b/source/multibuild.sh new file mode 100755 index 0000000..b58d31c --- /dev/null +++ b/source/multibuild.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Create output directory +mkdir -p output + + +function build_arch() { + local arch=$1 + + if [ ! -f "${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-c++" ]; then + echo "Musl cross compiler for ${arch} not found. Please run install_build_prerequisites.sh first." + exit 1 + fi + + CMAKE_BUILD_TYPE=Release + CC="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-gcc" + CXX="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-g++" + + BUILDDIR=build/${arch} + mkdir -p ${BUILDDIR} + + cmake -B ${BUILDDIR} -G Ninja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} + cmake --build ${BUILDDIR} + + upx ${BUILDDIR}/dropshell + cp ${BUILDDIR}/dropshell output/dropshell.${arch} +} + +build_arch x86_64 +build_arch aarch64 + +echo "Static binaries have been created:" +ls -la output diff --git a/source/publish.sh b/source/publish.sh index 63b78d5..8fef792 100755 --- a/source/publish.sh +++ b/source/publish.sh @@ -8,10 +8,12 @@ echo "Script directory: $SCRIPT_DIR" # Check for GITEA_TOKEN_DEPLOY or GITEA_TOKEN if [ -n "$GITEA_TOKEN_DEPLOY" ]; then TOKEN="$GITEA_TOKEN_DEPLOY" + echo "Using GITEA_TOKEN_DEPLOY" elif [ -n "$GITEA_TOKEN" ]; then TOKEN="$GITEA_TOKEN" + echo "Using GITEA_TOKEN" else - echo "GITEA_TOKEN_DEPLOY or GITEA_TOKEN environment variable not set!" >&2 + echo "Neither GITEA_TOKEN_DEPLOY nor GITEA_TOKEN environment variable set!" >&2 exit 1 fi @@ -22,20 +24,20 @@ OLD_PWD=$PWD cd $SCRIPT_DIR -if [ ! -f "output/dropshell.amd64" ]; then - echo "output/dropshell.amd64 not found!" >&2 +if [ ! -f "output/dropshell.x86_64" ]; then + echo "output/dropshell.x86_64 not found!" >&2 echo "Please run multibuild.sh first." >&2 exit 1 fi -if [ ! -f "output/dropshell.arm64" ]; then - echo "output/dropshell.arm64 not found!" >&2 +if [ ! -f "output/dropshell.aarch64" ]; then + echo "output/dropshell.aarch64 not found!" >&2 echo "Please run multibuild.sh first." >&2 exit 1 fi -TAG=$("$SCRIPT_DIR/output/dropshell.amd64" --version) -[ -z "$TAG" ] && echo "Failed to get version from dropshell.amd64" >&2 && exit 1 +TAG=$("$SCRIPT_DIR/output/dropshell.x86_64" --version) +[ -z "$TAG" ] && echo "Failed to get version from dropshell.x86_64" >&2 && exit 1 echo "Publishing dropshell version $TAG" @@ -81,7 +83,7 @@ if [ -z "$RELEASE_ID" ]; then fi # Upload binaries and install.sh -for FILE in dropshell.amd64 dropshell.arm64 install.sh server_autosetup.sh; do +for FILE in dropshell.x86_64 dropshell.aarch64 install.sh server_autosetup.sh; do if [ -f "output/$FILE" ]; then filetoupload="output/$FILE" elif [ -f "../$FILE" ]; then