From a05d2642952d1ba506b7c63a494586186324faef Mon Sep 17 00:00:00 2001 From: Mark Vainomaa Date: Sat, 24 Sep 2016 00:24:58 +0300 Subject: [PATCH] Add initial files --- README.md | 19 +++++++++++++++++++ aur | 12 ++++++++++++ buildpkg | 45 +++++++++++++++++++++++++++++++++++++++++++++ smtpd/smtpd.conf | 8 ++++++++ smtpd/vdoms | 1 + 5 files changed, 85 insertions(+) create mode 100644 README.md create mode 100755 aur create mode 100755 buildpkg create mode 100644 smtpd/smtpd.conf create mode 100644 smtpd/vdoms diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d44f95 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# mikroskeem's AUR build bot + +NOTE: This is actually not ready, so it is not recommended to run it in production (don't be like me!) + +## Installing + +* Set up new Arch Linux nspawn container (I recommend using this [script](https://gist.github.com/artizirk/fab2ce13277a190ee6063b03b8e0a6e9) made by @artizirk) +* Install [aurutils](https://aur.archlinux.org/packages/aurutils) and set it up +* Copy `buildpkg` to `/usr/bin` in builder container +* Set up [OpenSMTPD](https://wiki.archlinux.org/index.php/OpenSMTPD) server on container and host (to send emails to builder in case of failure) + - Note: Don't forget to firewall! +* Copy `aur` script to `/usr/bin` in host machine +* Set up nginx to serve packages to host (and maybe for public) + +## Known issues +* You can't edit PKGBUILD-s +* You can't accept GPG keys automatically (insecure to do so, but you can do `gpg --recv-key ` in container shell) +* Not documentated enough! +* Probably something more I'm not currently aware of diff --git a/aur b/aur new file mode 100755 index 0000000..a2e98dc --- /dev/null +++ b/aur @@ -0,0 +1,12 @@ +#!/bin/bash +aur(){ + if [ -z "$1" ]; then + echo "aur: " + return 1 + fi + sudo machinectl shell --setenv=INVOKER="${USER}@$(hostname)" builduser@builder /usr/bin/buildpkg $1 +} + +aur $* + +# vim: set ft=sh diff --git a/buildpkg b/buildpkg new file mode 100755 index 0000000..f81a906 --- /dev/null +++ b/buildpkg @@ -0,0 +1,45 @@ +#!/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 diff --git a/smtpd/smtpd.conf b/smtpd/smtpd.conf new file mode 100644 index 0000000..3801acc --- /dev/null +++ b/smtpd/smtpd.conf @@ -0,0 +1,8 @@ +listen on host0 + +table aliases file:/etc/smtpd/aliases +table vdoms "/etc/smtpd/vdoms" + +accept for local alias deliver to mbox +accept from any for domain deliver to mbox +accept for any relay diff --git a/smtpd/vdoms b/smtpd/vdoms new file mode 100644 index 0000000..722e59f --- /dev/null +++ b/smtpd/vdoms @@ -0,0 +1 @@ +builder