diff options
author | BlackNoxis <steven.darklight@gmail.com> | 2014-12-03 03:21:40 +0200 |
---|---|---|
committer | BlackNoxis <steven.darklight@gmail.com> | 2014-12-03 03:21:40 +0200 |
commit | 6948327c0d51eb2eb90b367fc87ee686f1636f11 (patch) | |
tree | d6b71e52bb16aba21b545f2d30ac06798f1edcc8 /tinderbox | |
parent | 81900ddf398dba3915b748f6adc729a8aa902ae0 (diff) |
Making everything Kogaion configs public
Diffstat (limited to 'tinderbox')
-rwxr-xr-x | tinderbox/antimatter-scheduler | 23 | ||||
-rwxr-xr-x | tinderbox/glsa-scheduler | 21 | ||||
-rwxr-xr-x | tinderbox/matter-build.sh | 94 | ||||
-rwxr-xr-x | tinderbox/matter-scheduler | 64 |
4 files changed, 202 insertions, 0 deletions
diff --git a/tinderbox/antimatter-scheduler b/tinderbox/antimatter-scheduler new file mode 100755 index 0000000..690ac5a --- /dev/null +++ b/tinderbox/antimatter-scheduler @@ -0,0 +1,23 @@ +#!/bin/bash + +unset PORTAGE +unset PORTAGE_TMPDIR + +set -e + +if [ "${#}" != "3" ]; then + echo "Invalid arguments." >&2 + exit 1 +fi + +CHROOT_PATH="${1}" +ARCH_NAME="${2}" +CHROOT_PREFIX="${3}" + +( + ${CHROOT_PREFIX} chroot "${CHROOT_PATH}" \ + /kogaion/bin/antimatter-digest +) | mail -a "MIME-Version: 1.0" \ + -a "Content-Type: text/html" \ + -s "AntiMatter tracker of $(date +%Y-%m-%d) for ${ARCH_NAME}" \ + entropy@rogentos.ro diff --git a/tinderbox/glsa-scheduler b/tinderbox/glsa-scheduler new file mode 100755 index 0000000..69b5027 --- /dev/null +++ b/tinderbox/glsa-scheduler @@ -0,0 +1,21 @@ +#!/bin/bash + +unset PORTAGE +unset PORTAGE_TMPDIR + +set -e + +if [ "${#}" != "3" ]; then + echo "Invalid arguments." >&2 + exit 1 +fi + +CHROOT_PATH="${1}" +ARCH_NAME="${2}" +CHROOT_PREFIX="${3}" + +( + ${CHROOT_PREFIX} chroot "${CHROOT_PATH}" \ + /kogaion/bin/glsa-digest 2>&1 +) | mail -s "GLSA tracker of $(date +%Y-%m-%d) for ${ARCH_NAME}" \ + entropy@rogentos.ro diff --git a/tinderbox/matter-build.sh b/tinderbox/matter-build.sh new file mode 100755 index 0000000..89db7c0 --- /dev/null +++ b/tinderbox/matter-build.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +show_help() { + echo "${0} <schedule> <pre-chroot (linux32, linux64)> <chroot dir> <chroot name>" +} + +ARGS="${@}" +schedule="${1}" +if [ "${schedule}" != "weekly" ] && [ "${schedule}" != "monthly" ] && [ "${schedule}" != "daily" ]; then + echo "schedule is invalid, must be either weekly, monthly, daily" + show_help + exit 1 +fi +PRE_CHROOT="${2}" +if [ "${PRE_CHROOT}" != "linux32" ] && [ "${PRE_CHROOT}" != "linux64" ]; then + echo "pre-chroot is invalid, must be either linux32, linux64" + show_help + exit 1 +fi +CHROOT_DIR="${3}" +if [ -z "${CHROOT_DIR}" ] || [ ! -d "${CHROOT_DIR}" ]; then + echo "chroot dir is invalid" + show_help + exit 1 +fi +CHROOT_NAME="${4:-unknown}" +shift 4 + +LOCK_FILE="${CHROOT_DIR}/.matter-build.lock" +LVM_LOCK_FILE="/entropy_LOCKS/vg_chroots-lv_chroots-snapshot.lock" +LOG_FILE=/var/log/particles/$(basename "${CHROOT_DIR}")-${schedule}-$(date +%Y%m%d).log + +# Make sure th have these directories in place +mkdir -p /var/log/particles /entropy_LOCKS || exit 1 + +# Drop these settings from the environment as they could interfere +# with interactive processing +unset PORTDIR PORTAGE_TMPDIR + +echo "CHROOT_DIR: ${CHROOT_DIR}" +echo "PRE_CHROOT: ${PRE_CHROOT}" +echo "LOG_FILE: ${LOG_FILE}.bz2" + +echo "Acquiring locks at ${LOCK_FILE} and ${LVM_LOCK_FILE} in blocking mode, waiting until we're ready" +( + flock -s --timeout=$((3600 * 12)) 10 + if [ "${?}" != "0" ]; then + echo "Tried to acquire the LVM lock in shared mode." >&2 + echo "After 12 hours, I give up. This is really wrong," >&2 + echo "since the backup script should not hold the lock for" >&2 + echo "this long." >&2 + exit 1 + fi + + flock -x --timeout=36000 9 + rc="${?}" + if [ "${rc}" != "0" ]; then + echo "CANNOT ACQUIRE LOCK, QUITTING" >&2 + else + echo "Lock acquired, let's go" + echo "Starting matter-scheduler at $(date)..." + export ETP_NO_COLOR="1" + + pre_post="--pre /particles/hooks/pre.sh --post /particles/hooks/post.sh" + # Place standard outout and standard error together to make + # tee happy. Filter out stdout because it gets to mail + PARTICLES_DIR="/particles/${schedule}" \ + MATTER_ARGS="--commit --blocking --gentle --disable-preserved-libs ${pre_post} ${@}" "${PRE_CHROOT}" \ + /build/tinderbox/matter-scheduler "${CHROOT_DIR}" 2>&1 3>&1 | tee "${LOG_FILE}" > /dev/null + rc=${?} + echo "Completed matter-scheduler at $(date) with exit status: ${rc}" + fi + + bzip2 -f -k "${LOG_FILE}" + # send mail + echo "Hello boys and girls, +this is andromeda.kogaion.org informing you that a new matter run has been +eventually executed. + +Call : ${ARGS} +Exit : ${rc} +Log : ${LOG_FILE}.bz2 + +Do not forget to check logs before touching repositories. +Thanks for reading." | mutt -s "${schedule} matter run, $(basename ${LOG_FILE})" -a "${LOG_FILE}.bz2" -- entropy-team@lists.kogaion.org + + # spawn GLSA and ignore any failures + /build/tinderbox/glsa-scheduler "${CHROOT_DIR}" "${CHROOT_NAME}" "${PRE_CHROOT}" > /dev/null + # spawn AntiMatter and ignore any failures + /build/tinderbox/antimatter-scheduler "${CHROOT_DIR}" "${CHROOT_NAME}" "${PRE_CHROOT}" > /dev/null + + exit ${rc} + +) 9> "${LOCK_FILE}" 10> "${LVM_LOCK_FILE}" diff --git a/tinderbox/matter-scheduler b/tinderbox/matter-scheduler new file mode 100755 index 0000000..55055ce --- /dev/null +++ b/tinderbox/matter-scheduler @@ -0,0 +1,64 @@ +#!/usr/bin/python + +import os +import sys +import argparse +import subprocess + +if __name__ == "__main__": + + DEFAULT_PARTICLES_DIR = "/particles" + PARTICLES_DIR = os.getenv("PARTICLES_DIR", DEFAULT_PARTICLES_DIR) + DEFAULT_BUILD_DIR = "/kogaion" + BUILD_DIR = os.getenv("BUILD_GIT_DIR", DEFAULT_BUILD_DIR) + DEFAULT_MATTER_ARGS = "--commit --gentle --push --sync --sync-best-effort" + MATTER_ARGS = os.getenv("MATTER_ARGS", DEFAULT_MATTER_ARGS) + + CHROOT_SCRIPT = "/kogaion/bin/matter-scheduler-chroot" # this is in build.git + ENV_VARS_HELP = """\ +Environment variables: +%s = path inside chroot containing Matter spec files (also called particles) + default: %s +%s = path inside chroot containing the build.git repository checkout + default: %s +%s = custom "matter" arguments + default: %s +""" % ( + "PARTICLES_DIR", + DEFAULT_PARTICLES_DIR, + "BUILD_GIT_DIR", + DEFAULT_BUILD_DIR, + "MATTER_ARGS", + DEFAULT_MATTER_ARGS,) + + parser = argparse.ArgumentParser( + description='Entropy Matter, execution scheduler', + epilog=ENV_VARS_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter) + + parser.add_argument("chroot", metavar="<chroot>", + help="path to chroot") + + nsargs = parser.parse_args(sys.argv[1:]) + + chroot_dir = nsargs.chroot + if not os.path.isdir(chroot_dir): + sys.stderr.write("chroot directory is not available\n") + raise SystemExit(1) + + if os.getuid() != 0: + sys.stderr.write("root access required\n") + raise SystemExit(1) + + os.environ["PARTICLES_DIR"] = PARTICLES_DIR + os.environ["BUILD_GIT_DIR"] = BUILD_DIR + os.environ["MATTER_ARGS"] = MATTER_ARGS + os.chroot(chroot_dir) + os.chdir("/") + try: + rc = subprocess.call(CHROOT_SCRIPT) + except Exception as err: + sys.stderr.write(repr(err) + "\n") + rc = 1 + + raise SystemExit(rc) |