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>
24 lines
668 B
Bash
24 lines
668 B
Bash
#!/usr/bin/env bash
|
|
# 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}
|
|
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
|