2008-09-04 01:18:17 +00:00
|
|
|
#!/bin/bash
|
2014-09-10 19:52:48 +00:00
|
|
|
# Copyright 1999-2014 Gentoo Foundation
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
2008-09-04 01:18:17 +00:00
|
|
|
|
2016-03-21 05:21:05 +00:00
|
|
|
CATALYST_CONFIG=/etc/catalyst/catalyst.conf
|
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
# Probe the default source dir from this script name.
|
|
|
|
REPO_DIR=$(dirname "$(dirname "$(realpath "$0")")")
|
|
|
|
|
|
|
|
# Set up defaults that config files can override if they want.
|
|
|
|
SUBARCH=$(uname -m)
|
|
|
|
EMAIL_TO="releng@gentoo.org,gentoo-releng-autobuilds@lists.gentoo.org"
|
|
|
|
# Use full hostname by default as Gentoo servers will reject short names.
|
|
|
|
EMAIL_FROM="catalyst@$(hostname -f)"
|
|
|
|
EMAIL_SUBJECT_PREPEND="[${SUBARCH}-auto]"
|
|
|
|
|
|
|
|
# Variables updated by command line arguments.
|
2016-01-26 07:17:34 +00:00
|
|
|
declare -a config_files
|
|
|
|
config_files=()
|
2008-09-04 01:19:35 +00:00
|
|
|
verbose=0
|
2008-09-28 20:15:21 +00:00
|
|
|
keep_tmpdir=0
|
2009-03-13 12:34:18 +00:00
|
|
|
testing=0
|
2016-03-21 05:27:34 +00:00
|
|
|
preclean=0
|
2016-03-21 05:34:12 +00:00
|
|
|
lastrun=0
|
2016-03-23 18:20:52 +00:00
|
|
|
lock_file=
|
2008-09-04 01:19:35 +00:00
|
|
|
|
2008-09-04 01:18:17 +00:00
|
|
|
usage() {
|
2020-05-31 16:32:02 +00:00
|
|
|
local msg=$1
|
2008-09-04 01:18:17 +00:00
|
|
|
|
2020-05-31 16:32:02 +00:00
|
|
|
if [ -n "${msg}" ]; then
|
|
|
|
printf "%b\n\n" "${msg}"
|
|
|
|
fi
|
2008-09-04 01:18:17 +00:00
|
|
|
|
2020-05-31 16:32:02 +00:00
|
|
|
cat <<EOH
|
2008-09-04 01:18:17 +00:00
|
|
|
Usage:
|
2017-12-15 18:40:07 +00:00
|
|
|
catalyst-auto [-c|--config <config>] [-v|--verbose] [-h|--help]
|
2008-09-04 01:18:17 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
-c|--config Specifies the config file to use (required)
|
2016-03-21 05:27:34 +00:00
|
|
|
-C|--preclean Clean up loose artifacts from previous runs
|
2011-12-02 05:15:46 +00:00
|
|
|
-v|--verbose Send output of commands to console as well as log
|
2009-01-02 01:50:52 +00:00
|
|
|
-k|--keep-tmpdir Don't remove temp dir when build finishes
|
2009-03-13 12:34:18 +00:00
|
|
|
-t|--test Stop after mangling specs and copying files
|
2016-03-21 05:34:12 +00:00
|
|
|
--interval <days> Exit if last successful run was less than <days> ago
|
2016-03-23 18:20:52 +00:00
|
|
|
-l|--lock <file> File to grab a lock on to prevent multiple invocations
|
2008-09-04 01:18:17 +00:00
|
|
|
-h|--help Show this message and quit
|
|
|
|
|
|
|
|
EOH
|
|
|
|
}
|
|
|
|
|
|
|
|
send_email() {
|
2020-05-31 16:32:02 +00:00
|
|
|
local subject="${EMAIL_SUBJECT_PREPEND} $1"
|
|
|
|
local message=$2
|
|
|
|
local logfile=$3
|
|
|
|
local body
|
|
|
|
|
|
|
|
if [ -n "${logfile}" ]; then
|
|
|
|
body=$(printf '%b\n\n\n' "${message}"; tail -n 200 "${logfile}"; printf '\n\n\nFull build log at %s\n' "${logfile}")
|
|
|
|
else
|
|
|
|
body=${message}
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%b' \
|
|
|
|
"${EMAIL_FROM}" "${EMAIL_TO}" "${subject}" "${body}" | \
|
|
|
|
/usr/sbin/sendmail -f "${EMAIL_FROM}" ${EMAIL_TO//,/ }
|
2008-09-04 01:18:17 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 04:51:29 +00:00
|
|
|
# Usage: run_cmd <logfile> <command to run>
|
2008-09-04 01:18:17 +00:00
|
|
|
run_cmd() {
|
2020-05-31 16:32:02 +00:00
|
|
|
local logfile="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
echo "*** Running command: $*" &>> "${logfile}"
|
|
|
|
if [[ ${verbose} == 2 ]]; then
|
|
|
|
echo "*** Running command: $*"
|
|
|
|
"$@" 2>&1 | tee -a "${logfile}"
|
|
|
|
elif [[ ${verbose} == 1 ]]; then
|
|
|
|
echo "*** Running command: $*"
|
|
|
|
"$@" &>> "${logfile}"
|
|
|
|
else
|
|
|
|
"$@" &>> "${logfile}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we used tee above, make sure we pass back up the command's error.
|
|
|
|
return ${PIPESTATUS[0]}
|
2008-09-04 01:18:17 +00:00
|
|
|
}
|
|
|
|
|
2016-05-05 10:07:20 +00:00
|
|
|
update_symlinks() {
|
2020-05-31 16:32:02 +00:00
|
|
|
# This is a skeleton function that you can override from the config file.
|
|
|
|
# It will be called by pre_build and after completing the build of a set
|
|
|
|
# to ensure the symlinks point to the latest built stages.
|
|
|
|
:
|
2016-05-05 10:07:20 +00:00
|
|
|
}
|
|
|
|
|
2008-09-28 04:31:49 +00:00
|
|
|
pre_build() {
|
2020-05-31 16:32:02 +00:00
|
|
|
# This is a skeleton function that you can override from the config file.
|
|
|
|
# It will be executed before the build is started.
|
|
|
|
update_symlinks
|
2008-09-28 04:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
post_build() {
|
2020-05-31 16:32:02 +00:00
|
|
|
# This is a skeleton function that you can override from the config file.
|
|
|
|
# It will be executed after the build is successfully completed. You can
|
|
|
|
# use this to rsync the builds to another box
|
|
|
|
:
|
2008-09-28 04:31:49 +00:00
|
|
|
}
|
|
|
|
|
2016-03-21 05:21:05 +00:00
|
|
|
catalyst_var() {
|
2020-05-31 16:32:02 +00:00
|
|
|
# Extract a setting from the catalyst.conf.
|
|
|
|
local var=$1
|
|
|
|
(. "${CATALYST_CONFIG}"; echo "${!var}")
|
2016-03-21 05:21:05 +00:00
|
|
|
}
|
|
|
|
|
2017-12-15 03:44:41 +00:00
|
|
|
trigger_post_build() {
|
2018-01-16 01:52:14 +00:00
|
|
|
local set=$1 spec=$2
|
|
|
|
if ! run_cmd "${TMPDIR}/log/post_build.log" post_build "${set}" "${spec}"; then
|
|
|
|
send_email "Catalyst build error - post_build" "The post_build function failed" "${TMPDIR}/log/post_build.log"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-12-15 03:44:41 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
parse_args() {
|
|
|
|
local a
|
|
|
|
while [[ $# -gt 0 ]] ; do
|
|
|
|
a=$1
|
|
|
|
shift
|
|
|
|
case "${a}" in
|
|
|
|
-h|--help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-c|--config)
|
|
|
|
config_files+=("$1")
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v|--verbose)
|
|
|
|
verbose=$(($verbose+1))
|
|
|
|
;;
|
|
|
|
-k|--keep-tmpdir)
|
|
|
|
keep_tmpdir=1
|
|
|
|
;;
|
|
|
|
-t|--test)
|
|
|
|
testing=1
|
|
|
|
;;
|
|
|
|
-C|--preclean)
|
|
|
|
preclean=1
|
|
|
|
;;
|
|
|
|
--interval)
|
|
|
|
lastrun=$1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-l|--lock)
|
|
|
|
lock_file=$1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
usage "ERROR: You have specified an invalid option: ${a}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage "ERROR: This script takes no arguments: ${a}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
2009-11-02 13:31:26 +00:00
|
|
|
|
2019-09-02 02:04:59 +00:00
|
|
|
give_latest_from_dates() {
|
2020-05-31 16:32:02 +00:00
|
|
|
sed 's,-20,~20,g' | \
|
|
|
|
sort -k +1 -n -t '~' | \
|
|
|
|
awk -F'~' \
|
|
|
|
'BEGIN{i=$1; o=$0};
|
|
|
|
{ if($1 != i && i != "") { print o; }; i=$1; o=$0; }
|
|
|
|
END { print o; };' | \
|
|
|
|
tr '~' '-'
|
2019-09-02 02:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Replace the date/time stamp in the filename to "latest".
|
|
|
|
# Forms we handle:
|
|
|
|
# stage3-xxx-2018.0.tar.bz2
|
|
|
|
# stage3-xxx-20180116.tar.bz2
|
|
|
|
# stage3-xxx-20180116T015819Z.tar.bz2
|
|
|
|
convert_filename() {
|
|
|
|
sed -E 's:-20[0-9]+(\.[0-9]+|T[0-9]+Z)?:-latest:g'
|
|
|
|
}
|
|
|
|
|
2018-01-16 01:13:59 +00:00
|
|
|
# Let's get our own namespaces/etc... to avoid leaking crap.
|
|
|
|
containerize() {
|
|
|
|
# If we've already relaunched, nothing to do.
|
|
|
|
if [[ ${UNSHARE} == "true" ]] ; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Most systems have unshare available, but just in case.
|
|
|
|
if type -P unshare >&/dev/null ; then
|
|
|
|
local uargs=()
|
|
|
|
# Probe the namespaces as some can be disabled (or we are not root).
|
|
|
|
unshare -m -- true >&/dev/null && uargs+=( -m )
|
|
|
|
unshare -u -- true >&/dev/null && uargs+=( -u )
|
|
|
|
unshare -i -- true >&/dev/null && uargs+=( -i )
|
|
|
|
unshare -p -- true >&/dev/null && uargs+=( -p -f --mount-proc )
|
|
|
|
# Re-exec ourselves in the new namespace.
|
|
|
|
UNSHARE=true exec unshare "${uargs[@]}" -- "$0" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-16 01:17:43 +00:00
|
|
|
# Update the git repo if possible. It might modify this script which will probably
|
|
|
|
# make bash fail (since bash parses as it executes). So we have to safely re-exec
|
|
|
|
# the script whenever there's an update.
|
|
|
|
git_update() {
|
|
|
|
# If we've already relaunched, nothing to do.
|
|
|
|
if [[ ${GIT_UPDATE} == "true" ]] ; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd "${REPO_DIR}" >/dev/null
|
|
|
|
git fetch -q
|
|
|
|
revs=$(git rev-list HEAD..FETCH_HEAD)
|
|
|
|
popd >/dev/null
|
|
|
|
if [[ -n ${revs} ]] ; then
|
|
|
|
GIT_UPDATE=true exec bash -c '
|
|
|
|
repo_dir=$1 script=$2
|
|
|
|
shift 2
|
|
|
|
pushd "${repo_dir}" >/dev/null
|
2018-01-16 16:24:43 +00:00
|
|
|
git merge -q FETCH_HEAD || echo "${script}: WARNING: git repo is dirty"
|
2018-01-16 01:17:43 +00:00
|
|
|
popd >/dev/null
|
|
|
|
exec "${script}" "$@"
|
|
|
|
' -- "${REPO_DIR}" "$0" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-04-26 04:52:40 +00:00
|
|
|
# Stages are uploaded to <arch>@releng-incoming.gentoo.org and in order to
|
|
|
|
# allow us to change what system this domain points to, we will retrieve the
|
|
|
|
# SSH fingerprint from DNS. To do this securely, we need to ensure DNSSEC is
|
|
|
|
# working.
|
|
|
|
verify_dnssec() {
|
|
|
|
which dig >/dev/null || {
|
|
|
|
echo "net-dns/bind-tools is needed to verify DNSSEC is working"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! dig +noall +comments dev.gentoo.org. IN SSHFP | egrep -q '^;; flags: [ a-z]+\<ad\>'; then
|
|
|
|
echo "DNSSEC does not appear to be working. Bailing out"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-26 05:23:48 +00:00
|
|
|
|
2020-05-08 04:59:19 +00:00
|
|
|
if ! grep -q '^options\>.*\<edns0\>' /etc/resolv.conf; then
|
2020-04-26 05:23:48 +00:00
|
|
|
echo "DNSSEC is not enabled in /etc/resolv.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-26 04:52:40 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
run_catalyst_commands() {
|
|
|
|
doneconfig=0
|
|
|
|
for config_file in "${config_files[@]}"; do
|
|
|
|
# Make sure all required values were specified.
|
|
|
|
if [[ -z "${config_file}" || ! -e "${config_file}" ]]; then
|
|
|
|
usage "ERROR: You must specify a valid config file to use: '$config_file' is not valid"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
source "${config_file}"
|
|
|
|
doneconfig=1
|
|
|
|
done
|
|
|
|
if [[ ${doneconfig} == 0 ]]; then
|
|
|
|
usage "ERROR: You must specify at least one valid config file to use"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Some configs will set this explicitly, so don't clobber it.
|
|
|
|
: ${BUILD_SRCDIR_BASE:=$(catalyst_var storedir)}
|
2020-04-30 23:12:56 +00:00
|
|
|
: ${BUILD_SRCDIR_BASE:=/var/tmp/catalyst}
|
2018-01-16 01:11:44 +00:00
|
|
|
|
|
|
|
# See if we had a recent success.
|
|
|
|
if [[ ${lastrun} != 0 ]]; then
|
|
|
|
last_success_file="${BUILD_SRCDIR_BASE}/.last_success"
|
|
|
|
delay=$(( lastrun * 24 * 60 * 60 ))
|
|
|
|
last_success=$(head -1 "${last_success_file}" 2>/dev/null || echo 0)
|
|
|
|
if [[ $(date +%s) -lt $(( last_success + delay )) ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-05-31 16:43:59 +00:00
|
|
|
# Nuke any previous tmpdirs to keep them from accumulating.
|
|
|
|
if [[ ${preclean} == 1 ]]; then
|
|
|
|
rm -rf "${TMP_PATH:-/tmp}/catalyst-auto".*
|
|
|
|
|
|
|
|
snapshot_cache=$(catalyst_var snapshot_cache)
|
|
|
|
if [[ -z ${snapshot_cache} ]]; then
|
|
|
|
echo "error: snapshot_cache not set in config file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
pushd "${BUILD_SRCDIR_BASE}" >/dev/null || exit 1
|
|
|
|
rm -rf --one-file-system \
|
|
|
|
kerncache packages snapshots tmp "${snapshot_cache}"/*
|
|
|
|
popd >/dev/null
|
|
|
|
fi
|
|
|
|
|
2020-04-30 04:49:10 +00:00
|
|
|
if catalyst --help | grep -q "git-treeish"; then
|
|
|
|
snapshot_log=$(mktemp --tmpdir="${TMP_PATH:-/tmp}")
|
|
|
|
if ! run_cmd "${snapshot_log}" catalyst -c "${CATALYST_CONFIG}" -s stable; then
|
|
|
|
send_email "Catalyst build error - snapshot" "" "${snapshot_log}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
read TREEISH gitdir <<<$(egrep -o 'Creating .* tree snapshot [0-9a-f]{40} from .*' "${snapshot_log}" | cut -d' ' -f5,7)
|
|
|
|
TIMESTAMP=$(git -C "${gitdir}" show --no-patch --format=%cd --date=format:%Y%m%dT%H%M%SZ "${TREEISH}")
|
|
|
|
else
|
|
|
|
TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)
|
|
|
|
|
|
|
|
snapshot_log=$(mktemp --tmpdir="${TMP_PATH:-/tmp}")
|
|
|
|
if ! run_cmd "${snapshot_log}" catalyst -c "${CATALYST_CONFIG}" -s "${TIMESTAMP}"; then
|
|
|
|
send_email "Catalyst build error - snapshot" "" "${snapshot_log}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2020-05-11 18:53:55 +00:00
|
|
|
DATESTAMP=$(date -u +%Y%m%d)
|
2018-01-16 01:11:44 +00:00
|
|
|
TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" "catalyst-auto.${TIMESTAMP}.XXXXXX")
|
|
|
|
|
|
|
|
if [[ ${verbose} -ge 1 ]]; then
|
|
|
|
echo "TMPDIR = ${TMPDIR}"
|
|
|
|
echo "TIMESTAMP = ${TIMESTAMP}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! mkdir -p "${TMPDIR}"/{specs,kconfig,log}; then
|
|
|
|
echo "Couldn't create tempdirs!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-30 04:49:10 +00:00
|
|
|
mv "${snapshot_log}" "${TMPDIR}/log/snapshot.log"
|
2018-01-16 01:11:44 +00:00
|
|
|
|
|
|
|
if ! run_cmd "${TMPDIR}/log/pre_build.log" pre_build; then
|
|
|
|
send_email "Catalyst build error - pre_build" "The pre_build function failed" "${TMPDIR}/log/pre_build.log"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "${SPECS_DIR}" || exit 1
|
|
|
|
|
|
|
|
for a in "" ${SETS}; do
|
|
|
|
if [[ -z "${a}" ]]; then
|
|
|
|
specs_var="SPECS"
|
|
|
|
optional_specs_var="OPTIONAL_SPECS"
|
|
|
|
else
|
|
|
|
specs_var="SET_${a}_SPECS"
|
|
|
|
optional_specs_var="SET_${a}_OPTIONAL_SPECS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in ${!specs_var} ${!optional_specs_var}; do
|
|
|
|
cp --parents "${i}" "${TMPDIR}"/specs/
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
find "${KCONFIG_DIR}" -type f -exec cp {} "${TMPDIR}"/kconfig \;
|
|
|
|
|
|
|
|
cd "${TMPDIR}/specs" || exit 1
|
|
|
|
|
|
|
|
# Fix up specs with datestamp
|
|
|
|
for i in $(find -name '*.spec'); do
|
|
|
|
kconfig_lines=$(grep '^boot/kernel/[^/]\+/config:' "${i}")
|
|
|
|
if [[ -n ${kconfig_lines} ]]; then
|
|
|
|
echo "${kconfig_lines}" | while read line; do
|
|
|
|
key=$(echo "${line}" | cut -d: -f1)
|
|
|
|
filename=$(basename $(echo "${line}" | cut -d: -f2))
|
|
|
|
sed -i "s|^${key}:.*\$|${key}: ${TMPDIR}/kconfig/${filename}|" "${i}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-04-30 04:49:10 +00:00
|
|
|
if [[ -n ${TREEISH} ]]; then
|
|
|
|
sed -i -e "s|snapshot:.*|snapshot_treeish: ${TREEISH}|g" "${i}"
|
|
|
|
fi
|
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
# Expand vars that the spec expects us to.
|
|
|
|
sed -i \
|
|
|
|
-e "s:@TIMESTAMP@:${TIMESTAMP}:g" \
|
|
|
|
-e "s:@REPO_DIR@:${REPO_DIR}:g" \
|
2020-04-30 04:49:10 +00:00
|
|
|
-e "s:@TREEISH@:${TREEISH}:g" \
|
2018-01-16 01:11:44 +00:00
|
|
|
"${i}"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ${testing} == 1 ]]; then
|
|
|
|
echo "Exiting due to --test"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
build_failure=0
|
|
|
|
|
|
|
|
timeprefix=()
|
|
|
|
which time >/dev/null && timeprefix=( "time" )
|
|
|
|
|
|
|
|
for a in "" ${SETS}; do
|
|
|
|
if [[ -z ${a} ]]; then
|
|
|
|
specs_var="SPECS"
|
|
|
|
optional_specs_var="OPTIONAL_SPECS"
|
|
|
|
else
|
|
|
|
specs_var="SET_${a}_SPECS"
|
|
|
|
optional_specs_var="SET_${a}_OPTIONAL_SPECS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in ${!specs_var}; do
|
|
|
|
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
2020-05-12 05:47:03 +00:00
|
|
|
specpath=$(readlink -f "${i}")
|
|
|
|
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
2018-01-16 01:11:44 +00:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
build_failure=1
|
|
|
|
send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}"
|
|
|
|
continue 2
|
|
|
|
else
|
2018-01-16 01:52:14 +00:00
|
|
|
trigger_post_build "${a}" "${i}"
|
2018-01-16 01:11:44 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in ${!optional_specs_var}; do
|
|
|
|
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
2020-05-12 05:47:03 +00:00
|
|
|
specpath=$(readlink -f "${i}")
|
|
|
|
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
2018-01-16 01:11:44 +00:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
build_failure=1
|
|
|
|
send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}"
|
|
|
|
break
|
|
|
|
else
|
2018-01-16 01:52:14 +00:00
|
|
|
trigger_post_build "${a}" "${i}"
|
2018-01-16 01:11:44 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-05-12 05:46:34 +00:00
|
|
|
# Do not purge yet, because there might be interdendency between specs
|
|
|
|
# in different build sets!
|
|
|
|
|
|
|
|
update_symlinks
|
|
|
|
done
|
|
|
|
|
|
|
|
# Now do the cleanup
|
|
|
|
for a in "" ${SETS}; do
|
|
|
|
if [[ -z ${a} ]]; then
|
|
|
|
specs_var="SPECS"
|
|
|
|
optional_specs_var="OPTIONAL_SPECS"
|
|
|
|
else
|
|
|
|
specs_var="SET_${a}_SPECS"
|
|
|
|
optional_specs_var="SET_${a}_OPTIONAL_SPECS"
|
|
|
|
fi
|
2018-01-16 01:11:44 +00:00
|
|
|
for i in ${!specs_var} ${!optional_specs_var}; do
|
|
|
|
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::')_purge.log"
|
2020-05-12 05:47:03 +00:00
|
|
|
specpath=$(readlink -f "${i}")
|
|
|
|
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst --purgetmponly -c "${CATALYST_CONFIG}" -f "${specpath}"
|
2018-01-16 01:11:44 +00:00
|
|
|
done
|
|
|
|
update_symlinks
|
|
|
|
done
|
|
|
|
|
|
|
|
trigger_post_build
|
|
|
|
|
|
|
|
if [[ ${build_failure} == 0 ]]; then
|
|
|
|
if [[ ${lastrun} != 0 ]]; then
|
|
|
|
stamp=$(date)
|
|
|
|
(date -d"${stamp}" +%s; echo "${stamp}") >"${last_success_file}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
send_email "Catalyst build success" "Build process complete."
|
|
|
|
|
|
|
|
if [[ ${keep_tmpdir} == 0 ]]; then
|
|
|
|
if ! rm -rf "${TMPDIR}"; then
|
|
|
|
echo "Could not remove tmpdir ${TMPDIR}!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
2016-05-30 16:13:32 +00:00
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
main() {
|
|
|
|
# Set pipefail so that run_cmd returns the right value in $?.
|
|
|
|
set -o pipefail
|
2008-11-29 02:15:02 +00:00
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
# Parse user arguments before we try doing container logic.
|
|
|
|
parse_args "$@"
|
2016-03-21 05:34:12 +00:00
|
|
|
|
2018-01-16 01:17:43 +00:00
|
|
|
# Update the release git dir if possible.
|
|
|
|
git_update "$@"
|
|
|
|
|
2020-04-26 04:52:40 +00:00
|
|
|
# Verify DNSSEC works
|
|
|
|
verify_dnssec
|
|
|
|
|
2018-01-16 01:13:59 +00:00
|
|
|
# Try to isolate ourselves from the rest of the system.
|
|
|
|
containerize "$@"
|
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
(
|
|
|
|
if [[ -n ${lock_file} ]]; then
|
|
|
|
if ! flock -n 9; then
|
|
|
|
echo "catalyst-auto already running"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2008-09-04 02:07:52 +00:00
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
run_catalyst_commands
|
|
|
|
) 9>"${lock_file:-/dev/null}"
|
|
|
|
}
|
2016-03-23 18:20:52 +00:00
|
|
|
|
2018-01-16 01:11:44 +00:00
|
|
|
main "$@"
|