#!/bin/sh

set -eu

die () {
	printf >&2 "%s\\n" "$@"
	exit 1
}

# check running from within an `aports` tree
if [ "${PWD%*/aports/*}" = "$PWD" ]; then
	die "Error: expecting to be run from within an aports tree!" \
		"Could not find '/aports/' in the current path: $PWD"
fi

podman run \
	--workdir /home/builder/aports/"${PWD#*/aports/}" \
	{{ podman_args }} \
	{{ container_image_repo }} \
	/usr/bin/abuild "$@"
