#1214 [WIP] Fix the release-candidate script (releng #11673)
Closed a year ago by humaton. Opened a year ago by patrikp.
patrikp/pungi-fedora release_candidate  into  f39

file modified
+131 -20
@@ -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"

rebased onto feb2dad8434862d40e9bfa9500658112af1757c0

a year ago

rebased onto 280819bc66c367d8bdcb60a6ab3b88b1f0ed966f

a year ago

rebased onto c2f4115

a year ago

So, this looks much better to me. ;)

A few small comments:

  • Currently we pass something like 'RC_1.3' to the script, without the number. If we expect to pass the number and where we use _s and -s, we need to update our docs and make sure we remember to do that. ;) Perhaps we could just change it to pass 'release' 'Beta or RC' 'version' as 3 arguments? Then we don't have to worry about _ or -s and can process it more easily?

  • Might add some more error checking... ie, if someone does pass 'Beta_1.2' error and say they need to provide the number, or if RC or Beta isn't passed error, or if X.Y isn't passed...
    not a big deal, but would be nice to catch such things. :) If we change it to take 3 args, we could also have the error message say what arguments it's expecting where. ;)

  • Might also check for if COMPOSE_ID is not there and error, along with STATUS... ie, if I grab this and run it on my laptop I get:
    cat: /mnt/koji/compose/39/latest-Fedora-39/COMPOSE_ID: No such file or directory
    ===== COMPOSE STATUS =====
    cat: /mnt/koji/compose/39//STATUS: No such file or directory

Compose is . Proceeding to rsync.

  • from the script you have: # ? If multiple composes are run like 1.2, 1.3, add multiple --link-dest arguments below with multiple composes.

To expand on that, it means if we do say a 39_RC-1.1... then do a 39_RC-1.2, you want to add a --link-dest=/srv/pub/alt/stage/39_RC-1.1
so the new 1.2 one hardlinks to the existing 1.1 one thats already there. I'm not 100% sure this is really needed however, as we are hardlinking to development/39 already
so it should already get the links. So, I think we can drop this part.

Thanks for working on this!

Pull-Request has been closed by humaton

a year ago
Metadata