From 63b4f1d3102ef1b6bf1c0dbedb5424d657e2dbf2 Mon Sep 17 00:00:00 2001 From: wonka929 Date: Sun, 22 Feb 2026 12:41:44 +0100 Subject: [PATCH] Aggiorna lo script build-apk.sh per gestire correttamente pkgname e pkgver, migliorando la creazione della directory di build temporanea --- pack/alpine/build-apk.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/pack/alpine/build-apk.sh b/pack/alpine/build-apk.sh index b341161..4c11a42 100644 --- a/pack/alpine/build-apk.sh +++ b/pack/alpine/build-apk.sh @@ -24,20 +24,40 @@ if [ ! -f "$HOME/.abuild/abuild-$(whoami).rsa" ]; then fi echo "Preparazione directory di build..." +# Read pkgname and pkgver from APKBUILD to build a correct source folder name +pkgname=$(sed -n 's/^pkgname=\(.*\)/\1/p' "$PKGDIR/APKBUILD" | tr -d '"') +pkgver=$(sed -n 's/^pkgver=\(.*\)/\1/p' "$PKGDIR/APKBUILD" | tr -d '"') +if [ -z "$pkgname" ] || [ -z "$pkgver" ]; then + pkgname=watchyourlan + pkgver=2.4.1 +fi +srcdir_name="$pkgname-$pkgver" + +# Ensure abuild writes packages inside the repo to avoid using /home//packages +PACKAGES="$PKGDIR/packages" +export PACKAGES +mkdir -p "$PACKAGES" + # Create a temporary build directory inside pack/alpine to avoid permission/path issues -# Use a unique name with timestamp, pid and random suffix tmpdir="$PKGDIR/build-tmp-$(date +%s)-$$-$RANDOM" mkdir -p "$tmpdir" trap 'rm -rf "$tmpdir"' EXIT echo "Copia sorgenti in $tmpdir" -# copy repository into a folder named watchyourlan- as expected by abuild -# use recursive copy without preserving ownership to avoid "Operation not permitted" -mkdir -p "$tmpdir/watchyourlan-2.4.1" -cp -r "$PKGDIR/../." "$tmpdir/watchyourlan-2.4.1" -cp "$PKGDIR/APKBUILD" "$tmpdir/watchyourlan-2.4.1/" +mkdir -p "$tmpdir/$srcdir_name" -cd "$tmpdir/watchyourlan-2.4.1" +# Copy repository contents into temporary build dir, excluding the temporary dir itself and VCS metadata. +# Prefer rsync when available; otherwise use tar with exclude patterns. +if command -v rsync >/dev/null 2>&1; then + rsync -a --exclude 'pack/alpine/build-tmp-*' --exclude '.git' "$PKGDIR/../" "$tmpdir/$srcdir_name/" +else + (cd "$PKGDIR/../" && tar --exclude='pack/alpine/build-tmp-*' --exclude='.git' -cf - .) | (cd "$tmpdir/$srcdir_name" && tar -xf -) +fi + +# Ensure APKBUILD is present in the source root (some setups expect it there) +cp -f "$PKGDIR/APKBUILD" "$tmpdir/$srcdir_name/" + +cd "$tmpdir/$srcdir_name" echo "Avvio build con abuild -r (richiede pacchetti makedepends installati)..." abuild -r