From daffaad8a1143be8543fadbee7d5a0ea519df23d Mon Sep 17 00:00:00 2001 From: robojerk Date: Fri, 5 Sep 2025 08:36:06 -0700 Subject: [PATCH] first commit --- .forgejo/workflows/ci.yml | 212 +++++++++++++++++++++++++++++++++++++ Dockerfile | 31 ++++++ Dockerfile-debian.template | 21 ++++ README.md | 3 + 4 files changed, 267 insertions(+) create mode 100644 .forgejo/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 Dockerfile-debian.template create mode 100644 README.md diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..5b30cd4 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,212 @@ +name: Build bootupd with systemd-boot + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup apt-cacher-ng + run: | + echo "Setting up apt-cacher-ng for faster builds..." + + # Try apt-cacher-ng first, fallback to standard mirrors + echo "Checking for apt-cacher-ng availability..." + + # Quick check with timeout to avoid hanging + if timeout 10 curl -s --connect-timeout 5 http://192.168.1.101:3142/acng-report.html > /dev/null 2>&1; then + echo "✅ apt-cacher-ng is available, configuring Docker to use proxy..." + + # Create Docker daemon configuration for apt-cacher-ng + sudo mkdir -p /etc/docker + echo '{ + "proxies": { + "default": { + "httpProxy": "http://192.168.1.101:3142", + "httpsProxy": "http://192.168.1.101:3142", + "noProxy": "localhost,127.0.0.1" + } + } + }' | sudo tee /etc/docker/daemon.json + + # Restart Docker to apply proxy settings + sudo systemctl restart docker + + echo "Using apt-cacher-ng proxy for faster Docker builds" + else + echo "⚠️ apt-cacher-ng not available, using standard mirrors..." + echo "Using standard Debian mirrors for Docker builds" + fi + + - name: Build Docker image + run: | + docker build --build-arg release-name=unstable -f Dockerfile -t bootupd-sdboot:latest . + + - name: Build bootupd inside container + run: | + docker run --rm -v $(pwd):/workspace bootupd-sdboot:latest bash -c " + # Setup apt-cacher-ng inside container if available + if timeout 5 curl -s --connect-timeout 3 http://192.168.1.101:3142/acng-report.html > /dev/null 2>&1; then + echo '✅ Using apt-cacher-ng for package downloads...' + echo 'deb http://192.168.1.101:3142/ftp.debian.org/debian unstable main contrib non-free' > /etc/apt/sources.list + echo 'deb-src http://192.168.1.101:3142/ftp.debian.org/debian unstable main contrib non-free' >> /etc/apt/sources.list + else + echo '⚠️ Using standard Debian mirrors...' + echo 'deb http://deb.debian.org/debian unstable main contrib non-free' > /etc/apt/sources.list + echo 'deb-src http://deb.debian.org/debian unstable main contrib non-free' >> /etc/apt/sources.list + fi + + # Update package lists + apt update -y + + # Clone and build bootupd + git clone https://github.com/p5/coreos-bootupd.git bootupd && \ + cd bootupd && \ + git fetch --all && \ + git switch origin/sdboot-support -d && \ + /root/.cargo/bin/cargo build --release --bins --features systemd-boot && \ + install -Dpm0755 -t /usr/bin ./target/release/bootupd && \ + ln -s ./bootupd /usr/bin/bootupctl && \ + cp /usr/bin/bootupd /workspace/ && \ + cp /usr/bin/bootupctl /workspace/ + " + + - name: Create Debian package + run: | + echo "Creating Debian package for bootupd..." + + # Get build information + BUILD_NUMBER="${FORGEJO_RUN_NUMBER:-${GITEA_RUN_NUMBER:-$(date +%Y%m%d%H%M%S)}}" + COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "unknown") + SHORT_COMMIT=$(echo "$COMMIT_HASH" | cut -c1-10) + + # Create package directory structure + mkdir -p bootupd-package/usr/bin + mkdir -p bootupd-package/DEBIAN + + # Copy binaries + cp bootupd bootupd-package/usr/bin/ + cp bootupctl bootupd-package/usr/bin/ + chmod +x bootupd-package/usr/bin/bootupd + chmod +x bootupd-package/usr/bin/bootupctl + + # Create control file + cat > bootupd-package/DEBIAN/control << EOF +Package: bootupd +Version: 0.1.0+${BUILD_NUMBER}+${SHORT_COMMIT} +Section: admin +Priority: optional +Architecture: amd64 +Maintainer: CI Build +Description: Distribution-independent bootloader update tool with systemd-boot support + Bootupd is a distribution-independent tool for managing bootloader updates. + This package includes systemd-boot support. + . + Features: + - systemd-boot support + - Distribution-independent + - Safe bootloader updates +EOF + + # Build Debian package + dpkg-deb --build bootupd-package bootupd_0.1.0+${BUILD_NUMBER}+${SHORT_COMMIT}_amd64.deb + + echo "✅ Debian package created: bootupd_0.1.0+${BUILD_NUMBER}+${SHORT_COMMIT}_amd64.deb" + + - name: Upload to Forgejo Debian Registry + run: | + echo "Uploading to Forgejo Debian Registry..." + + # Set Forgejo configuration + FORGEJO_OWNER="particle-os" + FORGEJO_DISTRIBUTION="trixie" + FORGEJO_COMPONENT="main" + + # Find the .deb file + DEB_FILE=$(ls bootupd_*.deb | head -1) + + if [ -z "$DEB_FILE" ]; then + echo "❌ No .deb file found for upload" + exit 1 + fi + + echo "📦 Uploading package: $DEB_FILE" + + # Extract package info + PKG_NAME=$(dpkg-deb -f "$DEB_FILE" Package 2>/dev/null || echo "bootupd") + PKG_VERSION=$(dpkg-deb -f "$DEB_FILE" Version 2>/dev/null || echo "unknown") + PKG_ARCH=$(dpkg-deb -f "$DEB_FILE" Architecture 2>/dev/null || echo "amd64") + + echo " Package: $PKG_NAME" + echo " Version: $PKG_VERSION" + echo " Architecture: $PKG_ARCH" + + # Forgejo Debian Registry upload URL + UPLOAD_URL="https://git.raines.xyz/api/packages/${FORGEJO_OWNER}/debian/pool/${FORGEJO_DISTRIBUTION}/${FORGEJO_COMPONENT}/upload" + + echo " Upload URL: $UPLOAD_URL" + + # Upload to Forgejo Debian Registry + if [ -n "${{ secrets.ACCESS_TOKEN }}" ]; then + echo " 🔐 Using authentication token..." + UPLOAD_RESULT=$(curl -s -w "%{http_code}" \ + --user "${FORGEJO_OWNER}:${{ secrets.ACCESS_TOKEN }}" \ + --upload-file "$DEB_FILE" \ + "$UPLOAD_URL" 2>/dev/null) + + # Extract HTTP status code (last 3 characters) + HTTP_CODE=$(echo "$UPLOAD_RESULT" | tail -c 4) + # Extract response body (everything except last 3 characters) + RESPONSE_BODY=$(echo "$UPLOAD_RESULT" | head -c -4) + + case $HTTP_CODE in + 201) + echo " ✅ Successfully published to Forgejo Debian Registry!" + echo " 📥 Install with: apt install $PKG_NAME" + ;; + 409) + echo " ⚠️ Package already exists (version conflict)" + echo " 💡 Consider deleting old version first" + ;; + 400) + echo " ❌ Bad request - package validation failed" + ;; + *) + echo " ❌ Upload failed with HTTP $HTTP_CODE" + echo " Response: $RESPONSE_BODY" + ;; + esac + else + echo " ⚠️ No ACCESS_TOKEN secret available - skipping upload" + echo " 💡 Set ACCESS_TOKEN secret in repository settings to enable automatic publishing" + echo " 📋 Manual upload command:" + echo " curl --user your_username:your_token \\" + echo " --upload-file $DEB_FILE \\" + echo " $UPLOAD_URL" + fi + + echo "" + echo "🎯 Debian package publishing complete!" + echo "📦 Package is now available in Forgejo Debian Registry" + echo "🔧 To install: apt install bootupd" + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: bootupd-binaries + path: | + bootupd + bootupctl + bootupd_*.deb \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7d0c91d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM buildpack-deps:$release-name + +LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.89.0 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='3b8daab6cc3135f2cd4b12919559e6adaee73a2fbefb830fadf0405c20231d61' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e3853c5a252fca15252d07cb23a1bdd9377a8c6f3efa01531109281ae47f841c' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='a5db2c4b29d23e9b318b955dd0337d6b52e93933608469085c924e0d05b1df1f' ;; \ + ppc64el) rustArch='powerpc64le-unknown-linux-gnu'; rustupSha256='acd89c42b47c93bd4266163a7b05d3f26287d5148413c0d47b2e8a7aa67c9dc0' ;; \ + s390x) rustArch='s390x-unknown-linux-gnu'; rustupSha256='726b7fd5d8805e73eab4a024a2889f8859d5a44e36041abac0a2436a52d42572' ;; \ + riscv64) rustArch='riscv64gc-unknown-linux-gnu'; rustupSha256='09e64cc1b7a3e99adaa15dd2d46a3aad9d44d71041e2a96100d165c98a8fd7a7' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.28.2/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template new file mode 100644 index 0000000..c13346f --- /dev/null +++ b/Dockerfile-debian.template @@ -0,0 +1,21 @@ +FROM buildpack-deps:%%DEBIAN-SUITE%% + +LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=%%RUST-VERSION%% + +RUN set -eux; \ + %%ARCH-CASE%%; \ + url="https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b0367d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +build bootup with systemd-boot + +This is only a ci.yml \ No newline at end of file