From 8a1a88e0d30778ba67f1652919e82e237283fa04 Mon Sep 17 00:00:00 2001 From: Pratham Date: Wed, 26 Oct 2022 09:19:25 +0200 Subject: [PATCH] kiss: fixup etcsums, closes #94 (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` λ rm -rf /tmp/root λ KISS_FORCE=1 kiss i iproute2 -> iproute2 Checking for package conflicts -> iproute2 Installing package (iproute2@5.19.0-1.tar.gz) -> iproute2 Installed successfully λ kiss r iproute2 -> iproute2 Checking if package removable -> iproute2 Removing package Skipping /etc/iproute2/rt_tables (modified) Skipping /etc/iproute2/rt_scopes (modified) Skipping /etc/iproute2/rt_realms (modified) Skipping /etc/iproute2/rt_protos (modified) Skipping /etc/iproute2/nl_protos (modified) Skipping /etc/iproute2/group (modified) Skipping /etc/iproute2/ematch_map (modified) Skipping /etc/iproute2/bpf_pinning (modified) -> iproute2 Removed successfully λ λ rm -rf /tmp/root λ KISS_FORCE=1 $PWD/kiss i iproute2 -> iproute2 Checking for package conflicts -> iproute2 Installing package (iproute2@5.19.0-1.tar.gz) -> iproute2 Installed successfully λ $PWD/kiss r iproute2 -> iproute2 Checking if package removable -> iproute2 Removing package -> iproute2 Removed successfully ``` Co-authored-by: git-bruh Reviewed-on: https://codeberg.org/kiss-community/kiss/pulls/97 --- kiss | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/kiss b/kiss index a1bb3c4..91c2256 100755 --- a/kiss +++ b/kiss @@ -935,9 +935,16 @@ pkg_etcsums() { # Minor optimization - skip packages without /etc/. [ -d "$pkg_dir/$repo_name/etc" ] || return 0 - # Create a list of all files in etc but do it in reverse. while read -r etc; do case $etc in /etc/*[!/]) - set -- "$pkg_dir/$repo_name/$etc" "$@" + etc="$pkg_dir/$repo_name/$etc" + # Always use hash of /dev/null as the hash for symlinks as it's + # possible that they can never be resolved/hashed + # (eg. directory, non-existent path, ...) + # So they leave missing lines in etcsums which breaks removal of all + # other unmodified files in /etc aswell + [ -h "$etc" ] && etc=/dev/null + + set -- "$@" "$etc" esac done < manifest b3 "$@" > etcsums @@ -1437,7 +1444,7 @@ pkg_remove_files() { case "${#sum_pkg}" in 64) sh256 "$KISS_ROOT/$file" >/dev/null ;; - 66) b3 "$KISS_ROOT/$file" >/dev/null ;; + *) b3 "$KISS_ROOT/$file" >/dev/null ;; esac equ "$hash" "$sum_pkg" || { @@ -1475,7 +1482,7 @@ pkg_etc() { case "${#sum_old}" in 64) sh256 "$tar_dir/$_pkg$file" "$KISS_ROOT$file" >/dev/null ;; - 66) b3 "$tar_dir/$_pkg$file" "$KISS_ROOT$file" >/dev/null ;; + *) b3 "$tar_dir/$_pkg$file" "$KISS_ROOT$file" >/dev/null ;; esac sum_new=${hash%%"$newline"*}