2021-02-26 23:50:00 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
shopt -s nullglob
|
|
|
|
|
|
|
|
did="pkg-build-$$.$SRANDOM"
|
2021-02-27 04:53:38 +00:00
|
|
|
mkdir "/tmp/$did"
|
2021-02-26 23:50:00 +00:00
|
|
|
|
|
|
|
pkg_dest=$1
|
|
|
|
pkg_url=$2
|
|
|
|
|
2021-02-27 04:53:38 +00:00
|
|
|
cd /home/containers/builder
|
|
|
|
podman build -t "$did" --force-rm .
|
|
|
|
podman run --rm -v "/tmp/$did:/buildroot" "$did:latest" /build "$pkg_url"
|
2021-02-26 23:50:00 +00:00
|
|
|
|
|
|
|
artifacts=( "/tmp/$did/"*.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
|
|
|
|
|
|
|
|
# cleanup
|
2021-02-27 04:55:24 +00:00
|
|
|
podman rmi "$did"
|
2021-02-26 23:50:00 +00:00
|
|
|
rm -rf "/tmp/$did"
|