aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-05-28 08:20:45 +0000
committermerakor <cem@ckyln.com>2020-05-28 08:20:45 +0000
commit7913d091d56a8225b6fdb790847193a7032985ab (patch)
tree1422ca1942ff0afebbc3dec8000ac1b7201f2539 /kiss
parent3408889014f57d7a7a84436c4970c8f9a4b0831d (diff)
downloadcpt-7913d091d56a8225b6fdb790847193a7032985ab.tar.gz
kiss: check manifests before removing directories
FossilOrigin-Name: d38263212b7d52045fe5cbc5e291ad6e9fb91867f62a2fa29240ea81dab747e8
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss8
1 files changed, 8 insertions, 0 deletions
diff --git a/kiss b/kiss
index 4baee37..8d4c8ad 100755
--- a/kiss
+++ b/kiss
@@ -1046,6 +1046,13 @@ pkg_remove() {
"$sys_db/$1/pre-remove" ||:
fi
+ # Create a temporary list of all directories, so we don't accidentally
+ # remove anything from packages that create empty directories for a
+ # purpose (such as baselayout).
+ manifest_list="$(set +f; pop "$sys_db/$1/manifest" from "$sys_db/"*/manifest)"
+ # shellcheck disable=2086
+ grep -h '/$' $manifest_list | sort -ur > "$mak_dir/dirs"
+
run_hook pre-remove "$1" "$sys_db/$1" root
while read -r file; do
@@ -1054,6 +1061,7 @@ pkg_remove() {
[ "${file##/etc/*}" ] || continue
if [ -d "$KISS_ROOT/$file" ]; then
+ "$grep" -q "^$file/\$" "$mak_dir/dirs" && continue
rmdir "$KISS_ROOT/$file" 2>/dev/null || continue
else
rm -f "$KISS_ROOT/$file"