From 0967cfd68edc812d38607b747796c99a96e4071a Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 17 Jan 2023 23:02:17 -0700 Subject: [PATCH] add mail notifications --- rocky/images-cloud.conf | 50 ------------------------- rocky/images.conf | 68 ++++++++++++++++++++++++++++------ rocky/override.conf | 2 + scripts/common-8 | 27 ++++++++++++++ scripts/produce-8-lookahead.sh | 34 +++++++++++++++-- 5 files changed, 116 insertions(+), 65 deletions(-) delete mode 100644 rocky/images-cloud.conf diff --git a/rocky/images-cloud.conf b/rocky/images-cloud.conf deleted file mode 100644 index 9868a95..0000000 --- a/rocky/images-cloud.conf +++ /dev/null @@ -1,50 +0,0 @@ -image_build = { - "^BaseOS$": [ - { - "image-build": { - "format": [("qcow2", "qcow2")], - "name": "Rocky-8-GenericCloud", - "subvariant": "generic", - "version": "8.8", - "release": "!RELEASE_FROM_DATE_RESPIN" - "target": "image-rocky-8", - "ksurl": "git+https://git.rockylinux.org/rocky/kickstarts.git?#origin/r8", - "kickstart": "Rocky-8-GenericCloud-Base.ks", - "ksversion": "F26", - "distro": "Fedora-20", - "disk-size": "10", - "arches": ["x86_64","aarch64"], - "install_tree_from": "BaseOS", - "repo": ["BaseOS","AppStream",] - }, - "factory-parameters": { - "generate_icicle": False, - } - }, - { - "image-build": { - "format": [("raw.xz", "raw.xz")], - "name": "Rocky-8-ec2", - "subvariant": "ec2", - "version": "8.8", - "release": "!RELEASE_FROM_DATE_RESPIN" - "target": "image-rocky-8", - "ksurl": "git+https://git.rockylinux.org/rocky/kickstarts.git?#origin/r8", - "kickstart": "Rocky-8-EC2-Base.ks", - "ksversion": "F26", - "distro": "Fedora-20", - "disk-size": "10", - "arches": ["x86_64", "aarch64"], - "install_tree_from": "BaseOS", - "repo": ["BaseOS","AppStream",] - }, - "factory-parameters": { - "generate_icicle": False, - } - }, - ] -} - -translate_paths = [ - ("/mnt/koji", "https://koji.rockylinux.org/kojifiles"), -] diff --git a/rocky/images.conf b/rocky/images.conf index 8b24d33..062fb35 100644 --- a/rocky/images.conf +++ b/rocky/images.conf @@ -1,13 +1,59 @@ -global_ksurl = 'git+https://git.resf.org/sig_core/kickstarts.git?#origin/r8' -live_media = { - '^Workstation$': [ - { - 'name': 'Rocky-Workstation-8', - 'version': '8.8', - 'arches': ['x86_64'], - 'kickstart': 'Rocky-8-Workstation.ks', - 'repo': ['BaseOS', 'AppStream', 'PowerTools', 'extras'], - 'failable': ['*'] +#global_ksurl = 'git+https://git.resf.org/sig_core/kickstarts.git?#origin/r8' +#live_media = { +# '^Workstation$': [ +# { +# 'name': 'Rocky-Workstation-8', +# 'version': '8.8', +# 'arches': ['x86_64'], +# 'kickstart': 'Rocky-8-Workstation.ks', +# 'repo': ['BaseOS', 'AppStream', 'PowerTools', 'extras'], +# 'failable': ['*'] +# } +# ] +#} +image_build = { + "^BaseOS$": [ + { + "image-build": { + "format": [("qcow2", "qcow2")], + "name": "Rocky-8-GenericCloud", + "subvariant": "generic", + "version": "8.8", + "release": "!RELEASE_FROM_DATE_RESPIN" + "target": "image-rocky-8", + "ksurl": "git+https://git.resf.org/sig_core/kickstarts.git?#origin/r8", + "kickstart": "Rocky-8-GenericCloud-Base.ks", + "ksversion": "F26", + "distro": "Fedora-20", + "disk-size": "10", + "arches": ["x86_64","aarch64"], + "install_tree_from": "BaseOS", + "repo": ["BaseOS","AppStream",] + }, + "factory-parameters": { + "generate_icicle": False, } - ] + }, + { + "image-build": { + "format": [("raw.xz", "raw.xz")], + "name": "Rocky-8-EC2", + "subvariant": "ec2", + "version": "8.8", + "release": "!RELEASE_FROM_DATE_RESPIN" + "target": "image-rocky-8", + "ksurl": "git+https://git.resf.org/sig_core/kickstarts.git?#origin/r8", + "kickstart": "Rocky-8-EC2-Base.ks", + "ksversion": "F26", + "distro": "Fedora-20", + "disk-size": "10", + "arches": ["x86_64", "aarch64"], + "install_tree_from": "BaseOS", + "repo": ["BaseOS","AppStream",] + }, + "factory-parameters": { + "generate_icicle": False, + } + }, + ] } diff --git a/rocky/override.conf b/rocky/override.conf index 0d7c11a..c812fb4 100644 --- a/rocky/override.conf +++ b/rocky/override.conf @@ -1,5 +1,7 @@ # Overrides default variables +from images import * + sigkeys = ['6D745A60'] tree_arches = ['aarch64', 'i386', 'x86_64'] translate_paths = [ diff --git a/scripts/common-8 b/scripts/common-8 index 65d72f8..9c45017 100644 --- a/scripts/common-8 +++ b/scripts/common-8 @@ -1 +1,28 @@ +MAJOR="8" REVISION="8.8" +FROMMAIL="Compose Tracker " +TOMAIL="releng@rockylinux.org" + +if ! which mm-compose-notif > /dev/null 2>&1; then + MM_NOTIF="" +else + MM_NOTIF="$(which mm-compose-notif)" +fi + +if ! which compose-changelog > /dev/null 2>&1; then + if [ -f "/home/$(whoami)/.local/bin/compose-changelog" ]; then + CHANGELOG_CMD="/home/$(whoami)/.local/bin/compose-changelog" + else + CHANGELOG_CMD="" + fi +else + CHANGELOG_CMD="$(which compose-changelog)" +fi + +if ! which mutt > /dev/null 2>&1; then + MAILCMD="" + MAILNOTIF="no" +else + MAILCMD="$(which mutt)" + MAILNOTIF="yes" +fi diff --git a/scripts/produce-8-lookahead.sh b/scripts/produce-8-lookahead.sh index c03dc39..3e8b600 100755 --- a/scripts/produce-8-lookahead.sh +++ b/scripts/produce-8-lookahead.sh @@ -3,16 +3,14 @@ source "$(dirname "$0")/common-8" export PATH=/usr/sbin:/usr/bin:/root/bin TARGET_DIR="/mnt/compose/8-LookAhead" +LOG_DIR="/mnt/compose/logs" SHORT=Rocky CONFIG=/etc/pungi-lh/rockylh.conf -# Unused for now -OLDCOMPOSE_ID=$(cat $TARGET_DIR/latest-$SHORT-8/COMPOSE_ID) +OLDCOMPOSE_ID="$(cat $TARGET_DIR/latest-$SHORT-$MAJOR/COMPOSE_ID)" SKIP="" #LABEL="--nightly --label RC-${REVISION}" LABEL="--test" - CMD="pungi-koji --config=$CONFIG $SKIP $LABEL" -#COMPOSE_ID="Rocky-8-20210625.n.0" if [ -z "$COMPOSE_ID" ]; then CMD="$CMD --target-dir=$TARGET_DIR" @@ -21,3 +19,31 @@ else fi time $CMD +ret_val=$? + +if [[ "$ret_val" != "0" ]]; then + if [[ "$MAILNOTIF" == "yes" ]]; then + echo "This is a notification that a recent $SHORT compose failed on $(hostname)" | mutt -e "set from=\"$FROM\"" \ + -e 'set envelope_from=yes' \ + -s "Compose $NEWCOMPOSE_ID failed (for Rocky Linux $REVISION)" \ + releng@rockylinux.org + fi + exit 1 +fi + +NEWCOMPOSE_ID="$(cat $TARGET_DIR/latest-$SHORT-$MAJOR/COMPOSE_ID)" +SHORTCOMPOSE_ID="$(echo $NEWCOMPOSE_ID | sed -e 's|Rocky-.*-||g')" + +# attempt to check changelog +if [ -n "$CHANGELOG_CMD" ]; then + if ! $CHANGELOG_CMD -p "$LOG_DIR/" "$TARGET_DIR/$OLDCOMPOSE_ID/" "$TARGET_DIR/$NEWCOMPOSE_ID" 2>"$LOG_DIR/changelog.$SHORTCOMPOSE_ID.stderr"; then + if [[ "$MAILNOTIF" == "yes" ]]; then + mutt -e "set from=\"$FROM\"" \ + -e 'set envelope_from=yes' \ + -s "Changelog for $NEWCOMPOSE_ID failed" \ + releng@rockylinux.org < "$LOG_DIR/changelog.$SHORTCOMPOSE_ID.stderr" + else + echo "!! Changelog run failed !!" + fi + fi +fi