Files
getpkg/dehydrate/build.sh
Your Name 344d62034c
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 7s
Build-Test-Publish / build (linux/arm64) (push) Failing after 7s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped
Update 2 files
2025-06-29 22:45:36 +12:00

52 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Get script directory - handle different execution contexts
if [ -n "${BASH_SOURCE[0]}" ]; then
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
else
SCRIPT_DIR="$( cd "$( dirname "$0" )" &> /dev/null && pwd )"
fi
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
# Debug output for CI
echo "${PROJECT} build script running from: ${SCRIPT_DIR}"
mkdir -p "${SCRIPT_DIR}/build"
mkdir -p "${SCRIPT_DIR}/output"
# Run build in container with mounted directories
COMMAND_TO_RUN="
cmake -G Ninja -S . -B ./build \
-DCMAKE_BUILD_TYPE=\${CMAKE_BUILD_TYPE} \
-DPROJECT_NAME=${PROJECT} && \
cmake --build ./build && \
cp ./build/${PROJECT} ./output/
"
if [ -n "${GITEA_CONTAINER_NAME:-}" ]; then
echo "We're in a gitea container: ${GITEA_CONTAINER_NAME}"
echo "Checking cmake availability..."
which cmake || echo "cmake not found in PATH"
echo "PATH: $PATH"
echo "Sourcing build environment..."
# Source the standard build environment if available
[ -f /etc/profile ] && source /etc/profile
[ -f ~/.bashrc ] && source ~/.bashrc
# Add common binary paths
export PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
cd "${SCRIPT_DIR}" && ls -la . && ${COMMAND_TO_RUN}
else
echo "Building in new docker container"
docker run --rm \
--user "$(id -u):$(id -g)" \
-v "${SCRIPT_DIR}:/app:ro" \
-v "${SCRIPT_DIR}/build:/app/build" \
-v "${SCRIPT_DIR}/output:/app/output" \
-e CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}" \
gitea.jde.nz/public/dropshell-build-base:latest \
bash -c "cd /app &&${COMMAND_TO_RUN}"
fi
echo "Build complete"