2022-12-10 23:42:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Run poudriere at system boot. Useful for virtual machines so launching the VM also kicks off a build.
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2022-12-10 23:58:09 +00:00
|
|
|
function main {
|
|
|
|
COMMAND="$1"
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
if [ "$COMMAND" = "start" ]; then
|
|
|
|
cmd_start "${@}"
|
|
|
|
elif [ "$COMMAND" = "stop" ]; then
|
|
|
|
cmd_stop "${@}"
|
|
|
|
else
|
|
|
|
die 1 "Unrecognized command: $COMMAND"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function die {
|
|
|
|
exit_code="$1"
|
|
|
|
shift 1
|
|
|
|
(>&2 echo "${@}")
|
|
|
|
exit "$exit_code"
|
|
|
|
}
|
|
|
|
|
|
|
|
function abort_if_jobs_running {
|
|
|
|
if [[ $(sudo poudriere status) != *"No running builds"* ]]; then
|
|
|
|
echo "There is already a poudriere build in progress, exiting."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function build {
|
|
|
|
poudriere pkgclean -y "$@"
|
|
|
|
poudriere bulk -J "${POUDRIERE_JOBS:-1}" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function cmd_start {
|
2022-12-11 00:01:14 +00:00
|
|
|
abort_if_jobs_running
|
|
|
|
|
2022-12-10 23:58:09 +00:00
|
|
|
# Allow command failures without quitting the script because some
|
|
|
|
# package sets might fail whereas others may succeed based on which
|
|
|
|
# packages are in each set.
|
|
|
|
set +e
|
|
|
|
|
|
|
|
for conf in /opt/poudriere/build_configs/*; do
|
|
|
|
(
|
|
|
|
source "$conf"
|
|
|
|
build -j "$JAIL" -p "$PORTS" -z "$SET" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
|
|
|
)
|
|
|
|
done
|
|
|
|
|
|
|
|
# Re-enable exiting on failed commands
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Cleanup old unused dist files
|
|
|
|
for conf in /opt/poudriere/build_configs/*; do
|
|
|
|
(
|
|
|
|
source "$conf"
|
|
|
|
poudriere distclean -y -p "$PORTS" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
|
|
|
)
|
|
|
|
done
|
|
|
|
|
|
|
|
poudriere logclean -y 180
|
|
|
|
}
|
|
|
|
|
|
|
|
function cmd_stop {
|
2022-12-11 00:02:50 +00:00
|
|
|
echo "cmd_stop not implemented."
|
2022-12-10 23:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "${@}"
|