cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit f246cea5d6551c2a6c411e73125b9a2af2bcc601
parent 70d761cbc04afa940398b37b3eab74ad660b49e0
Author: black <dylan.araps@gmail.com>
Date:   Sun, 16 Jun 2019 20:39:42 +0300

Merge pull request #9 from kissx/pkg_install_fix2

kiss: Fix pkg_install if coreutils is reinstalled.
Diffstat:
MREADME.md | 2+-
Mkiss | 19++++++++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md @@ -31,7 +31,7 @@ See: <https://github.com/kissx/packages> POSIX `coreutils`: -- `cat`, `cp`, `find`, `mkdir`, `sh`, `rm`, `rmdir`, `sed`, `tee` +- `cat`, `command`, `cp`, `find`, `mkdir`, `sh`, `rm`, `rmdir`, `sed`, `tee` Other utilities: diff --git 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() {