builder/makepkg-ci
fbt 8adeef05bc cleanup with a trap
Signed-off-by: fbt <fbt@fleshless.org>
2021-03-06 11:29:30 +03:00

33 lines
622 B
Bash
Executable File

#!/usr/bin/env bash
shopt -s nullglob
cleanup() { rm -rf "$tmpdir"; }
trap 'cleanup' EXIT
did="pkg-build-$$.$SRANDOM"
tmpdir="/tmp/$did"
mkdir "$tmpdir"
pkg_dest=$1
pkg_url=$2
mkdir -p "$pkg_dest" || exit 1
git clone "$pkg_url" "$tmpdir"
cd "$tmpdir"
makepkg-podman --noconfirm -sL
artifacts=( "$tmpdir/"*.pkg.* )
for i in "${artifacts[@]}"; do
i_name="${i##*/}"
printf 'Found artifact: %s\n' "$i_name"
if [[ -f "$pkg_dest/$i_name" ]]; then
printf '%s/%s already exists, not overwriting.\n' "$pkg_dest" "$i_name"
else
printf 'Copying %s to %s.\n' "$i_name" "$pkg_dest"
cp -vn "$i" "$pkg_dest"
fi
done