this is a bit simpler

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2021-03-06 06:41:56 +03:00
parent 1f2b2e3c6d
commit cba181007b
4 changed files with 47 additions and 27 deletions

View File

@ -8,10 +8,11 @@ export PKG_URL=$1
# Upgrade
pacman -Suy --noconfirm
# gnupg dir permissions
chown -R "$BUILDUSER:$BUILDUSER" /.gnupg
# Workdir
chown -R builder:builder /.gnupg
cd /buildroot
# Build the damn thing
sudo -u builder git clone "$PKG_URL" .
sudo -u builder GNUPGHOME="/.gnupg" makepkg -s --noconfirm -L
sudo -u "$BUILDUSER" GNUPGHOME="/.gnupg" makepkg -s --noconfirm -L

30
makepkg-ci Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
shopt -s nullglob
did="pkg-build-$$.$SRANDOM"
mkdir "/tmp/$did"
pkg_dest=$1
pkg_url=$2
#podman run --userns=keep-id -u root --rm -v "/tmp/$did:/buildroot" "spark:autobuilder" /build
git clone "$pkg_url" "/tmp/$did"
cd "/tmp/$did"
makepkg-podman 'localhost/spark:autobuilder'
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
rm -rf "/tmp/$did"

View File

@ -1,27 +1,16 @@
#!/usr/bin/env bash
shopt -s nullglob
did="pkg-build-$$.$SRANDOM"
mkdir "/tmp/$did"
image=${1:-localhost/spark:autobuilder}
pkg_dest=$1
pkg_url=$2
podman_cmd=(
podman run --rm -u root
--userns=keep-id
-v "$PWD:/buildroot"
--workdir /buildroot
--name "autobuilder.$$"
--env "BUILDUSER=$USER"
--entrypoint /build
"$image"
)
podman run --userns=keep-id -u root --rm -v "/tmp/$did:/buildroot" "spark:autobuilder" /build "$pkg_url"
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
rm -rf "/tmp/$did"
"${podman_cmd[@]}"

View File

@ -2,7 +2,7 @@
err() { printf '%s\n' "$*" >&2; }
build_remote() { makepkg-podman "$@"; }
build_remote() { makepkg-ci "$@"; }
cleanup() { rm -f "$lockfile"; }
lock() {