From 1e09c5c99530b9efc748691bce53ae02a73ebc31 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 31 May 2025 10:20:39 +1200 Subject: [PATCH] :-'Generic Commit' --- .gitea/workflows/dropshell-build.yaml | 26 +++++++++++ dropshell-build/Dockerfile | 21 +++++++++ dropshell-build/build.sh | 6 +++ dropshell-build/publish.sh | 11 +++++ dropshell-build/{ => src}/dropshell-build.sh | 46 +++++++++++++++---- .../install_dropshell_build_requirements.sh} | 9 ++-- dropshell-build/test.sh | 17 +++++++ dropshell-tool-install.sh | 2 +- publish_all.sh | 2 +- sos/sos | 2 +- 10 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 .gitea/workflows/dropshell-build.yaml create mode 100644 dropshell-build/Dockerfile create mode 100755 dropshell-build/build.sh create mode 100755 dropshell-build/publish.sh rename dropshell-build/{ => src}/dropshell-build.sh (86%) rename dropshell-build/{install_dropshell_build_host.sh => src/install_dropshell_build_requirements.sh} (98%) create mode 100755 dropshell-build/test.sh diff --git a/.gitea/workflows/dropshell-build.yaml b/.gitea/workflows/dropshell-build.yaml new file mode 100644 index 0000000..f0f6b6a --- /dev/null +++ b/.gitea/workflows/dropshell-build.yaml @@ -0,0 +1,26 @@ +name: dropshell-build +run-name: Build test and publish dropshell-build + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: gitea.jde.nz + username: DoesntMatter + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + - name: Build + run: | + ./build.sh + - name: Test + run: | + ./test.sh + - name: Publish + run: | + ./publish.sh diff --git a/dropshell-build/Dockerfile b/dropshell-build/Dockerfile new file mode 100644 index 0000000..33773e0 --- /dev/null +++ b/dropshell-build/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:latest + +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + git \ + nlohmann-json3-dev wget curl cmake ninja-build mold build-essential nodejs npm jq \ + && rm -rf /var/lib/apt/lists/* + +#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/ + +RUN install_dropshell_build_requirements.sh + +WORKDIR /app + +ENTRYPOINT ["dropshell-build.sh","/app"] + + diff --git a/dropshell-build/build.sh b/dropshell-build/build.sh new file mode 100755 index 0000000..273e189 --- /dev/null +++ b/dropshell-build/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -euo pipefail + +docker build -t gitea.jde.nz/public/dropshell-build:latest . + diff --git a/dropshell-build/publish.sh b/dropshell-build/publish.sh new file mode 100755 index 0000000..44ffe2c --- /dev/null +++ b/dropshell-build/publish.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +"${SCRIPT_DIR}/build.sh" + +"${SCRIPT_DIR}/sos/sos" upload "getbin.xyz" "dropshell-tool-install.sh" "${SCRIPT_DIR}/dropshell-tool-install.sh" + +docker push gitea.jde.nz/public/dropshell-build:latest diff --git a/dropshell-build/dropshell-build.sh b/dropshell-build/src/dropshell-build.sh similarity index 86% rename from dropshell-build/dropshell-build.sh rename to dropshell-build/src/dropshell-build.sh index 349151b..08d6730 100755 --- a/dropshell-build/dropshell-build.sh +++ b/dropshell-build/src/dropshell-build.sh @@ -32,7 +32,7 @@ function help() { } function version() { - echo "magicbuild 0.1" + echo "2025.0531.0942" } # ---------------------------------------------------------------------------------------------------------- @@ -162,13 +162,6 @@ function build_arch() { } function build() { - if [ -z "$1" ]; then - help - echo " " - echo "Error: DIR is required" - exit 1 - fi - echo "Building project in directory $1" if [ ! -d "$1" ]; then echo "Directory $1 does not exist" @@ -202,13 +195,39 @@ function build() { fi } +function buildspawn() { + local BUILD_DIR="$1" + if [ -z "$BUILD_DIR" ] || [ ! -d "$BUILD_DIR" ]; then + echo "Error: builddir doesn't exist: $BUILD_DIR" + exit 1 + fi + # make canonical + BUILD_DIR=$(realpath "$BUILD_DIR") + + BUILD_VERSION_FILE="$HOME/.config/dropshell-build/version" + if [ ! -f "$BUILD_VERSION_FILE" ]; then + # check if docker is installed + if ! command -v docker &> /dev/null; then + echo "Neither dropshell-build nor docker appears to be available. Please install one of them." + exit 1 + fi + echo "Using Docker Buildchain." + docker run --rm \ + -u "$(id -u)":"$(id -g)" \ + -v "$BUILD_DIR":/app \ + gitea.jde.nz/public/dropshell-build:latest + else + echo "Using local native buildchain" + build "$BUILD_DIR" + fi +} + # ---------------------------------------------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------------------------------------------- function main() { - while getopts "rm" opt; do case $opt in r) @@ -227,6 +246,13 @@ function main() { # Shift the processed options out of the argument list shift $((OPTIND-1)) + # check we have at least one argument + if [ $# -eq 0 ]; then + help + exit 1 + fi + + # get command argument, now that the flags are set CMD="$1" @@ -241,7 +267,7 @@ function main() { version ;; *) - build "$1" + buildspawn "$1" ;; esac } diff --git a/dropshell-build/install_dropshell_build_host.sh b/dropshell-build/src/install_dropshell_build_requirements.sh similarity index 98% rename from dropshell-build/install_dropshell_build_host.sh rename to dropshell-build/src/install_dropshell_build_requirements.sh index de4e883..5d9cac5 100755 --- a/dropshell-build/install_dropshell_build_host.sh +++ b/dropshell-build/src/install_dropshell_build_requirements.sh @@ -1,10 +1,12 @@ #!/bin/bash set -euo pipefail -set -x SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +VERSION=$(date +%Y.%m%d.%H%M) +VERSION_FILE="$HOME/.config/dropshell-build/version" + # If the user is not root, use sudo SUDOCMD="" [ "$EUID" -eq 0 ] || SUDOCMD="sudo" @@ -281,7 +283,7 @@ function install_musl_cross() { fi } -function installmusl() { +function install_musl() { echo "Installing musl toolchain" # Set install directory @@ -316,10 +318,11 @@ function main() { install_headers - installmusl + install_musl install_openssl_musl + echo "$VERSION" > "$VERSION_FILE" } main \ No newline at end of file diff --git a/dropshell-build/test.sh b/dropshell-build/test.sh new file mode 100755 index 0000000..7db7cde --- /dev/null +++ b/dropshell-build/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +echo "Testing dropshell-build" + +"${SCRIPT_DIR}/build.sh" + +"${SCRIPT_DIR}/src/dropshell-build.sh" ./test + +"${SCRIPT_DIR}/test/output/ipdemo.x86_64" + + + + diff --git a/dropshell-tool-install.sh b/dropshell-tool-install.sh index 3a0f39f..aab31c9 100755 --- a/dropshell-tool-install.sh +++ b/dropshell-tool-install.sh @@ -2,10 +2,10 @@ set -euo pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +echo "wheeeee!" diff --git a/publish_all.sh b/publish_all.sh index 7cafb37..1a5d436 100755 --- a/publish_all.sh +++ b/publish_all.sh @@ -6,7 +6,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # run sos to upload dropshell-tool-install.sh -"${SCRIPT_DIR}/sos/sos" upload "${SCRIPT_DIR}/dropshell-tool-install.sh" "dropshell-tool-install.sh" +"${SCRIPT_DIR}/sos/sos" upload "getbin.xyz" "dropshell-tool-install.sh" "${SCRIPT_DIR}/dropshell-tool-install.sh" # build and publish all dropshell tools diff --git a/sos/sos b/sos/sos index cb9ef49..01e77b9 100755 --- a/sos/sos +++ b/sos/sos @@ -72,7 +72,7 @@ function upload() { METADATA_JSON=$(cat <