From 41a7797bebe5f58bbeeed6f87190409c6227b347 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 10 Mar 2025 11:08:58 -0500 Subject: [PATCH 1/4] packaging: init mising packaging/{rpm,deb}/scripts --- packaging/deb/scripts/pre-remove.sh | 4 ++++ packaging/rpm/scripts/post-remove.sh | 1 + packaging/rpm/scripts/pre-remove.sh | 1 + 3 files changed, 6 insertions(+) create mode 100644 packaging/deb/scripts/pre-remove.sh create mode 100644 packaging/rpm/scripts/post-remove.sh create mode 100644 packaging/rpm/scripts/pre-remove.sh diff --git a/packaging/deb/scripts/pre-remove.sh b/packaging/deb/scripts/pre-remove.sh new file mode 100644 index 0000000000..3053d201df --- /dev/null +++ b/packaging/deb/scripts/pre-remove.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# prerm script for st2 + +set -e diff --git a/packaging/rpm/scripts/post-remove.sh b/packaging/rpm/scripts/post-remove.sh new file mode 100644 index 0000000000..667cde316c --- /dev/null +++ b/packaging/rpm/scripts/post-remove.sh @@ -0,0 +1 @@ +set -e diff --git a/packaging/rpm/scripts/pre-remove.sh b/packaging/rpm/scripts/pre-remove.sh new file mode 100644 index 0000000000..667cde316c --- /dev/null +++ b/packaging/rpm/scripts/pre-remove.sh @@ -0,0 +1 @@ +set -e From 15bbd1395dc8face862fc81f2b95cf913b57b27a Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 10 Mar 2025 11:19:21 -0500 Subject: [PATCH 2/4] Packaging: Copy scriptlet lines from st2.spec in st2-packages These lines were in st2.spec. They will need to be expanded in a follow-up commit. --- packaging/rpm/scripts/post-install.sh | 5 +++++ packaging/rpm/scripts/post-remove.sh | 10 ++++++++++ packaging/rpm/scripts/pre-remove.sh | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/packaging/rpm/scripts/post-install.sh b/packaging/rpm/scripts/post-install.sh index 65f63cf599..f58295e315 100644 --- a/packaging/rpm/scripts/post-install.sh +++ b/packaging/rpm/scripts/post-install.sh @@ -1,4 +1,9 @@ set -e +# from %post in st2-packages.git/packages/st2/rpm/st2.spec +%service_post st2actionrunner st2api st2stream st2auth st2notifier st2workflowengine +%service_post st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector +%service_post st2scheduler + # make sure that our socket generators run systemctl daemon-reload >/dev/null 2>&1 || true diff --git a/packaging/rpm/scripts/post-remove.sh b/packaging/rpm/scripts/post-remove.sh index 667cde316c..f81581c3f3 100644 --- a/packaging/rpm/scripts/post-remove.sh +++ b/packaging/rpm/scripts/post-remove.sh @@ -1 +1,11 @@ set -e + +# from %postun in st2-packages.git/packages/st2/rpm/st2.spec +%service_postun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine +%service_postun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector +%service_postun st2scheduler + +# Remove st2 logrotate config, since there's no analog of apt-get purge available +if [ $1 -eq 0 ]; then + rm -f /etc/logrotate.d/st2 +fi diff --git a/packaging/rpm/scripts/pre-remove.sh b/packaging/rpm/scripts/pre-remove.sh index 667cde316c..80243406d4 100644 --- a/packaging/rpm/scripts/pre-remove.sh +++ b/packaging/rpm/scripts/pre-remove.sh @@ -1 +1,6 @@ set -e + +# from %preun in st2-packages.git/packages/st2/rpm/st2.spec +%service_preun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine +%service_preun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector +%service_preun st2scheduler From 4ca7ec9f060e77b0f9cdf20070660f3132e1f2bd Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 7 Jan 2025 18:40:29 -0600 Subject: [PATCH 3/4] Packaging: Improve rpm scriptlet / deb maintainer script docs Document all scripts, and update deb docs to better describe when various args might be used and add some missing variants. --- packaging/deb/scripts/post-install.sh | 32 ++++++++++++++++++--------- packaging/deb/scripts/post-remove.sh | 28 ++++++++++++++--------- packaging/deb/scripts/pre-install.sh | 15 ++++++++----- packaging/deb/scripts/pre-remove.sh | 15 +++++++++++++ packaging/rpm/scripts/post-install.sh | 6 +++++ packaging/rpm/scripts/post-remove.sh | 6 +++++ packaging/rpm/scripts/pre-install.sh | 6 +++++ packaging/rpm/scripts/pre-remove.sh | 6 +++++ 8 files changed, 87 insertions(+), 27 deletions(-) diff --git a/packaging/deb/scripts/post-install.sh b/packaging/deb/scripts/post-install.sh index fd9007cd8a..225ec93d4f 100644 --- a/packaging/deb/scripts/post-install.sh +++ b/packaging/deb/scripts/post-install.sh @@ -6,16 +6,28 @@ set -e # summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package +# configure +# on fresh install +# configure +# on upgrade OR on install after pkg removal without purging conf files +# abort-upgrade +# on upgrade failed (after failure of prerm, preinst, postrm) +# abort-remove in-favour +# on removal due to conflict with other package +# abort-remove +# on removal (after failure of prerm) +# abort-deconfigure in-favour +# +# [ removing ] +# on removal due to breaks/conflict with other package (if --auto-deconfigure) +# triggered [ ...] +# when a trigger we've registered interest in fires, +# such as when /usr/bin/python3.9 (or similar) gets updated, +# allowing this script to rebuild the venv. +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html +# https://www.mankier.com/5/deb-postinst +# https://www.mankier.com/5/deb-triggers +# https://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger case "$1" in configure) diff --git a/packaging/deb/scripts/post-remove.sh b/packaging/deb/scripts/post-remove.sh index 9cfe930fb7..bdc758ad74 100644 --- a/packaging/deb/scripts/post-remove.sh +++ b/packaging/deb/scripts/post-remove.sh @@ -6,17 +6,23 @@ set -e # summary of how this script can be called: -# * `remove' -# * `purge' -# * `upgrade' -# * `failed-upgrade' -# * `abort-install' -# * `abort-install' -# * `abort-upgrade' -# * `disappear' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package +# remove +# on remove or remove+purge +# purge +# on purge or remove+purge +# upgrade +# on upgrade +# disappear +# on implicit removal (all package files replaced by another package) +# abort-install +# on failed fresh install (after failed) +# abort-install +# on failed install after pkg removal w/o conf purge (and failed) +# failed-upgrade +# on upgrade failed (after failed) +# abort-upgrade +# on upgrade failed (after or failed) +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html purge_files() { # This -pkgsaved.disabled file might be left over from old (buggy) deb packages diff --git a/packaging/deb/scripts/pre-install.sh b/packaging/deb/scripts/pre-install.sh index 5d327b21ae..9e5f935c8e 100644 --- a/packaging/deb/scripts/pre-install.sh +++ b/packaging/deb/scripts/pre-install.sh @@ -6,12 +6,15 @@ set -e # summary of how this script can be called: -# * `install' -# * `install' -# * `upgrade' -# * `abort-upgrade' -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package +# install +# on fresh install +# install +# on install after pkg removal without conf purge +# upgrade +# on upgrade +# abort-upgrade +# on upgrade failed (after failure of postrm) +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html PACKS_GROUP=st2packs SYS_USER=stanley diff --git a/packaging/deb/scripts/pre-remove.sh b/packaging/deb/scripts/pre-remove.sh index 3053d201df..fc644fd39c 100644 --- a/packaging/deb/scripts/pre-remove.sh +++ b/packaging/deb/scripts/pre-remove.sh @@ -2,3 +2,18 @@ # prerm script for st2 set -e + +# summary of how this script can be called: +# remove +# on remove or remove+purge +# upgrade +# on upgrade +# remove in-favour +# on removal due to conflict with other package +# deconfigure in-favour +# +# [ removing ] +# on removal due to breaks/conflict with other package (if --auto-deconfigure) +# failed-upgrade +# on upgrade failed (after failed) +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html diff --git a/packaging/rpm/scripts/post-install.sh b/packaging/rpm/scripts/post-install.sh index f58295e315..362ff56b6d 100644 --- a/packaging/rpm/scripts/post-install.sh +++ b/packaging/rpm/scripts/post-install.sh @@ -1,5 +1,11 @@ set -e +# This %post scriptlet gets one argument, $1, the number of packages of +# this name that will be left on the system when this script completes. So: +# * on install: $1 = 1 +# * on upgrade: $1 > 1 +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax + # from %post in st2-packages.git/packages/st2/rpm/st2.spec %service_post st2actionrunner st2api st2stream st2auth st2notifier st2workflowengine %service_post st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector diff --git a/packaging/rpm/scripts/post-remove.sh b/packaging/rpm/scripts/post-remove.sh index f81581c3f3..f2cc17a977 100644 --- a/packaging/rpm/scripts/post-remove.sh +++ b/packaging/rpm/scripts/post-remove.sh @@ -1,5 +1,11 @@ set -e +# This %postun scriptlet gets one argument, $1, the number of packages of +# this name that will be left on the system when this script completes. So: +# * on upgrade: $1 > 0 +# * on uninstall: $1 = 0 +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax + # from %postun in st2-packages.git/packages/st2/rpm/st2.spec %service_postun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine %service_postun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector diff --git a/packaging/rpm/scripts/pre-install.sh b/packaging/rpm/scripts/pre-install.sh index 0b430e33a0..e12dd26590 100644 --- a/packaging/rpm/scripts/pre-install.sh +++ b/packaging/rpm/scripts/pre-install.sh @@ -1,5 +1,11 @@ set -e +# This %pre scriptlet gets one argument, $1, the number of packages of +# this name that will be left on the system when this script completes. So: +# * on install: $1 = 1 +# * on upgrade: $1 > 1 +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax + PACKS_GROUP=%{packs_group} SYS_USER=%{stanley_user} ST2_USER=%{svc_user} diff --git a/packaging/rpm/scripts/pre-remove.sh b/packaging/rpm/scripts/pre-remove.sh index 80243406d4..6f65230cca 100644 --- a/packaging/rpm/scripts/pre-remove.sh +++ b/packaging/rpm/scripts/pre-remove.sh @@ -1,5 +1,11 @@ set -e +# This %preun scriptlet gets one argument, $1, the number of packages of +# this name that will be left on the system when this script completes. So: +# * on upgrade: $1 > 0 +# * on uninstall: $1 = 0 +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax + # from %preun in st2-packages.git/packages/st2/rpm/st2.spec %service_preun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine %service_preun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector From 8b77cdd7c3bd74cc9facef23ddd62529b316c0d0 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 10 Mar 2025 11:50:32 -0500 Subject: [PATCH 4/4] update changelog entry --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index eecbfafa66..422b322dbb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -79,7 +79,7 @@ Added to pants' use of PEX lockfiles. This is not a user-facing addition. #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253 #6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307 - #6311 #6314 + #6311 #6314 #6315 Contributed by @cognifloyd * Build of ST2 EL9 packages #6153 Contributed by @amanda11