Private
Public Access
1
0
Files
linux_patch_api/build-arch.sh
Echo a4026a471a
Some checks failed
CI/CD Pipeline / Code Format (push) Failing after 6s
CI/CD Pipeline / Clippy Lints (push) Failing after 11s
CI/CD Pipeline / Unit Tests (push) Failing after 1s
CI/CD Pipeline / Build Debian Package (push) Has been skipped
CI/CD Pipeline / Build RPM Package (push) Has been skipped
CI/CD Pipeline / Build Alpine Package (push) Has been skipped
CI/CD Pipeline / Build Arch Package (push) Has been skipped
CI/CD Pipeline / Security Audit (push) Failing after 1s
refactor: update CI for native per-OS runners
- Replace generic "linux" runner label with dedicated per-OS labels
  (ubuntu-24.04, fedora, alpine, arch)
- Remove all container declarations (native runner execution)
- Add build gate dependencies: build jobs need fmt+clippy+test
- Extract release upload logic into reusable scripts/upload-release.sh
- Fix build-alpine.sh: remove hardcoded container paths, add
  SKIP_CARGO_BUILD support
- Fix build-arch.sh: remove hardcoded container paths, add
  SKIP_CARGO_BUILD support
- Fix build-rpm.sh: remove sudo, native runner compatible
- Remove Dockerfile.rpm and Dockerfile.arch (no longer needed)
- Add sudo to Ubuntu/Fedora/Arch package installs for safety
- Add nodejs to Alpine deps for Gitea Actions compatibility
- Make upload-release.sh POSIX sh compatible (Alpine)
- Fix curl -sf to curl -s in upload-release.sh (404 on new releases)
2026-04-26 19:21:09 +00:00

88 lines
2.3 KiB
Bash

#!/bin/bash
# Build Arch Linux Package (.pkg.tar.zst)
# Run on: Arch Linux / Manjaro
# Designed for native Gitea Actions runner execution
set -e
echo "=== Linux Patch API - Arch Build Script ==="
echo ""
# Check if running on Arch
if ! command -v makepkg &> /dev/null; then
echo "Error: makepkg not found. This script must run on Arch Linux."
exit 1
fi
# Build release binary
if [ -z "$SKIP_CARGO_BUILD" ]; then
echo "Building release binary..."
cargo build --release
else
echo "Skipping cargo build (SKIP_CARGO_BUILD is set)"
fi
# 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
# Copy files
cp target/release/linux-patch-api "$PKGDIR"/usr/bin/
chmod 755 "$PKGDIR"/usr/bin/linux-patch-api
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
# Determine workspace path for PKGBUILD
WORKSPACE_DIR=$(pwd)
# Create PKGBUILD
echo "Creating PKGBUILD..."
cat > PKGBUILD << EOF
pkgname=linux-patch-api
pkgver=1.0.0
pkgrel=1
pkgdesc="Secure remote package management API for Linux systems"
url="https://gitea.moon-dragon.us/echo/linux_patch_api"
arch=('x86_64')
license=('MIT')
depends=('systemd')
package() {
cp -r ${WORKSPACE_DIR}/arch-package/* "$pkgdir"/
}
EOF
# Create .SRCINFO
echo "Creating .SRCINFO..."
# Build package
echo "Building Arch package..."
# For CI environments where we may run as root
if [ "$(id -u)" = "0" ]; then
echo "Running as root - creating build user for makepkg..."
useradd -m builduser 2>/dev/null || true
chown -R builduser:builduser "$(pwd)"
su - builduser -c "cd $(pwd) && makepkg --printsrcinfo > .SRCINFO"
su - builduser -c "cd $(pwd) && makepkg -f --noconfirm"
else
makepkg --printsrcinfo > .SRCINFO
makepkg -f --noconfirm
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"
echo ""
echo "Install with:"
echo " sudo pacman -U ./releases/linux-patch-api-*.pkg.tar.zst"