pungi-fedora/nightly-modular.sh
Lubomír Sedlář 4f15d62cdd Define start fedmsg json value
The nightly scripts try to send an announcement about compose starting.
As this happens before Pungi even started, the compose ID is not known
and can not be included in the message. The message about starting rsync
sent later will contain the ID correctly.

Without the json defined there is a traceback in the cron output, but
the errors are not logged anywhere else (but don't actually block
anything in the compose process).

Relates: https://pagure.io/pungi/issue/698
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
2017-08-08 08:54:27 +02:00

66 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
#set -x
export LC_ALL=C
CONFIG="fedora-modular.conf"
TARGET_DIR="/mnt/koji/compose/"
#OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=$TARGET_DIR"
NIGHTLY="--nightly"
SKIP_PHASES="--skip-phase=productimg"
DEST=$(pwd)
DATE=$(date "+%Y%m%d")
DIST="rawhide"
BRANCHED="Modular-Rawhide"
BRANCH="rawhide"
GIT_BRANCH="master"
TMPDIR=`mktemp -d /tmp/$DIST.$DATE.XXXX`
TOMAIL="devel@lists.fedoraproject.org test@lists.fedoraproject.org"
FROM="Fedora Rawhide Report <rawhide@fedoraproject.org>"
RSYNCPREFIX="sudo -u ftpsync"
ATOMIC=$(mktemp -d /tmp/atomic.${DIST}.$DATE.XXXX)
ATOMICREPO="/mnt/koji/compose/atomic/$BRANCHED/"
ATOMICDEST="/mnt/koji/atomic/$BRANCHED/"
OLDCOMPOSE_ID=$(cat $TARGET_DIR/latest-Fedora-Modular-Rawhide/COMPOSE_ID)
# assume a releng dir is a git checkout of the releng repo
# if it does not exist clone it
if [ -d releng ]; then
pushd releng
git pull --rebase
popd
else
git clone https://pagure.io/releng.git
fi
# Set up our fedmsg function, using the releng repo definition
FEDMSG_MODNAME="compose"
FEDMSG_CERTPREFIX="releng"
. ./releng/scripts/fedmsg-functions.sh
# Announce that we are starting, even though we don't know the compose_id yet..
fedmsg_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s"}' "$BRANCHED" "$ARCH")
send_fedmsg "${fedmsg_json_start}" ${DIST} start
CMD="pungi-koji --config=$CONFIG --old-composes=$TARGET_DIR $OLD_COMPOSES_DIR $NIGHTLY $SKIP_PHASES"
if [ -z "$COMPOSE_ID" ]; then
CMD="$CMD --target-dir=$TARGET_DIR"
else
CMD="$CMD --debug-mode --compose-dir=$TARGET_DIR/$COMPOSE_ID"
fi
time $CMD "$@"
NEWCOMPOSE_ID=$(cat $TARGET_DIR/latest-Fedora-Modular-Rawhide/COMPOSE_ID)
SHORTCOMPOSE_ID=$(echo $NEWCOMPOSE_ID|sed -e 's|Fedora-Modular.*-||g')
fedmsg_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s", "compose_id": "%s"}' "$BRANCHED" "$ARCH" "$NEWCOMPOSE_ID")
fedmsg_json_done=$(printf '{"log": "done", "branch": "%s", "arch": "%s", "compose_id": "%s"}' "$BRANCHED" "$ARCH" "$NEWCOMPOSE_ID")
# Tell everyone by fedmsg about the compose
send_fedmsg "${fedmsg_json_done}" ${DIST} complete
# Remove old composes older than 14 days
find $TARGET_DIR/Fedora-Modular-Rawhide* -xdev -depth -maxdepth 2 -mtime +14 -exec rm -rf {} \;