3 Commits

Author SHA1 Message Date
70cb5c1b3a test: Update 5 files
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 1m49s
Build-Test-Publish / build (linux/arm64) (push) Failing after 2m9s
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
2025-06-29 21:27:12 +12:00
facc6b73b0 feat: Update 4 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m30s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m33s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 7s
2025-06-29 20:52:40 +12:00
9a24576e37 Modify clean.sh
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m28s
Build-Test-Publish / build (linux/arm64) (push) Failing after 2m28s
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
2025-06-29 20:31:18 +12:00
12 changed files with 184 additions and 104 deletions

24
bb64/clean.sh Executable file
View 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"

View File

@ -20,7 +20,14 @@ echo "Building version $VERSION" >&2
# build release version
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 \
${CACHE_FLAG} \
-t "${PROJECT}-build" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \

44
clean.sh Executable file
View 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!"

View File

@ -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}

View File

@ -1,29 +1,26 @@
#!/bin/bash
set -euo pipefail
# build.sh using docker run approach
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT="dehydrate"
export CMAKE_BUILD_TYPE="Debug"
rm -rf "${SCRIPT_DIR}/output"
# Create persistent build directory
mkdir -p "${SCRIPT_DIR}/build"
mkdir -p "${SCRIPT_DIR}/output"
# make sure we have the latest base image.
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 \
${CACHE_FLAG} \
-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}"
# Run build in container with mounted directories
docker run --rm \
--user "$(id -u):$(id -g)" \
-v "${SCRIPT_DIR}:/src:ro" \
-v "${SCRIPT_DIR}/build:/build" \
-v "${SCRIPT_DIR}/output:/output" \
-e CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}" \
gitea.jde.nz/public/dropshell-build-base:latest \
bash -c "
cd /build && \
cmake -G Ninja -S /src -B . \
-DCMAKE_BUILD_TYPE=\${CMAKE_BUILD_TYPE} \
-DPROJECT_NAME=${PROJECT} && \
cmake --build . && \
cp ${PROJECT} /output/
"

18
dehydrate/clean.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT="dehydrate"
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"

View File

@ -35,14 +35,7 @@ heading "Building ${PROJECT}"
# build release version
export CMAKE_BUILD_TYPE="Release"
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}"
"${SCRIPT_DIR}/build.sh"
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."

View File

@ -4,7 +4,7 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
cd "$SCRIPT_DIR"
cd "$SCRIPT_DIR" || exit 1
# Clean up old test data and any existing binaries
# Force removal with chmod to handle permission issues

24
getpkg/clean.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT="getpkg"
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"

View File

@ -35,7 +35,14 @@ heading "Building ${PROJECT}"
# build release version
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 \
${CACHE_FLAG} \
-t "${PROJECT}-build" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \

View File

@ -76,6 +76,17 @@
namespace {
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)
bool isVersionOlder(const std::string& v1, const std::string& v2) {
// 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;
if (!getbin2.download(toolName, arch, archivePath.string(), progressCallback)) {
// 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)) {
std::cerr << "\rFailed to download tool archive (tried both " << arch << " and universal)." << std::endl;
return 1;
}
downloadArch = "universal";
}
std::cout << "\rDownloading " << toolName << "... done" << std::endl;
clearAndPrint("Downloading " + toolName + "... done\n");
// Unpack tool
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;
return 1;
}
std::cout << "\rUnpacking... done" << std::endl;
clearAndPrint("Unpacking... done\n");
// Add to PATH and autocomplete
std::cout << "Configuring..." << std::flush;
scriptManager.addToolEntry(toolName, binDir.string());
scriptManager.addAutocomplete(toolName);
std::cout << "\rConfiguring... done" << std::endl;
clearAndPrint("Configuring... done\n");
// Get tool info
std::string hash;
@ -347,7 +358,7 @@ int publish_tool(int argc, char* argv[]) {
std::cerr << "\rFailed to upload archive." << std::endl;
return 1;
}
std::cout << "\rUploading... done" << std::endl;
clearAndPrint("Uploading... done\n");
std::cout << "Published! URL: " << url << "\nHash: " << hash << std::endl;
return 0;
}
@ -426,7 +437,7 @@ int update_tool(int argc, char* argv[]) {
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
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) {
tool.status = "Updated";
std::cout << " Updated" << std::endl;
clearAndPrint("Updated\n");
// Re-read version after update
std::filesystem::path toolInfoPath = configDir / (tool.name + ".json");
@ -502,7 +513,7 @@ int update_tool(int argc, char* argv[]) {
}
} else {
tool.status = "Failed";
std::cout << " Failed" << std::endl;
clearAndPrint("Failed\n");
}
}
}

20
sos/clean.sh Executable file
View 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"