Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Last active October 6, 2022 10:38
Show Gist options
  • Select an option

  • Save LevitatingBusinessMan/4a418bdb396b1aefbdfa02be470bccc6 to your computer and use it in GitHub Desktop.

Select an option

Save LevitatingBusinessMan/4a418bdb396b1aefbdfa02be470bccc6 to your computer and use it in GitHub Desktop.
AUR/makepkg automation script
#!/bin/bash
set -e
DSTDIR="/tmp"
if [[ -z $1 ]]; then
echo No package specified >&2
exit 1
fi
package=$1
tempdir=`mktemp -d`
cd $tempdir
chown $USER:nogroup $tempdir
chmod g+wx $tempdir
export DSTDIR
export package
su nobody -s /bin/bash <<'end_build'
git clone "https://aur.archlinux.org/${package}.git"
cd "$package"
makepkg -o
source "PKGBUILD"
version=$(pkgver)-${pkgrel}
filename="${package}-${version}-x86_64.pkg.tar.zst"
if [[ -f "$DSTDIR/$filename" ]]; then
echo "File $filename already exists, aborting"
exit
fi
makepkg
cp "$filename" ..
end_build
file="$package"-*.pkg.tar.zst
if test -f $file; then
gpg -v --detach-sign --no-armor $file
cp -v $file{,.sig} "$DSTDIR"
cd "$DSTDIR"
repo-add -s -n -R levitating.db.tar.gz $file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment