Skip to content

Commit a99117f

Browse files
authored
Packaging: Improve rpm scriptlet / deb maintainer script docs (#6315)
2 parents 16478d9 + 8b77cdd commit a99117f

File tree

9 files changed

+114
-28
lines changed

9 files changed

+114
-28
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Added
7979
to pants' use of PEX lockfiles. This is not a user-facing addition.
8080
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253
8181
#6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307
82-
#6311 #6314
82+
#6311 #6314 #6315
8383
Contributed by @cognifloyd
8484
* Build of ST2 EL9 packages #6153
8585
Contributed by @amanda11

packaging/deb/scripts/post-install.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,28 @@
66
set -e
77

88
# summary of how this script can be called:
9-
# * <postinst> `configure' <most-recently-configured-version>
10-
# * <old-postinst> `abort-upgrade' <new version>
11-
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12-
# <new-version>
13-
# * <postinst> `abort-remove'
14-
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15-
# <failed-install-package> <version> `removing'
16-
# <conflicting-package> <version>
17-
# for details, see http://www.debian.org/doc/debian-policy/ or
18-
# the debian-policy package
9+
# <new-postinst> configure
10+
# on fresh install
11+
# <new-postinst> configure <most-recently-configured-version>
12+
# on upgrade OR on install after pkg removal without purging conf files
13+
# <old-postinst> abort-upgrade <new version>
14+
# on upgrade failed (after failure of prerm, preinst, postrm)
15+
# <conflictor's-postinst> abort-remove in-favour <package> <new-version>
16+
# on removal due to conflict with other package
17+
# <postinst> abort-remove
18+
# on removal (after failure of prerm)
19+
# <deconfigured's-postinst> abort-deconfigure in-favour
20+
# <failed-install-package> <version>
21+
# [ removing <conflicting-package> <version> ]
22+
# on removal due to breaks/conflict with other package (if --auto-deconfigure)
23+
# <postinst> triggered <trigger-name> [<trigger-name> ...]
24+
# when a trigger we've registered interest in fires,
25+
# such as when /usr/bin/python3.9 (or similar) gets updated,
26+
# allowing this script to rebuild the venv.
27+
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
28+
# https://www.mankier.com/5/deb-postinst
29+
# https://www.mankier.com/5/deb-triggers
30+
# https://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger
1931

2032
case "$1" in
2133
configure)

packaging/deb/scripts/post-remove.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@
66
set -e
77

88
# summary of how this script can be called:
9-
# * <postrm> `remove'
10-
# * <postrm> `purge'
11-
# * <old-postrm> `upgrade' <new-version>
12-
# * <new-postrm> `failed-upgrade' <old-version>
13-
# * <new-postrm> `abort-install'
14-
# * <new-postrm> `abort-install' <old-version>
15-
# * <new-postrm> `abort-upgrade' <old-version>
16-
# * <disappearer's-postrm> `disappear' <overwriter>
17-
# <overwriter-version>
18-
# for details, see http://www.debian.org/doc/debian-policy/ or
19-
# the debian-policy package
9+
# <postrm> remove
10+
# on remove or remove+purge
11+
# <postrm> purge
12+
# on purge or remove+purge
13+
# <old-postrm> upgrade <new-version>
14+
# on upgrade
15+
# <disappearer's-postrm> disappear <overwriter> <overwriter-version>
16+
# on implicit removal (all package files replaced by another package)
17+
# <new-postrm> abort-install
18+
# on failed fresh install (after <preinst> failed)
19+
# <new-postrm> abort-install <old-version> <new-version>
20+
# on failed install after pkg removal w/o conf purge (and <preinst> failed)
21+
# <new-postrm> failed-upgrade <old-version> <new-version>
22+
# on upgrade failed (after <old-postrm> failed)
23+
# <new-postrm> abort-upgrade <old-version> <new-version>
24+
# on upgrade failed (after <new-preinst> or <old-postrm> failed)
25+
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
2026

2127
purge_files() {
2228
# This -pkgsaved.disabled file might be left over from old (buggy) deb packages

packaging/deb/scripts/pre-install.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
set -e
77

88
# summary of how this script can be called:
9-
# * <new-preinst> `install'
10-
# * <new-preinst> `install' <old-version>
11-
# * <new-preinst> `upgrade' <old-version>
12-
# * <old-preinst> `abort-upgrade' <new-version>
13-
# for details, see http://www.debian.org/doc/debian-policy/ or
14-
# the debian-policy package
9+
# <new-preinst> install
10+
# on fresh install
11+
# <new-preinst> install <old-version> <new-version>
12+
# on install after pkg removal without conf purge
13+
# <new-preinst> upgrade <old-version> <new-version>
14+
# on upgrade
15+
# <old-preinst> abort-upgrade <new-version>
16+
# on upgrade failed (after failure of postrm)
17+
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
1518

1619
PACKS_GROUP=st2packs
1720
SYS_USER=stanley
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
# prerm script for st2
3+
4+
set -e
5+
6+
# summary of how this script can be called:
7+
# <new-prerm> remove
8+
# on remove or remove+purge
9+
# <old-prerm> upgrade <new-version>
10+
# on upgrade
11+
# <conflictor's-prerm> remove in-favour <package> <new-version>
12+
# on removal due to conflict with other package
13+
# <deconfigured's-prerm> deconfigure in-favour
14+
# <package-being-installed> <version>
15+
# [ removing <conflicting-package> <version> ]
16+
# on removal due to breaks/conflict with other package (if --auto-deconfigure)
17+
# <new-prerm> failed-upgrade <old-version> <new-version>
18+
# on upgrade failed (after <old-prerm> failed)
19+
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
set -e
22

3+
# This %post scriptlet gets one argument, $1, the number of packages of
4+
# this name that will be left on the system when this script completes. So:
5+
# * on install: $1 = 1
6+
# * on upgrade: $1 > 1
7+
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
8+
9+
# from %post in st2-packages.git/packages/st2/rpm/st2.spec
10+
%service_post st2actionrunner st2api st2stream st2auth st2notifier st2workflowengine
11+
%service_post st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector
12+
%service_post st2scheduler
13+
314
# make sure that our socket generators run
415
systemctl daemon-reload >/dev/null 2>&1 || true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set -e
2+
3+
# This %postun scriptlet gets one argument, $1, the number of packages of
4+
# this name that will be left on the system when this script completes. So:
5+
# * on upgrade: $1 > 0
6+
# * on uninstall: $1 = 0
7+
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
8+
9+
# from %postun in st2-packages.git/packages/st2/rpm/st2.spec
10+
%service_postun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine
11+
%service_postun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector
12+
%service_postun st2scheduler
13+
14+
# Remove st2 logrotate config, since there's no analog of apt-get purge available
15+
if [ $1 -eq 0 ]; then
16+
rm -f /etc/logrotate.d/st2
17+
fi

packaging/rpm/scripts/pre-install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
set -e
22

3+
# This %pre scriptlet gets one argument, $1, the number of packages of
4+
# this name that will be left on the system when this script completes. So:
5+
# * on install: $1 = 1
6+
# * on upgrade: $1 > 1
7+
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
8+
39
PACKS_GROUP=%{packs_group}
410
SYS_USER=%{stanley_user}
511
ST2_USER=%{svc_user}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set -e
2+
3+
# This %preun scriptlet gets one argument, $1, the number of packages of
4+
# this name that will be left on the system when this script completes. So:
5+
# * on upgrade: $1 > 0
6+
# * on uninstall: $1 = 0
7+
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
8+
9+
# from %preun in st2-packages.git/packages/st2/rpm/st2.spec
10+
%service_preun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine
11+
%service_preun st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector
12+
%service_preun st2scheduler

0 commit comments

Comments
 (0)