🐛 fix: more dynamic

This commit is contained in:
eshanized
2025-01-01 10:30:45 +05:30
parent ee1dab3821
commit 755e86f4b8

View File

@@ -1,21 +1,39 @@
#!/bin/sh
set -e
pkgname=$(grep "^pkgname=" PKGBUILD | awk -F"=" '{print $2}')
pkgrel=$(grep "^pkgrel=" PKGBUILD | awk -F"=" '{split($2,a," ");gsub(/"/, "", a[1]);print a[1]}')
arch=$(grep "^arch=" PKGBUILD | awk -F"'" '{print $2}')
#NEED ONLY TO EDIT sourcefiles VARIABLE
# Extract fields from PKGBUILD using a more robust approach
pkgname=$(awk -F"=" '/^pkgname=/ {print $2}' PKGBUILD)
pkgrel=$(awk -F"=" '/^pkgrel=/ {gsub(/"/, "", $2); print $2}' PKGBUILD)
arch=$(awk -F"'" '/^arch=/ {print $2}' PKGBUILD)
# Edit this variable to specify source files
sourcefiles="usr"
#sed -i -e '/^sha256/d' -e '/^sha512/d' PKGBUILD
# Create a compressed tarball of the specified source files
if [ -d "$sourcefiles" ]; then
echo "[INFO]: Creating source tarball..."
tar -zcvf "$pkgname.tar.gz" "$sourcefiles"
else
echo "[ERROR]: Source files directory '$sourcefiles' does not exist."
exit 1
fi
tar -zcvf $pkgname.tar.gz $sourcefiles
# updpkgsums
#makepkg -g >> PKGBUILD
# Generate the package
echo "[INFO]: Building the package..."
makepkg -f -scr --noconfirm
pkgver=$(grep "^pkgver=" PKGBUILD | awk -F"=" '{print $2}')
pkgfile=$pkgname-$pkgver-$pkgrel-$arch.pkg.tar.zst
rm -rf src pkg $pkgname.tar.gz
# Extract pkgver dynamically after package build
pkgver=$(awk -F"=" '/^pkgver=/ {print $2}' PKGBUILD)
pkgfile="$pkgname-$pkgver-$pkgrel-$arch.pkg.tar.zst"
# Clean up generated files and temporary directories
echo "[INFO]: Cleaning up..."
rm -rf src pkg "$pkgname.tar.gz"
# Verify that the package was built successfully
if [ -f "$pkgfile" ]; then
echo "[INFO]: Package '$pkgfile' built successfully."
else
echo "[ERROR]: Package build failed."
exit 1
fi