| |
@@ -1,32 +1,143 @@
|
| |
#!/bin/sh
|
| |
+ # This script can be run in dry mode by adding the -d option.
|
| |
+ # The -d option is a POSITIONAL argument and must be added AFTER the label.
|
| |
+ # Example usage: `./release-candidate.sh 39_Beta-1.3 -d`
|
| |
export LC_ALL=C
|
| |
+ # Remove the label from arguments. It gets special treatment.
|
| |
+ # Other arguments to the script are passed to `pungi-koji` directly.
|
| |
LABEL=$1
|
| |
- # Remove the label from arguments. It gets special treatment. Other arguments
|
| |
- # to the script are passed to pungi-koji directly.
|
| |
shift
|
| |
CONFIG="fedora-final.conf"
|
| |
- TARGET_DIR="/mnt/koji/compose/39"
|
| |
- #OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=$TARGET_DIR"
|
| |
+ # Extract the Fedora version from the label. Example label: 39_Beta-1.1
|
| |
+ FEDORA_VERSION="${LABEL%%_*}"
|
| |
+ TARGET_DIR="/mnt/koji/compose/${FEDORA_VERSION}"
|
| |
+ # OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=${TARGET_DIR}"
|
| |
NIGHTLY=""
|
| |
SKIP_PHASES="--skip-phase=productimg"
|
| |
DEST=$(pwd)
|
| |
DATE=$(date "+%Y%m%d")
|
| |
- COMPSFILE="comps-f39.xml"
|
| |
- TMPDIR=`mktemp -d /tmp/fedoraRC.$DATE.XXXX`
|
| |
- # uncomment and edit for resuming a failed compose
|
| |
- #COMPOSE_ID="Fedora-23-20150530.n.0"
|
| |
- pushd $TMPDIR
|
| |
- git clone https://pagure.io/fedora-comps.git && {
|
| |
- pushd fedora-comps
|
| |
- make "${COMPSFILE}"
|
| |
- cp "${COMPSFILE}" $DEST/
|
| |
+ # Comps file nomenclature example: comps-f39.xml
|
| |
+ COMPSFILE="comps-f${FEDORA_VERSION}.xml"
|
| |
+ TMPDIR=$(mktemp -d /tmp/fedoraRC."${DATE}".XXXX)
|
| |
+ RELEASE="f${FEDORA_VERSION}"
|
| |
+ SHORT="Fedora"
|
| |
+ RSYNCPREFIX="sudo -u ftpsync"
|
| |
+ RSYNCTARGET="/pub/alt/stage/${LABEL}"
|
| |
+ # Uncomment and edit for resuming a failed compose, e.g. "COMPOSE_ID="Fedora-23-20150530.n.0"
|
| |
+ # COMPOSE_ID="Fedora-23-20150530.n.0"
|
| |
+
|
| |
+ # Find out if the dry run (-d) option was invoked.
|
| |
+ DRY_RUN=false
|
| |
+ while getopts 'd' opt; do
|
| |
+ case "$opt" in
|
| |
+ d) DRY_RUN=true ;;
|
| |
+ *) echo "Error in command line parsing." >&2
|
| |
+ exit 1
|
| |
+ esac
|
| |
+ done
|
| |
+
|
| |
+ if "$DRY_RUN"; then
|
| |
+ echo "===== DRY RUN ====="
|
| |
+ CMD_PREFIX="echo"
|
| |
+ else
|
| |
+ CMD_PREFIX=''
|
| |
+ fi
|
| |
+
|
| |
+ echo "===== ASSUME THAT THE RELENG REPOSITORY IS AVAILABLE AND REBASE. CLONE IT IF IT'S NOT. ====="
|
| |
+ if [ -d releng ]; then
|
| |
+ pushd releng
|
| |
+ git pull --rebase
|
| |
popd
|
| |
- }
|
| |
- popd
|
| |
- CMD="pungi-koji --notification-script=/usr/bin/pungi-fedmsg-notification --notification-script=pungi-wait-for-signed-ostree-handler --config=$CONFIG --old-composes=$TARGET_DIR $OLD_COMPOSES_DIR $NIGHTLY $SKIP_PHASES --label=$LABEL"
|
| |
- if [ -z "$COMPOSE_ID" ]; then
|
| |
- CMD="$CMD --target-dir=$TARGET_DIR"
|
| |
else
|
| |
- CMD="$CMD --debug-mode --compose-dir=$TARGET_DIR/$COMPOSE_ID"
|
| |
+ git clone https://pagure.io/releng.git
|
| |
+ fi
|
| |
+
|
| |
+ # Set up our fedora-messaging function using the releng repository definition.
|
| |
+ # https://pagure.io/releng/blob/main/f/scripts/fedora-messaging.sh
|
| |
+ FEDMSG_MODNAME="compose"
|
| |
+ FEDMSG_CERTPREFIX="releng"
|
| |
+ . ./releng/scripts/fedora-messaging.sh
|
| |
+
|
| |
+ echo "===== ANNOUNCE THAT WE ARE STARTING (EVEN THOUGH THE COMPOSE_ID IS NOT YET KNOWN). ====="
|
| |
+ fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "short": "%s"}' \
|
| |
+ "$RELEASE" "$SHORT")
|
| |
+ $CMD_PREFIX send_fedora_message "${fedora_message_json_start} ${RELEASE} start"
|
| |
+
|
| |
+ # The `pungi-koji` script checks out the fedora-comps repository so this can be removed (commented out for now).
|
| |
+ #pushd "${TMPDIR}"
|
| |
+ #git clone https://pagure.io/fedora-comps.git && {
|
| |
+ # pushd fedora-comps
|
| |
+ # make "${COMPSFILE}"
|
| |
+ # cp "${COMPSFILE}" "${DEST}"/
|
| |
+ # popd
|
| |
+ #}
|
| |
+ #popd
|
| |
+
|
| |
+ CMD="pungi-koji --notification-script=/usr/bin/pungi-fedmsg-notification \
|
| |
+ --notification-script=pungi-wait-for-signed-ostree-handler \
|
| |
+ --config=${CONFIG} --old-composes=${TARGET_DIR} ${OLD_COMPOSES_DIR} ${NIGHTLY} ${SKIP_PHASES} \
|
| |
+ --label=${LABEL}"
|
| |
+
|
| |
+ if [ -z "${COMPOSE_ID}" ]; then
|
| |
+ CMD="${CMD_PREFIX} ${CMD} --target-dir=${TARGET_DIR}"
|
| |
+ else
|
| |
+ CMD="${CMD_PREFIX} ${CMD} --debug-mode --compose-dir=${TARGET_DIR}/${COMPOSE_ID}"
|
| |
+ fi
|
| |
+
|
| |
+ echo "===== RUN THE COMPOSE. EXIT IF THE EXIT STATUS IS NOT ZERO. ====="
|
| |
+ if ! time ${CMD} "$@"; then
|
| |
+ echo "Error: Command failed with a non-zero exit status."
|
| |
+ exit 1
|
| |
+ fi
|
| |
+
|
| |
+ # Get the compose ID.
|
| |
+ # The COMPOSE_ID variable is used for debugging purposes so another variable with the same value is needed.
|
| |
+ COMPOSE_ID_2=$(cat "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID)
|
| |
+
|
| |
+ # Find out what the status of the compose is. Do not proceed if it's DOOMED.
|
| |
+ echo "===== COMPOSE STATUS ====="
|
| |
+ COMPOSE_STATUS=$(cat "/mnt/koji/compose/${FEDORA_VERSION}/${COMPOSE_ID_2}/STATUS")
|
| |
+ echo "$COMPOSE_STATUS"
|
| |
+ if [ "$COMPOSE_STATUS" = "DOOMED" ]; then
|
| |
+ echo "Compose is $COMPOSE_STATUS. Exiting."
|
| |
+ "$CMD_PREFIX" exit 1
|
| |
+ else
|
| |
+ echo "Compose is $COMPOSE_STATUS. Proceeding to rsync."
|
| |
+ fi
|
| |
+
|
| |
+ # Update the fedora_message template.
|
| |
+ fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "short": "%s", "compose_id": "%s"}' \
|
| |
+ "$RELEASE" "$SHORT" "$COMPOSE_ID_2")
|
| |
+ fedora_message_json_done=$(printf '{"log": "done", "branch": "%s", "short": "%s", "compose_id": "%s"}' \
|
| |
+ "$RELEASE" "$SHORT" "$COMPOSE_ID_2")
|
| |
+
|
| |
+ echo "===== LET INTERESTED PERSONS KNOW ABOUT THE COMPOSE. ====="
|
| |
+ $CMD_PREFIX send_fedora_message "${fedora_message_json_done} ${RELEASE} complete"
|
| |
+
|
| |
+ echo "===== TELL INTERESTED PERSONS THAT THE RSYNC IS STARTING. ====="
|
| |
+ $CMD_PREFIX send_fedora_message "${fedora_message_json_start} ${RELEASE} rsync.start"
|
| |
+
|
| |
+ echo "===== CREATE THE DIRECTORY TARGETED FOR THE COPY (IF IT DOESN'T EXIST). ====="
|
| |
+ if [ ! -d "${RSYNCTARGET}" ]; then
|
| |
+ "${CMD_PREFIX}" "${RSYNCPREFIX}" mkdir -m 750 -p "${RSYNCTARGET}"
|
| |
+ fi
|
| |
+
|
| |
+ echo "===== RUN THE SYNCHRONIZATION. ====="
|
| |
+ # ? Note from documentation:
|
| |
+ # ? If multiple composes are run like 1.2, 1.3, add multiple --link-dest arguments below with multiple composes.
|
| |
+ ARTIFACTS="Everything Cloud Container Kinoite Labs Server Silverblue Spins \
|
| |
+ Workstation Onyx Sericea metadata"
|
| |
+
|
| |
+ for dir in ${ARTIFACTS}; do
|
| |
+ ${CMD_PREFIX} "${RSYNCPREFIX} sh -c rsync -avhH ${TARGET_DIR}/${COMPOSE_ID_2}/compose/$dir/ \
|
| |
+ ${RSYNCTARGET}/$dir/ --link-dest=/pub/fedora/linux/development/${FEDORA_VERSION}/Everything/ \
|
| |
+ --link-dest=${RSYNCTARGET}/Everything"
|
| |
+ done
|
| |
+
|
| |
+ echo "===== SET THE PERMISSIONS OF THE SYNCED COMPOSE. ====="
|
| |
+ if [ -d "${RSYNCTARGET}" ]; then
|
| |
+ "${CMD_PREFIX}" "${RSYNCPREFIX}" chmod 755 "${RSYNCTARGET}"
|
| |
fi
|
| |
- time $CMD "$@"
|
| |
+
|
| |
+ echo "===== LET INTERESTED PERSONS KNOW THAT THE RSYNC IS COMPLETE. ====="
|
| |
+ $CMD_PREFIX send_fedora_message "${fedora_message_json_done} ${RELEASE} rsync.complete"
|
| |
Signed-off-by: Patrik Polakovič patrik@alphamail.org