Installer robustness: setup.sh exec-after-rm + uninstall.sh CONFIG_PREFIX guard#368
Installer robustness: setup.sh exec-after-rm + uninstall.sh CONFIG_PREFIX guard#368ooonea wants to merge 3 commits into
Conversation
The non-self-replacing restart branch ran 'rm -rf "${tmp}"' and then
'exec "${tmp}/setup.sh"', so the exec always failed with ENOENT and aborted
the restart, leaving a half-finished install. Drop the premature rm; the
EXIT/INT/TERM trap removes ${tmp} if the exec fails.
Under set -eu, 'cd "${CONFIG_PREFIX}"' aborted the whole uninstall when the
config dir did not exist (configs already removed, a re-run after a partial
uninstall, or a custom/Merlin prefix that diverges from SCRIPT_PREFIX), leaving
cake-autorate.sh/lib.sh/etc. on disk. Guard the cd so program-file removal still
runs.
|
@lynxthecat It seems fine but for setup.sh I would drop self-replacing support entirely. For uninstall.sh I think it would be better to guard the entire thing with |
|
Thoughts @ooonea? |
setup.sh (per @rany2): rather than rip out self-replacing wholesale (a deliberate mechanism whose removal is a separate design call), delete only the broken `else` branch. It fires solely when the *downloaded* setup.sh lacks the marker -- i.e. installing a pre-self-replacing (pre-2024) version -- so instead of fixing the rm-then-exec, drop it: a marker-less download now falls through and installs the downloaded files with the current setup.sh. The modern marker path is untouched. uninstall.sh (per @rany2): guard *every* cd with [ -d ... ], not just CONFIG_PREFIX -- the two SCRIPT_PREFIX blocks are folded under one [ -d "${SCRIPT_PREFIX}" ] (dropping the redundant second cd). A missing prefix means nothing to remove there, so the block is skipped instead of aborting the rest of the uninstall under set -eu.
|
@rany2 thanks for the review — both addressed in the latest commit. uninstall.sh — agreed, that's cleaner than my partial fix. Every setup.sh — I'd rather not rip out self-replacing wholesale in a robustness PR: the Happy to remove self-replacing entirely as a separate PR if you'd both prefer — just say the word. |
|
@rany2 how about now? |
Two small installer hygiene fixes (one per file, one commit each).
setup.sh: don'trm -rf "${tmp}"right beforeexec'ing itThe non-self-replacing restart branch removed
${tmp}and thenexec "${tmp}/setup.sh", so theexecalways failed with ENOENT and aborted therestart, leaving a half-finished install. Dropped the premature
rm; theEXIT/INT/TERMtrap still removes${tmp}if theexecfails. (Narrow reach:only downloads predating the
SELF_REPLACINGmarker take this branch.)uninstall.sh: guardcd "${CONFIG_PREFIX}"Under
set -eu,cd "${CONFIG_PREFIX}"aborted the whole uninstall when theconfig dir didn't exist (configs already removed, a re-run after a partial
uninstall, or a Merlin/custom prefix that diverges from
SCRIPT_PREFIX), leavingcake-autorate.sh/lib.sh/etc. on disk. Guarded so program-file removal stillruns.
sh -n/shellcheck -xclean (the pre-existing SC2310 infos insetup.shareunrelated and untouched).