@@ -322,5 +322,69 @@ flatpak-deps arch="":
322322 sudo flatpak install -y --noninteractive flathub com.system76. Cosmic.BaseApp// stable $ARCH_FLAG
323323 echo " Flatpak dependencies installed!"
324324
325- # Full clean (cargo + vendor + flatpak)
326- clean -all: clean clean -vendor flatpak-clean
325+ # ============================================================================
326+ # Alpine APK recipes
327+ # ============================================================================
328+
329+ # Build Alpine APK package (optionally specify arch, e.g. aarch64)
330+ # Cross-compiles first, then packages the pre-built binary in an Alpine container.
331+ apk-build arch = " ":
332+ #!/usr/bin/env bash
333+ set -euo pipefail
334+ arch =" {{ arch }} "
335+ if [ -z " $arch" ]; then
336+ arch =$(uname -m)
337+ fi
338+
339+ # Map arch to Rust target triple
340+ case " $arch" in
341+ aarch64 ) rust_target=" aarch64-unknown-linux-musl" ;;
342+ x86 _64 ) rust_target=" x86_64-unknown-linux-musl" ;;
343+ *) echo " Unsupported arch: $arch" ; exit 1 ;;
344+ esac
345+
346+ echo " Cross-compiling for $rust_target (release-fast)..."
347+ cross build --target " $rust_target" --profile release-fast
348+
349+ binary=" target/$rust_target/release-fast/camera"
350+ [ -f " $binary" ] || { echo " Error: binary not found at $binary" ; exit 1 ; }
351+
352+ echo " Packaging APK for $arch..."
353+ platform=" linux/$arch"
354+ [ " $arch" = " x86_64" ] && platform=" linux/amd64"
355+ image_tag=" camera-apk-$arch"
356+ VERSION=$(grep " ^version" Cargo.toml | head -1 | sed ' s/.*"\(.*\)"/\1/' )
357+
358+ mkdir -p apk-out
359+ podman build --platform " $platform" -t " $image_tag" -f docker/ Dockerfile.apk .
360+
361+ podman run --rm --platform " $platform" \
362+ - v " $(pwd)" :/ src:ro \
363+ - v " $(pwd)/apk-out" :/ out \
364+ - v " $(pwd)/$binary" :/ prebuilt/ camera:ro \
365+ " $image_tag" sh -c '
366+ set -e
367+ VERSION="' " $VERSION"' "
368+
369+ mkdir -p /home/builder/apkbuild
370+ sed "s/@@VERSION@@/$VERSION/g" /src/.github/APKBUILD.prebuilt.template \
371+ > /home/builder/apkbuild/APKBUILD
372+ chown -R builder:builder /home/builder/apkbuild
373+
374+ cd /home/builder/apkbuild
375+ sudo -Hu builder abuild -r
376+
377+ mkdir -p /out
378+ find /home/builder/packages -name "camera-*.apk" ! -name "*-doc-*" ! -name "*-dev-*" -exec cp {} /out/ \;
379+ echo "APK built successfully:"
380+ ls -la /out/
381+ '
382+ echo " Output in apk-out/"
383+ ls -la apk-out/
384+
385+ # Clean APK build artifacts
386+ apk-clean :
387+ rm -rf apk-out
388+
389+ # Full clean (cargo + vendor + flatpak + apk)
390+ clean -all: clean clean -vendor flatpak-clean apk-clean
0 commit comments