aur-buildbot/buildpkg

46 lines
987 B
Plaintext
Raw Permalink Normal View History

2016-09-24 00:24:58 +03:00
#!/bin/bash
# Get package name
PACKAGE=${1}
shift
# Defaults
XDG_CACHE_HOME=${XDG_CACHE_HOME:="${HOME}/.cache"}
PKG_SOURCE_DIR="$XDG_CACHE_HOME/aursync/$PACKAGE"
MAIL_RECIPIENT=${INVOKER:="mark@Willywonka"}
if [ ! "$(whoami)" == "builduser" ]; then
su builduser -c "${0}" "${PACKAGE}"
exit
fi
# Update packages
echo "#### Updating packages"
sudo pacman --noconfirm -Syu
# aursync starts 'less' to show files, no thanks
export PAGER=cat
# Check for previous failed build and clean up
if [ -f "$PKG_SOURCE_DIR/FAILED" ]; then
echo "#### Cleaning up previous failed build"
rm -rf "$PKG_SOURCE_DIR"
fi
# Start aursync
LOGF=$(mktemp)
(
set -o pipefail
aursync -n ${PACKAGE} | tee ${LOGF}
)
# Mark package source dir failed
if [ ! $? -eq 0 ]; then
touch "$PKG_SOURCE_DIR/FAILED"
echo "#### Build failed"
cat ${LOGF} | mail -s "Build for AUR package '$PACKAGE' failed" ${MAIL_RECIPIENT}
fi
rm ${LOGF}
# vim:ft=sh