diff options
author | noreply@github.com <noreply@github.com> | 2019-06-26 20:40:34 +0000 |
---|---|---|
committer | noreply@github.com <noreply@github.com> | 2019-06-26 20:40:34 +0000 |
commit | 37c8b555e118ca707c7c952572b5febf1aa2e2e4 (patch) | |
tree | df0d28f49194e4cad83910057a0970f0e493c594 /kiss | |
parent | be6762000d20259440247b4b2db51ab583179b7d (diff) | |
parent | a18b45269edeef01e9b085f1a57afb84b50edc1a (diff) | |
download | cpt-37c8b555e118ca707c7c952572b5febf1aa2e2e4.tar.gz |
Merge pull request #21 from kissx/pkg_install_new2
kiss: Fix package installation bugs.
FossilOrigin-Name: 243e360673e78090a27a9c93834508fb3f08ce1ad4e6920102527b576930390d
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 40 |
1 files changed, 31 insertions, 9 deletions
@@ -20,8 +20,9 @@ source_type() { } pkg_clean() { - rm -rf -- "$mak_dir" "$pkg_dir" \ - "$cac_dir/manifest-$$" "$cac_dir/tar" "$cac_dir/checksums-$$" + rm -rf -- "$mak_dir" "$pkg_dir" "$tar_dir" \ + "$cac_dir/manifest-$$" "$cac_dir/checksums-$$" \ + "$cac_dir/mv" "$cac_dir/mkdir" "$cac_dir/find" } pkg_search() { @@ -172,15 +173,33 @@ pkg_install() { [ -f "$bin_dir/$pkg" ] || args b "$name" pkg_conflicts + tar pxf "$bin_dir/$pkg" -C "$tar_dir/" || die "Failed to extract tarball." - # Create a backup of 'tar' so it isn't removed during - # package installation. - cp "$(command -v tar)" "$cac_dir" + # Create a backup of 'mv', 'mkdir' and 'find' so they aren't removed + # during package removal. + cp "$(command -v mv)" "$cac_dir" + cp "$(command -v mkdir)" "$cac_dir" + cp "$(command -v find)" "$cac_dir" log "Removing previous version of package if it exists." pkg_remove - "$cac_dir/tar" kpxf "$bin_dir/$pkg" -C "$sys_dir/" 2>/dev/null + cd "$tar_dir" || die "Aborting due to tar error." + + # Optimization: Only find the deepest directories. + find . -type d -links -3 -prune | while read -r dir; do + mkdir -p "$sys_dir/${dir#./}" + done + + find ./ -mindepth 1 -not -type d | while read -r file; do + rpath=${file#.} + + [ -z "${rpath##/etc/*}" ] && [ -f "$sys_dir${rpath%/*}/${file##*/}" ] && + return + + mv "$file" "$sys_dir${rpath%/*}" + done + "$sys_db/$name/post-install" 2>/dev/null log "Installed ${pkg%.tar.gz}" @@ -195,17 +214,19 @@ pkg_remove() { cp "$(command -v rmdir)" "$cac_dir" while read -r file; do - [ "${file%/*}" = /etc ] && continue + [ "${file##/etc/*}" ] || continue if [ -d "$sys_dir$file" ]; then "$cac_dir/rmdir" "$sys_dir$file" 2>/dev/null || continue else "$cac_dir/rm" -f -- "$sys_dir$file" || log "Failed to remove $file." - fi && log "Removed $file" + fi done < "$sys_db/${1:-$name}/manifest" # Use the backup of 'rm' to remove 'rmdir' and itself. "$cac_dir/rm" "$cac_dir/rmdir" "$cac_dir/rm" + + log "Removed ${1:-$name}." } pkg_updates() { @@ -230,7 +251,7 @@ pkg_list() { } args() { - [ -w "$KISS_ROOT/" ] || case $1 in + [ -w "$sys_dir/" ] || case $1 in i*|r*) die "No write permissions to \$KISS_ROOT." esac @@ -285,6 +306,7 @@ main() { mkdir -p "${cac_dir:=${XDG_CACHE_HOME:=$HOME/.cache}/$kiss}" \ "${mak_dir:=$cac_dir/build-$$}" \ "${bin_dir:=$cac_dir/bin}" \ + "${tar_dir:=$cac_dir/extract-$$}" \ "${pkg_db:=${pkg_dir:=$cac_dir/pkg-$$}/var/db/$kiss}" || die "Couldn't create directories." |