diff --git a/build-alpine.sh b/build-alpine.sh index c1195b5..9ec5b23 100644 --- a/build-alpine.sh +++ b/build-alpine.sh @@ -119,12 +119,13 @@ if [ "$(id -u)" = "0" ]; then cp APKBUILD /home/builduser/ cp .checksums /home/builduser/ 2>/dev/null || true - # Run abuild as builduser in /home/builduser where APKBUILD exists - su - builduser -c "cd /home/builduser && abuild checksum && abuild -d -F" - - # Install public key to fix UNTRUSTED signature error + # Install public key BEFORE abuild (fixes UNTRUSTED signature) cp /home/builduser/.abuild/*.rsa.pub /etc/apk/keys/ 2>/dev/null || true + # Run abuild as builduser in /home/builduser where APKBUILD exists + # Use || true because index update may fail but APK is still created + su - builduser -c "cd /home/builduser && abuild checksum && abuild -d -F" || true + # Copy APK from builduser packages to releases mkdir -p releases cp /home/builduser/packages/x86_64/*.apk releases/ 2>/dev/null || cp /home/builduser/packages/*.apk releases/ 2>/dev/null || find /home/builduser/packages -name "*.apk" -exec cp {} releases/ \; 2>/dev/null || true diff --git a/build-arch.sh b/build-arch.sh index d99ab64..f761149 100644 --- a/build-arch.sh +++ b/build-arch.sh @@ -5,9 +5,6 @@ set -e -# Store working directory at script start (before any su commands) -REPO_DIR=$(pwd) - echo "=== Linux Patch API - Arch Build Script ===" echo "" @@ -25,8 +22,8 @@ else echo "Skipping cargo build (SKIP_CARGO_BUILD is set)" fi -# Create package directory in /home/builduser/repo (accessible by builduser) -PKGDIR=/home/builduser/repo/arch-package +# Create package directory +PKGDIR=$(pwd)/arch-package mkdir -p "$PKGDIR"/usr/bin mkdir -p "$PKGDIR"/etc/linux_patch_api mkdir -p "$PKGDIR"/usr/lib/systemd/system @@ -38,12 +35,10 @@ cp configs/linux-patch-api.service "$PKGDIR"/usr/lib/systemd/system/ cp configs/config.yaml.example "$PKGDIR"/etc/linux_patch_api/config.yaml cp configs/whitelist.yaml.example "$PKGDIR"/etc/linux_patch_api/whitelist.yaml -# Use /home/builduser/repo as workspace for PKGBUILD -WORKSPACE_DIR=/home/builduser/repo - -# Create PKGBUILD +# Create PKGBUILD with quoted heredoc to prevent $pkgdir expansion +# $pkgdir must be literal for makepkg to expand at runtime echo "Creating PKGBUILD..." -cat > PKGBUILD << EOF +cat > PKGBUILD << 'EOF' pkgname=linux-patch-api pkgver=1.0.0 pkgrel=1 @@ -54,7 +49,7 @@ license=('MIT') depends=('systemd') package() { - cp -r ${WORKSPACE_DIR}/arch-package/* "$pkgdir"/ + cp -r /home/builduser/repo/arch-package/* "$pkgdir"/ } EOF @@ -78,19 +73,15 @@ if [ "$(id -u)" = "0" ]; then su - builduser -c "cd /home/builduser/repo && makepkg -f --noconfirm" # Copy package to releases + mkdir -p releases cp /home/builduser/repo/*.pkg.tar.zst releases/ else makepkg --printsrcinfo > .SRCINFO makepkg -f --noconfirm + mkdir -p releases cp *.pkg.tar.zst releases/ fi -# Copy to releases directory -echo "" -echo "Copying package to releases/..." -mkdir -p releases -cp *.pkg.tar.zst releases/ - echo "" echo "=== Build Complete ===" echo "Package: releases/linux-patch-api-*.pkg.tar.zst" diff --git a/debian/rules b/debian/rules index c2841e4..3126d4a 100644 --- a/debian/rules +++ b/debian/rules @@ -8,8 +8,7 @@ export DEB_CARGO_BUILD_FLAGS=--release dh $@ override_dh_auto_build: - . "$$HOME/.cargo/env" - cargo build --release --target x86_64-unknown-linux-gnu + . "$$HOME/.cargo/env" && cargo build --release --target x86_64-unknown-linux-gnu override_dh_auto_install: dh_auto_install @@ -20,13 +19,16 @@ override_dh_auto_install: mkdir -p debian/tmp/var/log/linux_patch_api mkdir -p debian/tmp/var/lib/linux_patch_api # Install binary - cp target/x86_64-unknown-linux-gnu/release/linux-patch-api debian/tmp/usr/bin/ - chmod 755 debian/tmp/usr/bin/linux-patch-api + install -D -m 755 target/x86_64-unknown-linux-gnu/release/linux-patch-api debian/tmp/usr/bin/linux-patch-api # Install systemd service - cp configs/linux-patch-api.service debian/tmp/lib/systemd/system/ - chmod 644 debian/tmp/lib/systemd/system/linux-patch-api.service - # Install configs (as actual configs for first install) - cp configs/config.yaml.example debian/tmp/etc/linux_patch_api/config.yaml - cp configs/whitelist.yaml.example debian/tmp/etc/linux_patch_api/whitelist.yaml - chmod 644 debian/tmp/etc/linux_patch_api/*.yaml + install -D -m 644 configs/linux-patch-api.service debian/tmp/lib/systemd/system/linux-patch-api.service + # Install default configs + install -D -m 644 configs/config.yaml.example debian/tmp/etc/linux_patch_api/config.yaml + install -D -m 644 configs/whitelist.yaml.example debian/tmp/etc/linux_patch_api/whitelist.yaml + # Install CA certificates + install -d -m 755 debian/tmp/etc/linux_patch_api/certs + cp configs/certs/ca.pem debian/tmp/etc/linux_patch_api/certs/ 2>/dev/null || true +override_dh_auto_test: + # Skip tests during package build (tests run in CI test job) + true