Aggiorna lo script build-apk.sh per gestire correttamente pkgname e pkgver, migliorando la creazione della directory di build temporanea

This commit is contained in:
wonka929 2026-02-22 12:41:44 +01:00
parent 58031e6efc
commit 63b4f1d310

View file

@ -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/<other>/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-<ver> 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