Compare commits
33 Commits
v2025.0629
...
main
Author | SHA1 | Date | |
---|---|---|---|
4badce0ed4 | |||
fe83fc3d64 | |||
7149b8714e | |||
af95d27964 | |||
3eb78acf70 | |||
3d21d1da7d | |||
344d62034c | |||
78e41214d7 | |||
512ba200c2 | |||
5f04bd23a1 | |||
67bb7f747f | |||
e55fe1a17c | |||
2f056b8500 | |||
fe3c5d2ad9 | |||
2ab38fd053 | |||
9dda4e1649 | |||
d8883c4419 | |||
4c4257eebe | |||
4bb85c63b8 | |||
e5f3569b2a | |||
de200a5bb6 | |||
0f1cfdcc28 | |||
7f937c1090 | |||
d7964d3a78 | |||
719475e29f | |||
70cb5c1b3a | |||
facc6b73b0 | |||
9a24576e37 | |||
3f68f44e3d | |||
dbe88a7121 | |||
00d1e86157 | |||
3388a46bf3 | |||
0f5421630a |
@ -26,7 +26,10 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
||||||
- name: Build Test Publish All
|
- name: Build Test Publish All
|
||||||
run: |
|
run: |
|
||||||
SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} RELEASE_WRITE_TOKEN=${{ secrets.RELEASE_WRITE_TOKEN }} ./buildtestpublish_all.sh
|
SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} \
|
||||||
|
RELEASE_WRITE_TOKEN=${{ secrets.RELEASE_WRITE_TOKEN }} \
|
||||||
|
GITEA_CONTAINER_NAME=${{ env.JOB_CONTAINER_NAME }} \
|
||||||
|
./buildtestpublish_all.sh
|
||||||
|
|
||||||
test-install-from-scratch:
|
test-install-from-scratch:
|
||||||
needs: [build]
|
needs: [build]
|
||||||
|
@ -13,7 +13,14 @@ mkdir -p "${SCRIPT_DIR}/output"
|
|||||||
# make sure we have the latest base image.
|
# make sure we have the latest base image.
|
||||||
docker pull gitea.jde.nz/public/dropshell-build-base:latest
|
docker pull gitea.jde.nz/public/dropshell-build-base:latest
|
||||||
|
|
||||||
|
# Build with or without cache based on NO_CACHE environment variable
|
||||||
|
CACHE_FLAG=""
|
||||||
|
if [ "${NO_CACHE:-false}" = "true" ]; then
|
||||||
|
CACHE_FLAG="--no-cache"
|
||||||
|
fi
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
|
${CACHE_FLAG} \
|
||||||
-t "${PROJECT}-build" \
|
-t "${PROJECT}-build" \
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
--build-arg PROJECT="${PROJECT}" \
|
||||||
|
24
bb64/clean.sh
Executable file
24
bb64/clean.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="bb64"
|
||||||
|
|
||||||
|
echo "Cleaning ${PROJECT}..."
|
||||||
|
|
||||||
|
# Remove output directory
|
||||||
|
if [ -d "${SCRIPT_DIR}/output" ]; then
|
||||||
|
echo "Removing output directory..."
|
||||||
|
rm -rf "${SCRIPT_DIR}/output"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove Docker images related to this project
|
||||||
|
echo "Removing Docker images..."
|
||||||
|
docker images --filter "reference=${PROJECT}-build*" -q | xargs -r docker rmi -f
|
||||||
|
|
||||||
|
# Remove Docker build cache
|
||||||
|
echo "Pruning Docker build cache..."
|
||||||
|
docker builder prune -f
|
||||||
|
|
||||||
|
echo "✓ ${PROJECT} cleaned successfully"
|
@ -20,7 +20,14 @@ echo "Building version $VERSION" >&2
|
|||||||
# build release version
|
# build release version
|
||||||
export CMAKE_BUILD_TYPE="Release"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
|
|
||||||
|
# Build with or without cache based on NO_CACHE environment variable
|
||||||
|
CACHE_FLAG=""
|
||||||
|
if [ "${NO_CACHE:-false}" = "true" ]; then
|
||||||
|
CACHE_FLAG="--no-cache"
|
||||||
|
fi
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
|
${CACHE_FLAG} \
|
||||||
-t "${PROJECT}-build" \
|
-t "${PROJECT}-build" \
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
--build-arg PROJECT="${PROJECT}" \
|
||||||
@ -84,9 +91,11 @@ if git rev-parse "$TAG" >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if tag exists on remote
|
# Check if tag exists on remote
|
||||||
|
TAG_EXISTS_ON_REMOTE=false
|
||||||
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
|
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
|
||||||
echo "Tag $TAG already exists on remote - this is expected for multi-architecture builds"
|
echo "Tag $TAG already exists on remote - this is expected for multi-architecture builds"
|
||||||
echo "Skipping tag creation and proceeding with release attachment..."
|
echo "Skipping tag creation and proceeding with release attachment..."
|
||||||
|
TAG_EXISTS_ON_REMOTE=true
|
||||||
else
|
else
|
||||||
echo "Creating new tag $TAG..."
|
echo "Creating new tag $TAG..."
|
||||||
git tag -a "$TAG" -m "Release $TAG"
|
git tag -a "$TAG" -m "Release $TAG"
|
||||||
@ -105,12 +114,20 @@ echo "Getting or creating release $TAG on Gitea..."
|
|||||||
EXISTING_RELEASE=$(curl -s -X GET "$API_URL/releases/tags/$TAG" \
|
EXISTING_RELEASE=$(curl -s -X GET "$API_URL/releases/tags/$TAG" \
|
||||||
-H "Authorization: token $RELEASE_WRITE_TOKEN")
|
-H "Authorization: token $RELEASE_WRITE_TOKEN")
|
||||||
|
|
||||||
|
echo "Existing release check response: $EXISTING_RELEASE" >&2
|
||||||
|
|
||||||
if echo "$EXISTING_RELEASE" | grep -q '"id":[0-9]*'; then
|
if echo "$EXISTING_RELEASE" | grep -q '"id":[0-9]*'; then
|
||||||
# Release already exists, get its ID
|
# Release already exists, get its ID
|
||||||
RELEASE_ID=$(echo "$EXISTING_RELEASE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
RELEASE_ID=$(echo "$EXISTING_RELEASE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
echo "Release $TAG already exists with ID: $RELEASE_ID"
|
echo "Release $TAG already exists with ID: $RELEASE_ID"
|
||||||
else
|
else
|
||||||
# Create new release
|
# Create new release only if tag was just created
|
||||||
|
if [ "$TAG_EXISTS_ON_REMOTE" = true ]; then
|
||||||
|
echo "Tag exists on remote but no release found - this shouldn't happen" >&2
|
||||||
|
echo "API response was: $EXISTING_RELEASE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Creating new release $TAG on Gitea..."
|
echo "Creating new release $TAG on Gitea..."
|
||||||
RELEASE_RESPONSE=$(curl -s -X POST "$API_URL/releases" \
|
RELEASE_RESPONSE=$(curl -s -X POST "$API_URL/releases" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
set -uo pipefail # Remove -e to handle errors manually
|
set -uo pipefail # Remove -e to handle errors manually
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
docker builder prune -f
|
|
||||||
|
|
||||||
|
|
||||||
# Colors for output
|
# Colors for output
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
@ -112,7 +109,7 @@ function buildtestpublish() {
|
|||||||
# Add to projects list
|
# Add to projects list
|
||||||
PROJECTS+=("$TOOLNAME")
|
PROJECTS+=("$TOOLNAME")
|
||||||
|
|
||||||
cd "$dir" || echo "Failed to cd to $dir"
|
#cd "$dir" || echo "Failed to cd to $dir"
|
||||||
|
|
||||||
subtitle "🔨 BUILDING $TOOLNAME_UPPER 🔨"
|
subtitle "🔨 BUILDING $TOOLNAME_UPPER 🔨"
|
||||||
if dothis build "$dir" "$TOOLNAME"; then
|
if dothis build "$dir" "$TOOLNAME"; then
|
||||||
@ -237,15 +234,17 @@ function print_summary() {
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
title "🔨 BUILDING ALL TOOLS 🔨"
|
title "🔨 BUILDING GETPKG 🔨"
|
||||||
|
|
||||||
getpkg/build.sh
|
"${SCRIPT_DIR}/getpkg/build.sh"
|
||||||
export GETPKG="${SCRIPT_DIR}/getpkg/output/getpkg"
|
export GETPKG="${SCRIPT_DIR}/getpkg/output/getpkg"
|
||||||
if [ ! -f "$GETPKG" ]; then
|
if [ ! -f "$GETPKG" ]; then
|
||||||
echo "Build failed."
|
echo "Build failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
title "🔨 BUILDING ALL TOOLS 🔨"
|
||||||
|
|
||||||
buildtestpublish_all
|
buildtestpublish_all
|
||||||
|
|
||||||
print_summary
|
print_summary
|
||||||
|
44
clean.sh
Executable file
44
clean.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
echo "🧹 CLEANING ALL PROJECTS 🧹"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Get all project directories
|
||||||
|
PROJECT_DIRS=$(find "$SCRIPT_DIR" -maxdepth 1 -type d \
|
||||||
|
-not -name ".*" \
|
||||||
|
-not -path "$SCRIPT_DIR" | sort)
|
||||||
|
|
||||||
|
for dir in $PROJECT_DIRS; do
|
||||||
|
PROJECT_NAME=$(basename "$dir")
|
||||||
|
|
||||||
|
if [ -f "$dir/clean.sh" ]; then
|
||||||
|
echo "Cleaning $PROJECT_NAME..."
|
||||||
|
cd "$dir"
|
||||||
|
./clean.sh
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo "⚠️ No clean.sh found for $PROJECT_NAME, skipping..."
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Global Docker cleanup
|
||||||
|
echo "🐳 Global Docker cleanup..."
|
||||||
|
echo "Removing unused Docker images..."
|
||||||
|
docker image prune -f
|
||||||
|
|
||||||
|
echo "Removing unused Docker containers..."
|
||||||
|
docker container prune -f
|
||||||
|
|
||||||
|
echo "Removing unused Docker networks..."
|
||||||
|
docker network prune -f
|
||||||
|
|
||||||
|
echo "Removing unused Docker volumes..."
|
||||||
|
docker volume prune -f
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "✅ All projects cleaned successfully!"
|
@ -1,65 +0,0 @@
|
|||||||
ARG IMAGE_TAG
|
|
||||||
FROM gitea.jde.nz/public/dropshell-build-base:latest AS builder
|
|
||||||
|
|
||||||
ARG PROJECT
|
|
||||||
ARG CMAKE_BUILD_TYPE=Debug
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
|
||||||
|
|
||||||
# Create cache directories
|
|
||||||
RUN mkdir -p /ccache
|
|
||||||
|
|
||||||
# Set up ccache
|
|
||||||
ENV CCACHE_DIR=/ccache
|
|
||||||
ENV CCACHE_COMPILERCHECK=content
|
|
||||||
ENV CCACHE_MAXSIZE=2G
|
|
||||||
|
|
||||||
# Copy build files
|
|
||||||
COPY CMakeLists.txt ./
|
|
||||||
COPY src/version.hpp.in src/
|
|
||||||
|
|
||||||
# Copy source files
|
|
||||||
COPY src/ src/
|
|
||||||
COPY contrib/ contrib/
|
|
||||||
|
|
||||||
# Configure project
|
|
||||||
RUN --mount=type=cache,target=/ccache \
|
|
||||||
--mount=type=cache,target=/build \
|
|
||||||
mkdir -p /build && \
|
|
||||||
cmake -G Ninja -S /app -B /build \
|
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
|
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold -static -g" \
|
|
||||||
-DCMAKE_CXX_FLAGS="-g -fno-omit-frame-pointer" \
|
|
||||||
-DCMAKE_C_FLAGS="-g -fno-omit-frame-pointer" \
|
|
||||||
-DPROJECT_NAME="${PROJECT}" \
|
|
||||||
-DCMAKE_STRIP=OFF \
|
|
||||||
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
|
||||||
|
|
||||||
# Build project
|
|
||||||
RUN --mount=type=cache,target=/ccache \
|
|
||||||
--mount=type=cache,target=/build \
|
|
||||||
cmake --build /build
|
|
||||||
|
|
||||||
# Copy the built executable to a regular directory for the final stage
|
|
||||||
RUN --mount=type=cache,target=/build \
|
|
||||||
mkdir -p /output && \
|
|
||||||
find /build -type f -executable -name "*${PROJECT}*" -exec cp {} /output/${PROJECT} \; || \
|
|
||||||
find /build -type f -executable -exec cp {} /output/${PROJECT} \;
|
|
||||||
|
|
||||||
# if we're a release build, then run upx on the binary.
|
|
||||||
RUN if [ "${CMAKE_BUILD_TYPE}" = "Release" ]; then \
|
|
||||||
upx /output/${PROJECT}; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Final stage that only contains the binary
|
|
||||||
FROM scratch AS project
|
|
||||||
|
|
||||||
ARG PROJECT
|
|
||||||
|
|
||||||
# Copy the actual binary from the regular directory
|
|
||||||
COPY --from=builder /output/${PROJECT} /${PROJECT}
|
|
@ -1,22 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Get script directory - handle different execution contexts
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
PROJECT="dehydrate"
|
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
|
||||||
|
|
||||||
export CMAKE_BUILD_TYPE="Debug"
|
# Debug output for CI
|
||||||
|
echo "${PROJECT} build script running from: ${SCRIPT_DIR}"
|
||||||
|
|
||||||
rm -rf "${SCRIPT_DIR}/output"
|
# Run build in container with mounted directories
|
||||||
mkdir -p "${SCRIPT_DIR}/output"
|
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/"
|
||||||
|
|
||||||
# make sure we have the latest base image.
|
echo "Building in new docker container"
|
||||||
docker pull gitea.jde.nz/public/dropshell-build-base:latest
|
docker run --rm \
|
||||||
|
--user "$(id -u):$(id -g)" \
|
||||||
|
-v "${SCRIPT_DIR}:/app" \
|
||||||
|
-e CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}" \
|
||||||
|
gitea.jde.nz/public/dropshell-build-base:latest \
|
||||||
|
bash -c "cd /app && ${COMMAND_TO_RUN}"
|
||||||
|
|
||||||
docker build \
|
echo "Build complete"
|
||||||
-t "${PROJECT}-build" \
|
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
|
||||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
|
||||||
--output "${SCRIPT_DIR}/output" \
|
|
||||||
"${SCRIPT_DIR}"
|
|
||||||
|
18
dehydrate/clean.sh
Executable file
18
dehydrate/clean.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
|
||||||
|
|
||||||
|
echo "Cleaning ${PROJECT}..."
|
||||||
|
|
||||||
|
# Remove output and build directories
|
||||||
|
for dir in "output" "build"; do
|
||||||
|
if [ -d "${SCRIPT_DIR}/${dir}" ]; then
|
||||||
|
echo "Removing ${dir} directory..."
|
||||||
|
rm -rf "${SCRIPT_DIR:?}/${dir}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✓ ${PROJECT} cleaned successfully"
|
@ -35,14 +35,7 @@ heading "Building ${PROJECT}"
|
|||||||
|
|
||||||
# build release version
|
# build release version
|
||||||
export CMAKE_BUILD_TYPE="Release"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
|
"${SCRIPT_DIR}/build.sh"
|
||||||
docker build \
|
|
||||||
-t "${PROJECT}-build" \
|
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
|
||||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
|
||||||
--output "${OUTPUT}" \
|
|
||||||
"${SCRIPT_DIR}"
|
|
||||||
|
|
||||||
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
PROJECT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
|
PROJECT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
|
||||||
|
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
|
||||||
# Clean up old test data and any existing binaries
|
# Clean up old test data and any existing binaries
|
||||||
# Force removal with chmod to handle permission issues
|
# Force removal with chmod to handle permission issues
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
ARG IMAGE_TAG
|
|
||||||
FROM gitea.jde.nz/public/dropshell-build-base:latest AS builder
|
|
||||||
|
|
||||||
ARG PROJECT
|
|
||||||
ARG CMAKE_BUILD_TYPE=Debug
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
|
||||||
|
|
||||||
# Create cache directories
|
|
||||||
RUN mkdir -p /ccache
|
|
||||||
|
|
||||||
# Set up ccache
|
|
||||||
ENV CCACHE_DIR=/ccache
|
|
||||||
ENV CCACHE_COMPILERCHECK=content
|
|
||||||
ENV CCACHE_MAXSIZE=2G
|
|
||||||
|
|
||||||
# Copy only build files first (for better layer caching)
|
|
||||||
COPY CMakeLists.txt cmake_prebuild.sh ./
|
|
||||||
COPY src/version.hpp.in src/
|
|
||||||
|
|
||||||
# Run prebuild script early (this rarely changes)
|
|
||||||
RUN bash cmake_prebuild.sh
|
|
||||||
|
|
||||||
# Copy source files (this invalidates cache when source changes)
|
|
||||||
COPY src/ src/
|
|
||||||
|
|
||||||
# Configure project (this step is cached unless CMakeLists.txt changes)
|
|
||||||
RUN --mount=type=cache,target=/ccache \
|
|
||||||
--mount=type=cache,target=/build \
|
|
||||||
mkdir -p /build && \
|
|
||||||
SSL_LIB=$(find /usr/local -name "libssl.a" | head -1) && \
|
|
||||||
CRYPTO_LIB=$(find /usr/local -name "libcrypto.a" | head -1) && \
|
|
||||||
echo "Found SSL: $SSL_LIB, Crypto: $CRYPTO_LIB" && \
|
|
||||||
cmake -G Ninja -S /app -B /build \
|
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
|
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold -static -g" \
|
|
||||||
-DCMAKE_CXX_FLAGS="-g -fno-omit-frame-pointer" \
|
|
||||||
-DCMAKE_C_FLAGS="-g -fno-omit-frame-pointer" \
|
|
||||||
-DPROJECT_NAME="${PROJECT}" \
|
|
||||||
-DCMAKE_STRIP=OFF \
|
|
||||||
-DOPENSSL_SSL_LIBRARY="$SSL_LIB" \
|
|
||||||
-DOPENSSL_CRYPTO_LIBRARY="$CRYPTO_LIB" \
|
|
||||||
-DOPENSSL_INCLUDE_DIR=/usr/local/include \
|
|
||||||
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
|
||||||
|
|
||||||
# Run prebuild script
|
|
||||||
RUN --mount=type=cache,target=/ccache \
|
|
||||||
--mount=type=cache,target=/build \
|
|
||||||
cmake --build /build --target run_prebuild_script
|
|
||||||
|
|
||||||
# Build project (ccache will help here when only some files change)
|
|
||||||
RUN --mount=type=cache,target=/ccache \
|
|
||||||
--mount=type=cache,target=/build \
|
|
||||||
cmake --build /build
|
|
||||||
|
|
||||||
# Copy the built executable to a regular directory for the final stage
|
|
||||||
RUN --mount=type=cache,target=/build \
|
|
||||||
mkdir -p /output && \
|
|
||||||
find /build -type f -executable -name "*${PROJECT}*" -exec cp {} /output/${PROJECT} \; || \
|
|
||||||
find /build -type f -executable -exec cp {} /output/${PROJECT} \;
|
|
||||||
|
|
||||||
|
|
||||||
# if we're a release build, then run upx on the binary.
|
|
||||||
RUN if [ "${CMAKE_BUILD_TYPE}" = "Release" ]; then \
|
|
||||||
upx /output/${PROJECT}; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Final stage that only contains the binary
|
|
||||||
FROM scratch AS project
|
|
||||||
|
|
||||||
ARG PROJECT
|
|
||||||
|
|
||||||
# Copy CA certificates for SSL validation
|
|
||||||
#COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs/
|
|
||||||
|
|
||||||
# Copy the actual binary from the regular directory
|
|
||||||
COPY --from=builder /output/${PROJECT} /${PROJECT}
|
|
||||||
|
|
@ -1,25 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Get script directory - handle different execution contexts
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
|
||||||
|
|
||||||
|
# Debug output for CI
|
||||||
|
echo "${PROJECT} build script running from: ${SCRIPT_DIR}"
|
||||||
|
|
||||||
export CMAKE_BUILD_TYPE="Debug"
|
# 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/"
|
||||||
|
|
||||||
rm -rf "${SCRIPT_DIR}/output"
|
echo "Building in new docker container"
|
||||||
mkdir -p "${SCRIPT_DIR}/output"
|
docker run --rm \
|
||||||
|
--user "$(id -u):$(id -g)" \
|
||||||
PROJECT="getpkg"
|
-v "${SCRIPT_DIR}:/app" \
|
||||||
|
-e CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}" \
|
||||||
# make sure we have the latest base image.
|
gitea.jde.nz/public/dropshell-build-base:latest \
|
||||||
docker pull gitea.jde.nz/public/dropshell-build-base:latest
|
bash -c "cd /app && ${COMMAND_TO_RUN}"
|
||||||
|
|
||||||
docker build \
|
|
||||||
-t "${PROJECT}-build" \
|
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
|
||||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
|
||||||
--output "${SCRIPT_DIR}/output" \
|
|
||||||
"${SCRIPT_DIR}"
|
|
||||||
|
|
||||||
|
echo "Build complete"
|
||||||
|
18
getpkg/clean.sh
Executable file
18
getpkg/clean.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
|
||||||
|
|
||||||
|
echo "Cleaning ${PROJECT}..."
|
||||||
|
|
||||||
|
# Remove output and build directories
|
||||||
|
for dir in "output" "build"; do
|
||||||
|
if [ -d "${SCRIPT_DIR}/${dir}" ]; then
|
||||||
|
echo "Removing ${dir} directory..."
|
||||||
|
rm -rf "${SCRIPT_DIR:?}/${dir}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✓ ${PROJECT} cleaned successfully"
|
@ -34,15 +34,7 @@ heading "Building ${PROJECT}"
|
|||||||
|
|
||||||
# build release version
|
# build release version
|
||||||
export CMAKE_BUILD_TYPE="Release"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
|
"${SCRIPT_DIR}/build.sh"
|
||||||
docker build \
|
|
||||||
-t "${PROJECT}-build" \
|
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
|
||||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
|
||||||
--output "${OUTPUT}" \
|
|
||||||
"${SCRIPT_DIR}"
|
|
||||||
|
|
||||||
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
@ -267,4 +267,51 @@ bool GetbinClient::listPackages(std::vector<std::string>& outPackages) {
|
|||||||
std::cerr << "[GetbinClient::listPackages] Exception: " << e.what() << std::endl;
|
std::cerr << "[GetbinClient::listPackages] Exception: " << e.what() << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetbinClient::listAllEntries(std::vector<std::pair<std::string, std::vector<std::string>>>& outEntries) {
|
||||||
|
try {
|
||||||
|
std::string url = "https://" + SERVER_HOST + "/dir";
|
||||||
|
|
||||||
|
auto response = cpr::Get(cpr::Url{url},
|
||||||
|
cpr::Header{{"User-Agent", getUserAgent()}},
|
||||||
|
cpr::Timeout{30000}, // 30 seconds
|
||||||
|
cpr::VerifySsl{true});
|
||||||
|
|
||||||
|
if (response.status_code == 200) {
|
||||||
|
try {
|
||||||
|
auto resp_json = json::parse(response.text);
|
||||||
|
if (resp_json.contains("entries") && resp_json["entries"].is_array()) {
|
||||||
|
outEntries.clear();
|
||||||
|
|
||||||
|
for (const auto& entry : resp_json["entries"]) {
|
||||||
|
if (entry.contains("hash") && entry.contains("labeltags") &&
|
||||||
|
entry["hash"].is_string() && entry["labeltags"].is_array()) {
|
||||||
|
|
||||||
|
std::string hash = entry["hash"].get<std::string>();
|
||||||
|
std::vector<std::string> labeltags;
|
||||||
|
|
||||||
|
for (const auto& tag : entry["labeltags"]) {
|
||||||
|
if (tag.is_string()) {
|
||||||
|
labeltags.push_back(tag.get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
outEntries.push_back({hash, labeltags});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (const json::exception& e) {
|
||||||
|
std::cerr << "[GetbinClient::listAllEntries] JSON parse error: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "[GetbinClient::listAllEntries] HTTP " << response.status_code << ": " << response.error.message << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "[GetbinClient::listAllEntries] Exception: " << e.what() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,8 +17,9 @@ public:
|
|||||||
bool getHash(const std::string& toolName, const std::string& arch, std::string& outHash);
|
bool getHash(const std::string& toolName, const std::string& arch, std::string& outHash);
|
||||||
bool deleteObject(const std::string& hash, const std::string& token);
|
bool deleteObject(const std::string& hash, const std::string& token);
|
||||||
bool listPackages(std::vector<std::string>& outPackages);
|
bool listPackages(std::vector<std::string>& outPackages);
|
||||||
|
bool listAllEntries(std::vector<std::pair<std::string, std::vector<std::string>>>& outEntries);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string SERVER_HOST;
|
static const std::string SERVER_HOST;
|
||||||
std::string getUserAgent() const;
|
std::string getUserAgent() const;
|
||||||
};
|
};
|
||||||
|
@ -76,6 +76,17 @@
|
|||||||
namespace {
|
namespace {
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
// Clear current line and reset cursor to beginning
|
||||||
|
void clearLine() {
|
||||||
|
std::cout << "\r\033[K" << std::flush;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear current line and print message
|
||||||
|
void clearAndPrint(const std::string& message) {
|
||||||
|
clearLine();
|
||||||
|
std::cout << message << std::flush;
|
||||||
|
}
|
||||||
|
|
||||||
// Compare versions (returns true if v1 < v2)
|
// Compare versions (returns true if v1 < v2)
|
||||||
bool isVersionOlder(const std::string& v1, const std::string& v2) {
|
bool isVersionOlder(const std::string& v1, const std::string& v2) {
|
||||||
// Simple version comparison - assumes versions are in YYYY.MMDD.HHMM format
|
// Simple version comparison - assumes versions are in YYYY.MMDD.HHMM format
|
||||||
@ -215,14 +226,14 @@ int install_tool(int argc, char* argv[]) {
|
|||||||
std::cout << "Downloading " << toolName << "..." << std::flush;
|
std::cout << "Downloading " << toolName << "..." << std::flush;
|
||||||
if (!getbin2.download(toolName, arch, archivePath.string(), progressCallback)) {
|
if (!getbin2.download(toolName, arch, archivePath.string(), progressCallback)) {
|
||||||
// Try universal version as fallback
|
// Try universal version as fallback
|
||||||
std::cout << "\rArch-specific version not found, trying universal..." << std::endl;
|
clearAndPrint("Arch-specific version not found, trying universal...\n");
|
||||||
if (!getbin2.download(toolName, "universal", archivePath.string(), progressCallback)) {
|
if (!getbin2.download(toolName, "universal", archivePath.string(), progressCallback)) {
|
||||||
std::cerr << "\rFailed to download tool archive (tried both " << arch << " and universal)." << std::endl;
|
std::cerr << "\rFailed to download tool archive (tried both " << arch << " and universal)." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
downloadArch = "universal";
|
downloadArch = "universal";
|
||||||
}
|
}
|
||||||
std::cout << "\rDownloading " << toolName << "... done" << std::endl;
|
clearAndPrint("Downloading " + toolName + "... done\n");
|
||||||
|
|
||||||
// Unpack tool
|
// Unpack tool
|
||||||
std::cout << "Unpacking..." << std::flush;
|
std::cout << "Unpacking..." << std::flush;
|
||||||
@ -230,13 +241,13 @@ int install_tool(int argc, char* argv[]) {
|
|||||||
std::cerr << "\rFailed to unpack tool archive." << std::endl;
|
std::cerr << "\rFailed to unpack tool archive." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "\rUnpacking... done" << std::endl;
|
clearAndPrint("Unpacking... done\n");
|
||||||
|
|
||||||
// Add to PATH and autocomplete
|
// Add to PATH and autocomplete
|
||||||
std::cout << "Configuring..." << std::flush;
|
std::cout << "Configuring..." << std::flush;
|
||||||
scriptManager.addToolEntry(toolName, binDir.string());
|
scriptManager.addToolEntry(toolName, binDir.string());
|
||||||
scriptManager.addAutocomplete(toolName);
|
scriptManager.addAutocomplete(toolName);
|
||||||
std::cout << "\rConfiguring... done" << std::endl;
|
clearAndPrint("Configuring... done\n");
|
||||||
|
|
||||||
// Get tool info
|
// Get tool info
|
||||||
std::string hash;
|
std::string hash;
|
||||||
@ -347,7 +358,7 @@ int publish_tool(int argc, char* argv[]) {
|
|||||||
std::cerr << "\rFailed to upload archive." << std::endl;
|
std::cerr << "\rFailed to upload archive." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "\rUploading... done" << std::endl;
|
clearAndPrint("Uploading... done\n");
|
||||||
std::cout << "Published! URL: " << url << "\nHash: " << hash << std::endl;
|
std::cout << "Published! URL: " << url << "\nHash: " << hash << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -426,7 +437,7 @@ int update_tool(int argc, char* argv[]) {
|
|||||||
tool.status = "Check failed";
|
tool.status = "Check failed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "\r" << std::string(50, ' ') << "\r" << std::flush; // Clear progress line
|
clearLine(); // Clear progress line
|
||||||
|
|
||||||
// Step 2: Update tools that need updating
|
// Step 2: Update tools that need updating
|
||||||
std::vector<std::tuple<std::string, std::string, std::string>> updateResults;
|
std::vector<std::tuple<std::string, std::string, std::string>> updateResults;
|
||||||
@ -484,7 +495,7 @@ int update_tool(int argc, char* argv[]) {
|
|||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
tool.status = "Updated";
|
tool.status = "Updated";
|
||||||
std::cout << " Updated" << std::endl;
|
clearAndPrint("Updated\n");
|
||||||
|
|
||||||
// Re-read version after update
|
// Re-read version after update
|
||||||
std::filesystem::path toolInfoPath = configDir / (tool.name + ".json");
|
std::filesystem::path toolInfoPath = configDir / (tool.name + ".json");
|
||||||
@ -502,7 +513,7 @@ int update_tool(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tool.status = "Failed";
|
tool.status = "Failed";
|
||||||
std::cout << " Failed" << std::endl;
|
clearAndPrint("Failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,35 +712,34 @@ int unpublish_tool(int argc, char* argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No specific architecture - unpublish all architectures
|
// No specific architecture - unpublish ALL entries with this tool name
|
||||||
std::vector<std::string> allArchitectures = {"x86_64", "aarch64", "universal"};
|
std::vector<std::pair<std::string, std::vector<std::string>>> allEntries;
|
||||||
std::vector<std::pair<std::string, std::string>> foundPackages;
|
std::vector<std::pair<std::string, std::string>> foundPackages; // (tag, hash)
|
||||||
|
|
||||||
std::cout << "Searching for " << toolName << " across all architectures..." << std::endl;
|
std::cout << "Searching for all entries with label '" << toolName << "'..." << std::endl;
|
||||||
|
|
||||||
// Find all existing versions
|
if (!getbin.listAllEntries(allEntries)) {
|
||||||
for (const auto& arch : allArchitectures) {
|
std::cerr << "Failed to get directory listing from server" << std::endl;
|
||||||
std::string archHash;
|
return 1;
|
||||||
if (getbin.getHash(toolName, arch, archHash) && !archHash.empty()) {
|
}
|
||||||
// Validate hash
|
|
||||||
bool validHash = true;
|
// Find all entries with labeltags starting with toolName:
|
||||||
for (char c : archHash) {
|
for (const auto& entry : allEntries) {
|
||||||
if (!std::isdigit(c)) {
|
const std::string& hash = entry.first;
|
||||||
validHash = false;
|
const std::vector<std::string>& labeltags = entry.second;
|
||||||
break;
|
|
||||||
}
|
for (const std::string& tag : labeltags) {
|
||||||
}
|
if (tag.find(toolName + ":") == 0) {
|
||||||
|
// Found a matching labeltag
|
||||||
if (validHash) {
|
foundPackages.push_back({tag, hash});
|
||||||
foundPackages.push_back({arch, archHash});
|
std::cout << " Found " << tag << " (hash: " << hash << ")" << std::endl;
|
||||||
std::cout << " Found " << toolName << ":" << arch << " (hash: " << archHash << ")" << std::endl;
|
break; // Only count each hash once even if it has multiple matching tags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundPackages.empty()) {
|
if (foundPackages.empty()) {
|
||||||
std::cerr << "No packages found for " << toolName << std::endl;
|
std::cerr << "No packages found for " << toolName << std::endl;
|
||||||
std::cerr << "Searched architectures: x86_64, aarch64, universal" << std::endl;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,7 +751,7 @@ int unpublish_tool(int argc, char* argv[]) {
|
|||||||
int failCount = 0;
|
int failCount = 0;
|
||||||
|
|
||||||
for (const auto& [arch, archHash] : foundPackages) {
|
for (const auto& [arch, archHash] : foundPackages) {
|
||||||
std::cout << " Unpublishing " << toolName << ":" << arch << "... ";
|
std::cout << " Unpublishing " << arch << "... ";
|
||||||
if (getbin.deleteObject(archHash, token)) {
|
if (getbin.deleteObject(archHash, token)) {
|
||||||
std::cout << "OK" << std::endl;
|
std::cout << "OK" << std::endl;
|
||||||
successCount++;
|
successCount++;
|
||||||
|
127
getpkg/test.sh
127
getpkg/test.sh
@ -455,12 +455,13 @@ EOF
|
|||||||
CONFIG_EXISTS=false
|
CONFIG_EXISTS=false
|
||||||
TOOL_DIR_EXISTS=false
|
TOOL_DIR_EXISTS=false
|
||||||
SYMLINK_EXISTS=false
|
SYMLINK_EXISTS=false
|
||||||
HELPER_SYMLINK_EXISTS=false
|
# HELPER_SYMLINK_EXISTS=false
|
||||||
|
|
||||||
[ -f ~/.config/getpkg/"${TEST_UNINSTALL_TOOL}.json" ] && CONFIG_EXISTS=true
|
[ -f ~/.config/getpkg/"${TEST_UNINSTALL_TOOL}.json" ] && CONFIG_EXISTS=true
|
||||||
[ -d ~/.getpkg/"$TEST_UNINSTALL_TOOL" ] && TOOL_DIR_EXISTS=true
|
[ -d ~/.getpkg/"$TEST_UNINSTALL_TOOL" ] && TOOL_DIR_EXISTS=true
|
||||||
[ -L ~/.local/bin/getpkg/"$TEST_UNINSTALL_TOOL" ] && SYMLINK_EXISTS=true
|
[ -L ~/.local/bin/getpkg/"$TEST_UNINSTALL_TOOL" ] && SYMLINK_EXISTS=true
|
||||||
[ -L ~/.local/bin/getpkg/"${TEST_UNINSTALL_TOOL}-helper" ] && HELPER_SYMLINK_EXISTS=true
|
# Check if helper symlink exists (not currently used in validation)
|
||||||
|
# [ -L ~/.local/bin/getpkg/"${TEST_UNINSTALL_TOOL}-helper" ] && HELPER_SYMLINK_EXISTS=true
|
||||||
|
|
||||||
if $CONFIG_EXISTS && $TOOL_DIR_EXISTS && $SYMLINK_EXISTS; then
|
if $CONFIG_EXISTS && $TOOL_DIR_EXISTS && $SYMLINK_EXISTS; then
|
||||||
# Now uninstall
|
# Now uninstall
|
||||||
@ -528,6 +529,128 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Test 13.5: Comprehensive unpublish functionality
|
||||||
|
echo -e "\nTest 13.5: Comprehensive unpublish functionality"
|
||||||
|
|
||||||
|
# Only run unpublish tests if SOS_WRITE_TOKEN is available
|
||||||
|
if [ -n "${SOS_WRITE_TOKEN:-}" ]; then
|
||||||
|
# Create unique test names for unpublish tests
|
||||||
|
UNPUBLISH_TOOL_BASE="test-unpublish-$RANDOM"
|
||||||
|
UNPUBLISH_TOOL_MULTI="${UNPUBLISH_TOOL_BASE}-multi"
|
||||||
|
UNPUBLISH_TOOL_CUSTOM="${UNPUBLISH_TOOL_BASE}-custom"
|
||||||
|
UNPUBLISH_TEST_DIR="${TEST_DIR}/unpublish_tests"
|
||||||
|
|
||||||
|
# Create test directory structure
|
||||||
|
mkdir -p "$UNPUBLISH_TEST_DIR"
|
||||||
|
|
||||||
|
# Test 13.5a: Create and publish tool with multiple architectures
|
||||||
|
echo "Test 13.5a: Unpublish tool with multiple architectures"
|
||||||
|
echo '#!/bin/bash
|
||||||
|
echo "Multi-arch unpublish test"' > "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_MULTI"
|
||||||
|
chmod +x "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_MULTI"
|
||||||
|
|
||||||
|
# Publish to multiple architectures
|
||||||
|
PUBLISH_x86_64_OUTPUT=$("$GETPKG" publish "${UNPUBLISH_TOOL_MULTI}:x86_64" "$UNPUBLISH_TEST_DIR" 2>&1)
|
||||||
|
PUBLISH_aarch64_OUTPUT=$("$GETPKG" publish "${UNPUBLISH_TOOL_MULTI}:aarch64" "$UNPUBLISH_TEST_DIR" 2>&1)
|
||||||
|
PUBLISH_universal_OUTPUT=$("$GETPKG" publish "${UNPUBLISH_TOOL_MULTI}:universal" "$UNPUBLISH_TEST_DIR" 2>&1)
|
||||||
|
|
||||||
|
if [[ "$PUBLISH_x86_64_OUTPUT" =~ Published! ]] && [[ "$PUBLISH_aarch64_OUTPUT" =~ Published! ]] && [[ "$PUBLISH_universal_OUTPUT" =~ Published! ]]; then
|
||||||
|
# Test robust unpublish - should remove ALL architectures
|
||||||
|
sleep 1 # Give server time to process all publishes
|
||||||
|
UNPUBLISH_OUTPUT=$("$GETPKG" unpublish "$UNPUBLISH_TOOL_MULTI" 2>&1)
|
||||||
|
UNPUBLISH_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Check that unpublish found and removed packages
|
||||||
|
if [ $UNPUBLISH_EXIT_CODE -eq 0 ] && [[ "$UNPUBLISH_OUTPUT" =~ "Found" ]] && [[ "$UNPUBLISH_OUTPUT" =~ "Successfully unpublished" ]]; then
|
||||||
|
print_test_result "Unpublish removes all architectures" 0
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish removes all architectures" 1
|
||||||
|
echo " Unpublish failed: $UNPUBLISH_OUTPUT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish removes all architectures" 1
|
||||||
|
echo " Failed to publish test tool to multiple architectures"
|
||||||
|
echo " x86_64: $PUBLISH_x86_64_OUTPUT"
|
||||||
|
echo " aarch64: $PUBLISH_aarch64_OUTPUT"
|
||||||
|
echo " universal: $PUBLISH_universal_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test 13.5b: Unpublish tool with universal architecture
|
||||||
|
echo "Test 13.5b: Unpublish tool with universal architecture"
|
||||||
|
echo '#!/bin/bash
|
||||||
|
echo "Universal arch unpublish test"' > "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_CUSTOM"
|
||||||
|
chmod +x "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_CUSTOM"
|
||||||
|
|
||||||
|
# Publish with universal architecture
|
||||||
|
PUBLISH_CUSTOM_OUTPUT=$("$GETPKG" publish "${UNPUBLISH_TOOL_CUSTOM}:universal" "$UNPUBLISH_TEST_DIR" 2>&1)
|
||||||
|
|
||||||
|
if [[ "$PUBLISH_CUSTOM_OUTPUT" =~ Published! ]]; then
|
||||||
|
# Test that unpublish can find and remove custom tags
|
||||||
|
UNPUBLISH_CUSTOM_OUTPUT=$("$GETPKG" unpublish "$UNPUBLISH_TOOL_CUSTOM" 2>&1)
|
||||||
|
UNPUBLISH_CUSTOM_EXIT_CODE=$?
|
||||||
|
|
||||||
|
if [ $UNPUBLISH_CUSTOM_EXIT_CODE -eq 0 ] && [[ "$UNPUBLISH_CUSTOM_OUTPUT" =~ Found\ ${UNPUBLISH_TOOL_CUSTOM}:universal ]]; then
|
||||||
|
print_test_result "Unpublish finds universal architecture" 0
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish finds universal architecture" 1
|
||||||
|
echo " Failed to find or unpublish custom tag: $UNPUBLISH_CUSTOM_OUTPUT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish finds universal architecture" 1
|
||||||
|
echo " Failed to publish tool with custom tag: $PUBLISH_CUSTOM_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test 13.5c: Unpublish non-existent tool
|
||||||
|
echo "Test 13.5c: Unpublish non-existent tool"
|
||||||
|
NON_EXISTENT_TOOL="non-existent-tool-$RANDOM"
|
||||||
|
UNPUBLISH_MISSING_OUTPUT=$("$GETPKG" unpublish "$NON_EXISTENT_TOOL" 2>&1)
|
||||||
|
UNPUBLISH_MISSING_EXIT_CODE=$?
|
||||||
|
|
||||||
|
if [ $UNPUBLISH_MISSING_EXIT_CODE -ne 0 ] && [[ "$UNPUBLISH_MISSING_OUTPUT" =~ "No packages found" ]]; then
|
||||||
|
print_test_result "Unpublish handles missing tools gracefully" 0
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish handles missing tools gracefully" 1
|
||||||
|
echo " Expected failure for non-existent tool, got: $UNPUBLISH_MISSING_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test 13.5d: Unpublish by hash
|
||||||
|
echo "Test 13.5d: Unpublish by hash"
|
||||||
|
UNPUBLISH_TOOL_HASH="${UNPUBLISH_TOOL_BASE}-hash"
|
||||||
|
echo '#!/bin/bash
|
||||||
|
echo "Hash unpublish test"' > "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_HASH"
|
||||||
|
chmod +x "$UNPUBLISH_TEST_DIR/$UNPUBLISH_TOOL_HASH"
|
||||||
|
|
||||||
|
PUBLISH_HASH_OUTPUT=$("$GETPKG" publish "${UNPUBLISH_TOOL_HASH}:x86_64" "$UNPUBLISH_TEST_DIR" 2>&1)
|
||||||
|
|
||||||
|
if [[ "$PUBLISH_HASH_OUTPUT" =~ Hash:\ ([0-9]+) ]]; then
|
||||||
|
EXTRACTED_HASH="${BASH_REMATCH[1]}"
|
||||||
|
|
||||||
|
# Test unpublish by hash
|
||||||
|
UNPUBLISH_HASH_OUTPUT=$("$GETPKG" unpublish "$EXTRACTED_HASH" 2>&1)
|
||||||
|
UNPUBLISH_HASH_EXIT_CODE=$?
|
||||||
|
|
||||||
|
if [ $UNPUBLISH_HASH_EXIT_CODE -eq 0 ] && [[ "$UNPUBLISH_HASH_OUTPUT" =~ "Successfully unpublished hash" ]]; then
|
||||||
|
print_test_result "Unpublish by hash works" 0
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish by hash works" 1
|
||||||
|
echo " Failed to unpublish by hash: $UNPUBLISH_HASH_OUTPUT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_test_result "Unpublish by hash works" 1
|
||||||
|
echo " Could not extract hash from publish output"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cleanup unpublish test directory
|
||||||
|
rm -rf "$UNPUBLISH_TEST_DIR"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo " Skipping unpublish tests (SOS_WRITE_TOKEN not set)"
|
||||||
|
print_test_result "Unpublish removes all architectures" 0 # Pass as skipped
|
||||||
|
print_test_result "Unpublish finds universal architecture" 0
|
||||||
|
print_test_result "Unpublish handles missing tools gracefully" 0
|
||||||
|
print_test_result "Unpublish by hash works" 0
|
||||||
|
fi
|
||||||
# Test 14: Invalid tool name validation
|
# Test 14: Invalid tool name validation
|
||||||
echo -e "\nTest 14: Invalid tool name validation"
|
echo -e "\nTest 14: Invalid tool name validation"
|
||||||
INVALID_OUTPUT=$(timeout 3 "$GETPKG" install "../evil-tool" 2>&1)
|
INVALID_OUTPUT=$(timeout 3 "$GETPKG" install "../evil-tool" 2>&1)
|
||||||
|
1
getpkg/test_display/test-display
Executable file
1
getpkg/test_display/test-display
Executable file
@ -0,0 +1 @@
|
|||||||
|
#!/bin/bash\necho display test
|
1
getpkg/test_multi/test-multi
Executable file
1
getpkg/test_multi/test-multi
Executable file
@ -0,0 +1 @@
|
|||||||
|
#!/bin/bash\necho multi arch
|
1
getpkg/test_robust/test-robust
Executable file
1
getpkg/test_robust/test-robust
Executable file
@ -0,0 +1 @@
|
|||||||
|
#!/bin/bash\necho robust test
|
20
sos/clean.sh
Executable file
20
sos/clean.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="sos"
|
||||||
|
|
||||||
|
echo "Cleaning ${PROJECT}..."
|
||||||
|
|
||||||
|
# Remove output directory (if it exists)
|
||||||
|
if [ -d "${SCRIPT_DIR}/output" ]; then
|
||||||
|
echo "Removing output directory..."
|
||||||
|
rm -rf "${SCRIPT_DIR}/output"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove any temporary files
|
||||||
|
echo "Removing temporary files..."
|
||||||
|
find "${SCRIPT_DIR}" -name "*.tmp" -o -name "*.temp" -o -name "*~" | xargs -r rm -f
|
||||||
|
|
||||||
|
echo "✓ ${PROJECT} cleaned successfully"
|
Reference in New Issue
Block a user