Files
ElyOffice/packaging/windows/files.sh
T
ZacharyZhang-NYandClaude Opus 5.5 23735aee3c R6.11 round 1 fix: the installer removes only what it installed
Reinstalling deleted files Ely never installed, and a busy file left a
half-removed install. The installer now writes the top-level names it
installs (.ely-files, from packaging/windows/files.sh); upgrades and
uninstall remove only those, and releases before the list only in the
folder the registry names. It checks that every listed file can be
written, moves them all into .ely-old, and on any refusal puts them
back and exits 2. A file that cannot be written fails the install,
which removes what it created and restores the old release.
tests/scripts/windows-installer.sh covers each case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 15:59:50 -04:00

32 lines
876 B
Bash

#!/usr/bin/env bash
# Prints NSIS macros naming what a stage installs.
# Usage: files.sh <stage> <slug>
set -euo pipefail
stage=${1:?staged folder from packaging/stage.sh}
slug=${2:?app slug, such as ely-doc}
names=$({ ls -A "$stage"; echo "$slug.ico"; echo uninstall.exe; } | sort -u)
for name in $names; do
[[ $name =~ ^[A-Za-z0-9._-]+$ ]] || {
echo "files.sh: unsafe name $name" >&2
exit 1
}
done
# The list the next install and the uninstaller remove.
echo '!macro ElyWriteOwned'
echo ' FileOpen $9 "$INSTDIR\.ely-files" w'
for name in $names; do
echo " FileWrite \$9 \"$name\$\\r\$\\n\""
done
echo ' FileClose $9'
echo '!macroend'
# Names this install creates, for a rollback to remove.
echo '!macro ElyNoteNew'
for name in $names; do
echo " IfFileExists \"\$INSTDIR\\$name\" +2"
echo " FileWrite \$R2 \"$name\$\\r\$\\n\""
done
echo '!macroend'