From 8f4faa1707c4776c6136962e4c8bc01f41d3635c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 16 Jun 2019 19:50:57 +0300 Subject: [PATCH 1/4] kiss: Fix pkg_install if coreutils is reinstalled. --- kiss | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index a2edff5..a35f9d0 100755 --- a/kiss +++ b/kiss @@ -137,8 +137,13 @@ pkg_tar() { pkg_install() { [ -f "$bin_dir/$pkg" ] || args b "$name" + # Create a backup of 'tar' so it isn't removed during + # package installation. + cp "$(command -v tar)" "$cac_dir" + pkg_remove "$name" - tar pxvf "$bin_dir/$pkg" -k -C "$sys_dir/" 2>/dev/null + "$cac_dir/tar" kpxvf "$bin_dir/$pkg" -C "$sys_dir/" + rm "$cac_dir/tar" "$sys_db/$name/post-install" 2>/dev/null @@ -148,13 +153,18 @@ pkg_install() { pkg_remove() { pkg_list "$name" || return 1 + # Create a backup of 'rm' and 'rmdir' so they aren't + # removed during package installation. + cp "$(command -v rm)" "$cac_dir" + cp "$(command -v rmdir)" "$cac_dir" + while read -r file; do [ "${file%/*}" = /etc ] && continue if [ -d "$sys_dir$file" ]; then - rmdir "$sys_dir$file" 2>/dev/null || continue + "$cac_dir/rmdir" "$sys_dir$file" 2>/dev/null || continue else - rm -f -- "$sys_dir$file" || log "Failed to remove $file." + "$cac_dir/rm" -f -- "$sys_dir$file" || log "Failed to remove $file." fi && log "Removed $file" done < "$sys_db/$name/manifest" } From 6342f187ce65b64b497d3553e09418eb71e9dc0b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 16 Jun 2019 19:54:30 +0300 Subject: [PATCH 2/4] kiss: Removed backed up versions of rm/rmdir --- kiss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kiss b/kiss index a35f9d0..d00c0b5 100755 --- a/kiss +++ b/kiss @@ -167,6 +167,9 @@ pkg_remove() { "$cac_dir/rm" -f -- "$sys_dir$file" || log "Failed to remove $file." fi && log "Removed $file" done < "$sys_db/$name/manifest" + + # Use the backup of 'rm' to remove 'rmdir' and itself. + "$cac_dir/rm" "$cac_dir/rmdir" "$cac_dir/rm" } pkg_updates() { From cbb94091203b469c56f45a91f26a9ef895ab6bbc Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 16 Jun 2019 19:59:21 +0300 Subject: [PATCH 3/4] docs: update --- kiss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kiss b/kiss index d00c0b5..802589d 100755 --- a/kiss +++ b/kiss @@ -154,7 +154,7 @@ pkg_remove() { pkg_list "$name" || return 1 # Create a backup of 'rm' and 'rmdir' so they aren't - # removed during package installation. + # removed during package removal. cp "$(command -v rm)" "$cac_dir" cp "$(command -v rmdir)" "$cac_dir" From ecf553ff918194764cd833c2fe68eab3ede72dd8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 16 Jun 2019 20:35:39 +0300 Subject: [PATCH 4/4] docs: update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 987622f..0f4f7d7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ See: POSIX `coreutils`: -- `cat`, `cp`, `find`, `mkdir`, `sh`, `rm`, `rmdir`, `sed`, `tee` +- `cat`, `command`, `cp`, `find`, `mkdir`, `sh`, `rm`, `rmdir`, `sed`, `tee` Other utilities: