aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authornoreply@github.com <noreply@github.com>2019-06-16 17:39:42 +0000
committernoreply@github.com <noreply@github.com>2019-06-16 17:39:42 +0000
commitb6f6c97afdf4f26b286909c2899d4ce0cead55fa (patch)
treed7d5221c2b89cbd01379426bec0036b4fcac31b5 /kiss
parent9ca70045a914a8e1aa982cc8e554857739167b95 (diff)
parente1e0f8cf3b6769d3d3a8127cf3fc2c82ae2e083d (diff)
downloadcpt-b6f6c97afdf4f26b286909c2899d4ce0cead55fa.tar.gz
Merge pull request #9 from kissx/pkg_install_fix2
kiss: Fix pkg_install if coreutils is reinstalled. FossilOrigin-Name: fc7375e88e5e9c3342e85b49988fb1038f2c3db85d05d9d71f28ddeba7905484
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss19
1 files changed, 16 insertions, 3 deletions
diff --git a/kiss b/kiss
index a2edff5..802589d 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,15 +153,23 @@ pkg_install() {
pkg_remove() {
pkg_list "$name" || return 1
+ # Create a backup of 'rm' and 'rmdir' so they aren't
+ # removed during package removal.
+ 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"
+
+ # Use the backup of 'rm' to remove 'rmdir' and itself.
+ "$cac_dir/rm" "$cac_dir/rmdir" "$cac_dir/rm"
}
pkg_updates() {