commit 10e0aff32196ca646eec267b1a4a011dc41fe2f8
parent 14baa1fce787a8804816869c4543675009e274b6
Author: ccx <root@dorje.wpr.cz>
Date: Sun, 20 Feb 2022 15:19:52 +0100
Fix link_changed comparison and how /previous is handled.
Diffstat:
M | install | | | 30 | ++++++++++++++++++------------ |
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/install b/install
@@ -203,7 +203,7 @@ install_bzr_repos(){
}
link_changed() {
- [[ "${preinstall_links[$1]:-}" == "${postinstall_links[$1]:-}" ]]
+ [[ "${preinstall_links[$1]:-}" != "${postinstall_links[$1]:-}" ]]
}
preinstall() {
typeset -gA preinstall_links
@@ -212,24 +212,22 @@ preinstall() {
for l in /current/**/*(@N); do
preinstall_links[${l#/current/}]=$l:A
done
- preinstall_current=/current
- preinstall_current=$preinstall_current:A
- cp -a /current /previous || exit $?
+ local -A statinfo
+ zstat -H statinfo +link /current
+ preinstall_current=$statinfo[link]
+ s6-rename /previous /previous.1
+ s6-ln -sf $preinstall_current /previous || exit $?
}
-typeset -ft preinstall
+#typeset -ft preinstall
+
postinstall() {
- typeset -gA postinstall_links
- local l ret
- for l in /current/**/*(@N); do
- postinstall_links[${l#/current/}]=$l:A
- done
if [[ -d /run/s6-rc/ ]]; then
if link_changed package; then
if link_changed s6-rc-source; then
+ # s6-rc-format-upgrade to tmpdir, then s6-rc-update
local tmp_db=/run/old-s6-rc-db-migration.$EPOCHREALTIME
- # s6-rc-format-upgrade to tmpdir, then s6-rc-update
: s6-rc-compile $tmp_db "$preinstall_links[s6-rc-source]" || return $?
: s6-rc-format-upgrade -v2 $tmp_db || return $?
: s6-rc-update -v2 /current/s6-rc-db/ || return $?
@@ -255,10 +253,18 @@ postinstall() {
return 0
}
typeset -ft postinstall
+
postinstall_or_rollback() {
+ typeset -gA postinstall_links
+ local l ret
+ for l in /current/**/*(@N); do
+ postinstall_links[${l#/current/}]=$l:A
+ done
+
if ! postinstall; then
echo >&2 "Fatal: postinstall script failed, rolling back to $preinstall_current"
- cp -a /previous /current
+ s6-ln -sf $preinstall_current /current || exit $?
+ s6-rename /previous.1 /previous
exit 1
fi
}