R6.11 round 2 fix: the installer lists every file it installs
The list names each file and folder; upgrades and uninstall move only listed files and remove a folder only when empty. Every file, nested ones included, must be writable first. A new file whose place holds a file this app did not install refuses the install. A copy failing midway removes what it wrote and puts the old release back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8946a08538
commit
50d348d4e5
5 files changed
+232
-101
No files matched your search
+16
-23
@@ -1,30 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prints NSIS macros naming a stage: files.sh <stage> <slug>
|
||||
# Prints the files and folders an install owns: 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
|
||||
cd "$stage"
|
||||
[ -z "$(find . -type l)" ] || {
|
||||
echo "files.sh: links in $stage" >&2
|
||||
exit 1
|
||||
}
|
||||
# Folders first, parents before children; then files.
|
||||
{
|
||||
find . -mindepth 1 -type d | sort | sed 's|$|/|'
|
||||
{ find . -type f; echo "./$slug.ico"; echo ./uninstall.exe; } | sort -u
|
||||
} | sed 's|^\./||' | while IFS= read -r path; do
|
||||
case $path in *\\* | *[[:cntrl:]]*)
|
||||
echo "files.sh: unsafe name $path" >&2
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
esac
|
||||
printf '%s\r\n' "${path//\//\\}"
|
||||
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'
|
||||
Reference in new issue
Block a user