diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2023-11-20 02:43:22 -0500 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2024-03-28 23:12:41 -0400 |
commit | 1b73d8a12a4e17c65b0326ca1d04bb6b723873a2 (patch) | |
tree | 71f16fb44711493053cd03a26d93deddbc67c309 | |
parent | ebb26c233c05dfb2dba63e29b1dff3e83bc1584d (diff) |
split pbot notification out to separate file
-rw-r--r-- | po/es/librelib.po | 4 | ||||
-rwxr-xr-x | src/abslibre-tools/librerelease | 52 | ||||
-rw-r--r-- | src/lib/notifications.sh | 31 |
3 files changed, 55 insertions, 32 deletions
diff --git a/po/es/librelib.po b/po/es/librelib.po index 552840f..d59bc11 100644 --- a/po/es/librelib.po +++ b/po/es/librelib.po @@ -286,3 +286,7 @@ msgstr "no se ha dado ningún archivo" #: src/lib/messages.sh:60 msgid "panic: malformed call to internal function" msgstr "pánico: llamada malformada a la función interna" + +#: src/lib/notifications.sh:26 +msgid "Notifying pbot:" +msgstr "Notificando pbot:" diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease index c8217c7..560e8d1 100755 --- a/src/abslibre-tools/librerelease +++ b/src/abslibre-tools/librerelease @@ -38,8 +38,11 @@ # so we take the '+' to combine it with our GPLv3+. set -euE -. "$(librelib messages)" -. "$(librelib conf)" + +source "$(librelib conf )" +source "$(librelib messages )" +source "$(librelib notifications)" + setup_traps dryrun="" @@ -242,6 +245,15 @@ clean() { } release_packages() { + local login_err_msg="connection or login failed" + local tier0_port="${REPODEST_port:+-p "$REPODEST_port"}" + local tier0_host="${REPODEST_userhost}" + local ssh_cmd="ssh ${tier0_port} ${tier0_host}" # eg: ssh -p 1863 autobuilder@repo.parabola.nu STAGING='staging/' DBSCRIPTS_CONFIG='/etc/dbscripts/config.local.parabola' db-update + local dbupdate_cmd="STAGING=${REPODEST_path@Q} DBSCRIPTS_CONFIG=${DBSCRIPTS_CONFIG@Q} db-update" + + + ## prepare ## + if [[ -n $HOOKPRERELEASE ]]; then msg "Running HOOKPRERELEASE..." ( @@ -289,13 +301,8 @@ release_packages() { ## publish ## - local tier0_port="${REPODEST_port:+-p "$REPODEST_port"}" - local tier0_host="${REPODEST_userhost}" - local dbupdate_cmd="STAGING=${REPODEST_path@Q} DBSCRIPTS_CONFIG=${DBSCRIPTS_CONFIG@Q} db-update" - msg "Running db-update on repos" - # eg: ssh -p 1863 autobuilder@repo.parabola.nu STAGING='staging/' DBSCRIPTS_CONFIG='/etc/dbscripts/config.local.parabola' db-update - ssh ${tier0_port} "${tier0_host}" "${dbupdate_cmd}" + ${ssh_cmd} "${dbupdate_cmd}" if [[ -n $HOOKPOSTRELEASE ]]; then msg "Running HOOKPOSTRELEASE..." @@ -305,30 +312,11 @@ release_packages() { ) fi - # notify pbot of the excellent work we have done - local login=${REPODEST_userinfo:-somebody} ; login=${login%%:*} ; - local select_pkgs='\.pkg\.tar\.[^\.]+$' - local reject_pkgs='-debug-' - local pkgname_rx='s|\([^/]*\)/\([^/ -]*\)-\([^-]*\)-[^-]*-\([^-\.]*\)\..*$|\2-\3-\4/\1|' - local pbotsay_fmt="if type pbot-say &>/dev/null ; then pbot-say %s just published: %s ; fi" - local filename - local packages=( - $( - while read -r -d '' - do filename="$REPLY" - [[ "${filename}" =~ ${select_pkgs} ]] || continue - [[ "${filename}" =~ ${reject_pkgs} ]] && continue || : - - sed "${pkgname_rx}" <<<${filename} || : - done < ${file_list} | sort -u | xargs || : - ) - ) - - if (( ${#packages[@]} )); then - local pbotsay_cmd="$(printf "${pbotsay_fmt}" "${login}" "${packages[@]}")" - - ssh ${tier0_port} "${tier0_host}" "${pbotsay_cmd}" &> /dev/null || : - fi + + ## notify pbot of the excellent work we have done ## + + notify_pbot "${ssh_cmd}" < $file_list + return $EXIT_SUCCESS } diff --git a/src/lib/notifications.sh b/src/lib/notifications.sh new file mode 100644 index 0000000..6a42fd9 --- /dev/null +++ b/src/lib/notifications.sh @@ -0,0 +1,31 @@ +# process librerelease::$file_list via STDIN +notify_pbot() # ( "ssh_cmd" ) file_list->STDIN +{ + local ssh_cmd="$1" + local repo_user=${REPOUSER:-${LIBREUSER:-somebody}} + local select_rx='\.pkg\.tar\.[^\.]+$' + local reject_rx='-debug-' + # example "selected" $file_list entry, to be fed through $filename_rx: + # libre/gst-plugins-bad-1.22.8-1.parabola1-x86_64.pkg.tar.zst + # (repo )/(pkgname )-(pkgver )- -(arch ) + local filename_rx="^([a-z]+)/([0-9A-Za-z\._@\+\-]+)-([0-9A-Za-z\._]+)-[^/-]+-([0-9a-z_]+)${select_rx}$" + # example $filename_subst, sent to pbot: + # (gst-plugins-bad 1.22.8)->libre/x86_64 + local filename_subst='(\2 \3)->\1/\4' + local filename_sed="s|${filename_rx}|${filename_subst}|" + local filename + local releases=( $(while read -r -d '' # process librerelease::$file_list via STDIN + do filename="$REPLY" + [[ "${filename}" =~ ${select_rx} ]] || continue + [[ "${filename}" =~ ${reject_rx} ]] && continue || : + + sed -E "${filename_sed}" <<< ${filename} || : + done | sort -u | xargs || :) ) + local pbotsay_msg="$(printf "%s just published:" ${repo_user}) ${releases[@]}" + local pbotsay_cmd="which pbot-say &> /dev/null && pbot-say '${pbotsay_msg}'" + + if [[ ${ssh_cmd[0]} =~ ^ssh\ ]] && (( ${#releases[@]} )); then + msg2 "$(_ "Notifying pbot:")" ; print " ${pbotsay_msg}" ; + ${ssh_cmd} "${pbotsay_cmd}" &> /dev/null || : + fi +} |