pungi-fedora/release-candidate.sh
Samyak Jain 267491e2f7
All checks were successful
Fedora Pungi Compose CI Validation / validate (pull_request) Successful in 26s
Fedora Pungi Compose CI Validation / validate (push) Successful in 23s
fedora-comps is now migrated to new forgejo
Signed-off-by: Samyak Jain <samyak.jn11@gmail.com>
2026-06-01 13:47:50 +05:30

217 lines
7.6 KiB
Bash
Executable file

#!/bin/sh
# This script is used to generate Beta and Final release candidate composes.
# Relevant SOPs:
# Beta RC: https://docs.fedoraproject.org/en-US/infra/release_guide/beta_RC_compose/
# Final RC: https://docs.fedoraproject.org/en-US/infra/release_guide/final_RC_compose/
# The first argument is the release version (e.g. 41).
# The second argument is the compose label (e.g. Beta-1.3).
# It 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 42 Beta-1.3 -d`
export LC_ALL=C
FEDORA_VERSION=$1
LABEL=$2
# Find out which config file to use based on the label.
if [[ "$LABEL" = *"Beta"* ]]; then
CONFIG="fedora-beta.conf"
echo "========================================"
echo "CONFIG: $CONFIG"
echo ""
elif [[ "$LABEL" = *"RC"* ]]; then
CONFIG="fedora-final.conf"
echo "========================================"
echo "CONFIG: $CONFIG"
echo ""
else
echo "ERROR: Invalid label."
exit 1
fi
TARGET_DIR="/mnt/koji/compose/${FEDORA_VERSION}"
MD_ARCHIVE_DIR="/mnt/koji/compose/metadata-archive"
SERIES_DIR="${MD_ARCHIVE_DIR}/series"
# 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")
# 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"
RSYNC_PREFIX="sudo -u ftpsync"
RSYNC_TARGET="/pub/alt/stage/${FEDORA_VERSION}_${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
if [[ $3 == "-d" ]]; then
DRY_RUN=true
fi
if "$DRY_RUN"; then
printf "THIS IS A DRY RUN.\n\n"
CMD_PREFIX="echo"
else
printf "THIS IS NOT A DRY RUN.\n\n"
CMD_PREFIX=''
fi
echo "========================================"
echo "ASSUME THAT THE RELENG TOOLING REPOSITORY IS AVAILABLE AND REBASE. CLONE IT IF IT'S NOT."
echo ""
if [ -d releng ]; then
$CMD_PREFIX pushd releng
$CMD_PREFIX git pull --rebase
$CMD_PREFIX popd
echo ""
else
$CMD_PREFIX git clone https://forge.fedoraproject.org/releng/tooling.git releng
echo ""
fi
# Set up our fedora-messaging function using the releng repository definition.
# https://forge.fedoraproject.org/releng/tooling/src/branch/main/infrastructure/messaging/fedora_messaging.sh
FEDMSG_MODNAME="compose"
FEDMSG_CERTPREFIX="releng"
. ./releng/infrastructure/messaging/fedora_messaging.sh
echo "========================================"
echo "ANNOUNCE THAT WE ARE STARTING (EVEN THOUGH THE COMPOSE_ID IS NOT YET KNOWN)."
echo ""
fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "short": "%s"}' \
"$RELEASE" "$SHORT")
$CMD_PREFIX send_fedora_message "${fedora_message_json_start}" "${RELEASE}" start
echo ""
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}"
fi
echo "========================================"
echo "RUN THE COMPOSE. EXIT IF THE EXIT STATUS IS NOT ZERO."
echo ""
if ! time ${CMD_PREFIX} ${CMD}; then
echo "ERROR: Command failed with a non-zero exit status."
$CMD_PREFIX exit 1
echo ""
fi
echo ""
# Check if the compose ID exists and exit if it does not.
if [ ! -f "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID ]; then
echo "ERROR: No compose ID available."
$CMD_PREFIX exit 1
echo ""
fi
# Get the compose ID if it exists, exit if it does not.
# Note: The COMPOSE_ID variable is used for debugging purposes so another variable with the same value is needed.
if [ -e "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID ]; then
COMPOSE_ID_2=$(cat "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID)
else
echo "ERROR: Compose ID not found."
$CMD_PREFIX exit 1
echo ""
fi
# Check if the compose STATUS exists and exit if it does not.
if [ ! -f "/mnt/koji/compose/${FEDORA_VERSION}/${COMPOSE_ID_2}/STATUS" ]; then
echo "ERROR: No compose STATUS available."
$CMD_PREFIX exit 1
echo ""
fi
# Find out what the status of the compose is. Do not proceed if the status is DOOMED.
COMPOSE_STATUS=$(cat "/mnt/koji/compose/${FEDORA_VERSION}/${COMPOSE_ID_2}/STATUS")
echo "========================================"
echo "COMPOSE DETAILS"
echo "Compose ID: ${COMPOSE_ID_2}"
echo "Compose status: ${COMPOSE_STATUS}"
if [ "$COMPOSE_STATUS" = "DOOMED" ]; then
echo "ERROR: The compose status is DOOMED."
$CMD_PREFIX exit 1
echo ""
else
echo "Proceeding to rsync."
echo ""
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 "========================================"
echo "LET INTERESTED PERSONS KNOW ABOUT THE COMPOSE."
echo ""
$CMD_PREFIX send_fedora_message "${fedora_message_json_done}" "${RELEASE}" complete
echo ""
echo "========================================"
echo "TELL INTERESTED PERSONS THAT THE RSYNC IS STARTING."
echo ""
$CMD_PREFIX send_fedora_message "${fedora_message_json_start}" "${RELEASE}" rsync.start
echo ""
echo "========================================"
echo "CREATE THE DIRECTORY TARGETED FOR THE COPY (IF IT DOESN'T EXIST)."
echo ""
if [ ! -d "${RSYNC_TARGET}" ]; then
${CMD_PREFIX} ${RSYNC_PREFIX} mkdir -m 750 -p ${RSYNC_TARGET}
fi
echo ""
echo "========================================"
echo "RUN THE SYNCHRONIZATION."
echo ""
# thanks, camh from StackExchange:
# https://unix.stackexchange.com/a/13472
# the nested dirname $0 finds variants-fedora.xml in the same dir as
# this script, no matter where it was run from
VARIANTS=$(grep -oP 'variant id="\K[^"]+' $(dirname $0)/variants-fedora.xml | tr '\n' ' ')
ARTIFACTS="${VARIANTS} metadata"
for dir in ${ARTIFACTS}; do
${CMD_PREFIX} ${RSYNC_PREFIX} rsync -avhH ${TARGET_DIR}/${COMPOSE_ID_2}/compose/$dir/ \
${RSYNC_TARGET}/$dir/ --link-dest=/pub/fedora/linux/development/${FEDORA_VERSION}/Everything/ \
--link-dest=/pub/fedora-secondary/development/${FEDORA_VERSION}/Everything/ \
--link-dest=/pub/alt/stage/
done
echo ""
echo "========================================"
echo "SET THE PERMISSIONS OF THE SYNCED COMPOSE."
echo ""
if [ -d "${RSYNC_TARGET}" ]; then
${CMD_PREFIX} ${RSYNC_PREFIX} chmod 755 "${RSYNC_TARGET}"
fi
echo ""
# Copy the metadata to the non-garbage-collected metadata archive
YEAR=$(echo "$COMPOSE_ID_2"|sed -e 's|Fedora-.*-||g'|cut -c1-4)
mkdir -p "${MD_ARCHIVE_DIR}/${YEAR}/${COMPOSE_ID_2}"
cp "${DESTDIR}"/compose/metadata/*.json "${MD_ARCHIVE_DIR}/${YEAR}/${COMPOSE_ID_2}/"
# Add the compose ID to the 'series' file which records the
# compose IDs for each SHORT name in order
mkdir -p "${SERIES_DIR}"
echo "${COMPOSE_ID_2} ${LABEL}" >> "${SERIES_DIR}/${SHORT}-${RELEASE}"
echo "========================================"
echo "LET INTERESTED PERSONS KNOW THAT THE RSYNC IS COMPLETE."
echo ""
$CMD_PREFIX send_fedora_message "${fedora_message_json_done}" "${RELEASE}" rsync.complete