From 7f341699c1683da755bd45dad4e98ba1849ed2c7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Jun 2025 23:34:31 +1200 Subject: [PATCH] 'Generic Commit' --- .gitea/workflows/test.yaml | 22 ++++++++++++++----- source/agent-remote/agent-install.sh | 9 +++----- source/{build.sh => build_native.sh} | 13 ++++++++--- source/{multibuild.sh => build_production.sh} | 22 +++++++++---------- source/test.sh | 12 ++++++++++ 5 files changed, 52 insertions(+), 26 deletions(-) rename source/{build.sh => build_native.sh} (77%) rename source/{multibuild.sh => build_production.sh} (60%) create mode 100644 source/test.sh diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index c50395a..1e737dd 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -16,12 +16,24 @@ jobs: run: | cd source ./install_build_prerequisites.sh - - name: Build + - name: Build Native run: | cd source - ./multibuild.sh + ./build_native.sh - name: Test run: | - cd source/output - ./dropshell_x86_64 list - ./dropshell_x86_64 help + cd source + ./test.sh + - name: Build Production + run: | + cd source + ./build_production.sh + - name: Test + run: | + cd source + ./test.sh + - name: Publish + run: | + cd source + ./publish.sh + diff --git a/source/agent-remote/agent-install.sh b/source/agent-remote/agent-install.sh index 4f1e608..d920ea6 100755 --- a/source/agent-remote/agent-install.sh +++ b/source/agent-remote/agent-install.sh @@ -21,16 +21,13 @@ fi _check_required_env_vars "AGENT_PATH" function install_bb64() { - curl -fsSL "https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh" | bash -s -- "$AGENT_PATH" "$(id -u $USER):$(id -g $USER)" - - # test result code from curl - if [ $? -ne 0 ]; then + if ! curl -fsSL "https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh" | \ + bash -s -- "$AGENT_PATH" "$(id -u "$USER"):$(id -g "$USER")"; then _die "Failed to install bb64. Curl returned non-zero exit code." fi # test if bb64 is installed - VER=$("$AGENT_PATH/bb64" -v) - if [ $? -ne 0 ]; then + if ! VER=$("$AGENT_PATH/bb64" -v); then _die "bb64 did not install correctly." fi diff --git a/source/build.sh b/source/build_native.sh similarity index 77% rename from source/build.sh rename to source/build_native.sh index d2a7ebc..3b41057 100755 --- a/source/build.sh +++ b/source/build_native.sh @@ -6,7 +6,14 @@ INSTALL_DIR=${HOME}/.local/bin mkdir -p "${OUTPUT_DIR}" # Exit on error -set -e +set -euo pipefail + +ARCH=$(uname -m) +if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ]; then + echo "Unsupported architecture: $ARCH" + exit 1 +fi + function build_native() { local BUILDDIR=${SCRIPT_DIR}/build/native @@ -16,8 +23,8 @@ function build_native() { mkdir -p "${BUILDDIR}" cd "${SCRIPT_DIR}" || exit 1 - CC="${HOME}/.musl-cross/x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc" - CXX="${HOME}/.musl-cross/x86_64-linux-musl-native/bin/x86_64-linux-musl-g++" + CC="${HOME}/.musl-cross/${ARCH}-linux-musl-native/bin/${ARCH}-linux-musl-gcc" + CXX="${HOME}/.musl-cross/${ARCH}-linux-musl-native/bin/${ARCH}-linux-musl-g++" cmake -B "${BUILDDIR}" -G Ninja \ diff --git a/source/multibuild.sh b/source/build_production.sh similarity index 60% rename from source/multibuild.sh rename to source/build_production.sh index 75a8562..367a03f 100755 --- a/source/multibuild.sh +++ b/source/build_production.sh @@ -1,15 +1,15 @@ #!/bin/bash - +set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # Create output directory -mkdir -p ${SCRIPT_DIR}/output +mkdir -p "${SCRIPT_DIR}/output" +cd "${SCRIPT_DIR}" +trap 'cd "${PREVDIR}"' EXIT function build_arch() { local arch=$1 - local PREVDIR=$PWD - cd ${SCRIPT_DIR} 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." @@ -20,16 +20,14 @@ function build_arch() { 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=${SCRIPT_DIR}/build/${arch} - mkdir -p ${BUILDDIR} + BUILDDIR="${SCRIPT_DIR}/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} + 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 ${SCRIPT_DIR}/output/dropshell.${arch} - - cd ${PREVDIR} + upx "${BUILDDIR}/dropshell" + cp "${BUILDDIR}/dropshell" "${SCRIPT_DIR}/output/dropshell.${arch}" } build_arch x86_64 diff --git a/source/test.sh b/source/test.sh new file mode 100644 index 0000000..b1de7d2 --- /dev/null +++ b/source/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +ARCH=$(uname -m) + +PREV_DIR=$(pwd) +trap 'cd "$PREV_DIR"' EXIT + +"$SCRIPT_DIR/output/dropshell_${ARCH}" list +"$SCRIPT_DIR/output/dropshell_${ARCH}" help +