fd9eb12
#!/bin/sh
fd9eb12
export LC_ALL=C
fd9eb12
LABEL=$1
fd9eb12
CONFIG="fedora-atomic.conf"
fd9eb12
TARGET_DIR="/mnt/koji/compose/twoweek"
fd9eb12
#OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=$TARGET_DIR"
fd9eb12
NIGHTLY=""
fd9eb12
SKIP_PHASES="--skip-phase=productimg --skip-phase=extra_files"
fd9eb12
DEST=$(pwd)
fd9eb12
DATE=$(date "+%Y%m%d")
fd9eb12
DIST="26"
fd9eb12
BRANCHED="26"
fd9eb12
BRANCH="branched"
fd9eb12
COMPSFILE="comps-f26.xml"
fd9eb12
GIT_BRANCH="f26"
fd9eb12
TMPDIR=`mktemp -d /tmp/$DIST.$DATE.XXXX`
fd9eb12
TOMAIL="devel@lists.fedoraproject.org test@lists.fedoraproject.org"
fd9eb12
FROM="Fedora Branched Report <rawhide@fedoraproject.org>"
fd9eb12
RSYNCPREFIX="sudo -u ftpsync"
fd9eb12
ATOMIC=$(mktemp -d /tmp/atomic.${DIST}.$DATE.XXXX)
fd9eb12
ATOMICREPO="/mnt/koji/compose/atomic/$BRANCHED/"
fd9eb12
ATOMICDEST="/pub/fedora/linux/atomic/$BRANCHED/"
fd9eb12
OLDCOMPOSE_ID=$(cat $TARGET_DIR/latest-Fedora-Atomic-26/COMPOSE_ID)
fd9eb12
# uncomment and edit for resuming a failed compose
fd9eb12
#COMPOSE_ID="Fedora-23-20150530.n.0"
fd9eb12
# assume a releng dir is a git checkout of teh releng repo
fd9eb12
# if it does not exist clone it
fd9eb12
if [ -d releng ]; then
fd9eb12
    pushd releng
fd9eb12
    git pull --rebase
fd9eb12
    popd
fd9eb12
else
fd9eb12
    git clone https://pagure.io/releng.git
fd9eb12
fi
fd9eb12
# Set up our fedmsg function, using the releng repo definition
fd9eb12
fedmsg_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s"}' "$BRANCHED" "$ARCH")
fd9eb12
fedmsg_json_done=$(printf '{"log": "done", "branch": "%s", "arch": "%s"}' "$BRANCHED" "$ARCH")
fd9eb12
FEDMSG_MODNAME="compose"
fd9eb12
FEDMSG_CERTPREFIX="releng"
fd9eb12
. ./releng/scripts/fedmsg-functions.sh
fd9eb12
# Announce that we are starting...
fd9eb12
send_fedmsg "${fedmsg_json_start}" ${DIST} start
fd9eb12
pushd $TMPDIR
fd9eb12
git clone https://pagure.io/fedora-comps.git && {
fd9eb12
    pushd fedora-comps
fd9eb12
    make "${COMPSFILE}"
fd9eb12
    cp "${COMPSFILE}" $DEST/
fd9eb12
    popd
fd9eb12
}
fd9eb12
popd
fd9eb12
CMD="pungi-koji --notification-script=/usr/bin/pungi-fedmsg-notification --config=$CONFIG --old-composes=$TARGET_DIR $OLD_COMPOSES_DIR $NIGHTLY $SKIP_PHASES --label=$LABEL"
fd9eb12
if [ -z "$COMPOSE_ID" ]; then
fd9eb12
    CMD="$CMD --target-dir=$TARGET_DIR"
fd9eb12
else
fd9eb12
    CMD="$CMD --debug-mode --compose-dir=$TARGET_DIR/$COMPOSE_ID"
fd9eb12
fi
fd9eb12
time $CMD "$@"
fd9eb12
if [ "$?" = "0" ]; then
fd9eb12
   export mail=0
fd9eb12
fi
fd9eb12
NEWCOMPOSE_ID=$(cat $TARGET_DIR/latest-Fedora-Atomic-26/COMPOSE_ID)
fd9eb12
SHORTCOMPOSE_ID=$(echo $NEWCOMPOSE_ID|sed -e 's|Fedora-.*-||g')
fd9eb12
DESTDIR=$TARGET_DIR/$NEWCOMPOSE_ID
fd9eb12
$RSYNCPREFIX mkdir -p $DESTDIR
fd9eb12
# Tell interested persons that the rsync is starting (zomg!)
fd9eb12
send_fedmsg "${fedmsg_json_start}" ${DIST} rsync.start
fd9eb12
for dir in Atomic CloudImages Docker metadata ;
fd9eb12
  do
fd9eb12
    $RSYNCPREFIX rsync -avhH $TARGET_DIR/$NEWCOMPOSE_ID/compose/$dir/ /pub/alt/atomic/testing/$SHORTCOMPOSE_ID/$dir/ ;
fd9eb12
    $RSYNCPREFIX ./releng/scripts/build_composeinfo /pub/alt/atomic/testing/$SHORTCOMPOSE_ID/ --name $NEWCOMPOSE_ID
fd9eb12
  done
fd9eb12
# Tell interested persons that the rsync is done.
fd9eb12
send_fedmsg "${fedmsg_json_done}" ${DIST} rsync.complete
fd9eb12
# Tell everyone by fedmsg about the compose
fd9eb12
send_fedmsg "${fedmsg_json_done}" ${DIST} complete
fd9eb12
SUBJECT='Fedora '$DIST' compose report: '$SHORTCOMPOSE_ID' changes'
fd9eb12
#if [ "$mail" = "0" ]; then
fd9eb12
#    for tomail in $TOMAIL ; do
fd9eb12
#        cat $TARGET_DIR/$NEWCOMPOSE_ID/logs/*verbose $DESTDIR/logs/depcheck | \
fd9eb12
#             mutt -e "set from=\"$FROM\"" -e 'set envelope_from=yes' -s "$SUBJECT" $tomail
fd9eb12
#    done
fd9eb12
#fi