aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoreply@github.com <noreply@github.com>2019-07-21 08:45:57 +0000
committernoreply@github.com <noreply@github.com>2019-07-21 08:45:57 +0000
commitde9f51eb150aee443b5477f830690aaec030e2a8 (patch)
tree545bce10afe9d1a6dd8e8cc1dc371b0f9e932ffe
parentc7fc36be06ddabca62c860b6753e516e8494c328 (diff)
parent050dbff624056d44148d1cc916ea4965bd01ee52 (diff)
downloadcpt-de9f51eb150aee443b5477f830690aaec030e2a8.tar.gz
Merge pull request #29 from kisslinux/new_install5
Better installation logic. FossilOrigin-Name: 16e04038815a24b263b8795a61f1e75bc87cd13c70aeaaaf9fcbd428a41e3406
-rwxr-xr-xkiss64
1 files changed, 25 insertions, 39 deletions
diff --git a/kiss b/kiss
index 587db68..6229775 100755
--- a/kiss
+++ b/kiss
@@ -594,15 +594,6 @@ pkg_remove() {
# is handled differently and configuration files are *not*
# overwritten.
- # Create a backup of 'rm' and 'rmdir' so they aren't removed
- # during package removal. This ensures that an upgrade to 'busybox'
- # or your core utilities of choice doesn't break the package manager.
- cp "$(command -v rm)" "$cac_dir"
- cp "$(command -v rmdir)" "$cac_dir"
-
- # Don't remove `musl`. This safegaurds against breaking the system.
- [ "$1" != musl ] || return 0
-
# The package is not installed, don't do anything.
pkg_list "$1" >/dev/null || {
log "[$1]: Not installed."
@@ -632,9 +623,9 @@ pkg_remove() {
[ "${file##/etc/*}" ] || continue
if [ -d "$KISS_ROOT/$file" ]; then
- "$cac_dir/rmdir" "$KISS_ROOT/$file" 2>/dev/null || continue
+ rmdir "$KISS_ROOT/$file" 2>/dev/null || continue
else
- "$cac_dir/rm" -f -- "$KISS_ROOT/$file" ||
+ rm -f -- "$KISS_ROOT/$file" ||
log "[$1]: Failed to remove '$file'."
fi
done < "$KISS_ROOT/$pkg_db/$1/manifest"
@@ -685,9 +676,7 @@ pkg_install() {
pkg_conflicts "$tar_file" "$pkg_name"
- # Extract the tar-ball early to catch any errors before installation
- # begins. The package manager uninstalls the previous package during
- # an upgrade so any errors need to be caught ASAP.
+ # Extract the tar-ball to catch any errors before installation begins.
tar pxf "$tar_file" -C "$tar_dir/" ||
die "[$pkg_name]: Failed to extract tar-ball."
@@ -706,15 +695,6 @@ pkg_install() {
die "[$1]: Package requires ${required_install%, }." \
"[$1]: Aborting here..."
- # Create a backup of 'mv', 'rsync' and 'find' so they aren't removed
- # during package removal. This ensures that an upgrade to 'busybox' or
- # your core utilities of choice doesn't break the package manager.
- cp "$(command -v mv)" "$cac_dir"
- cp "$(command -v rsync)" "$cac_dir"
- cp "$(command -v find)" "$cac_dir"
-
- log "[$pkg_name]: Removing previous version of package if it exists."
- pkg_remove "$pkg_name"
log "[$pkg_name]: Installing package..."
# Block being able to abort the script with 'Ctrl+C' during installation.
@@ -722,16 +702,26 @@ pkg_install() {
# an incomplete package installed.
trap '' INT
- # Don't ignore existing files when installing `musl`.
- case $pkg_name in
- musl) rsync_ignore= ;;
- *) rsync_ignore=--ignore-existing ;;
- esac
-
- # "Install" the package using 'rsync'. None of the coreutils could
- # correctly accomplish this task. The preservation of permissions,
- # proper handling of existing files etc.
- "$cac_dir/rsync" "$rsync_ignore" -a "$tar_dir/" "$KISS_ROOT/"
+ # If the package is already installed (and this is an upgrade) make a
+ # backup of the manifest file.
+ [ -f "$KISS_ROOT/$pkg_db/$pkg_name/manifest" ] &&
+ cp -f "$KISS_ROOT/$pkg_db/$pkg_name/manifest" "$cac_dir/m-$pkg_name"
+
+ # Install the package by using 'rsync' and overwrite any existing files
+ # (excluding '/etc/').
+ rsync -Kav --exclude etc -- "$tar_dir/" "$KISS_ROOT/"
+
+ # If '/etc/' exists in the package, install it but don't overwrite.
+ [ -d "$tar_dir/etc" ] &&
+ rsync -Kav --ignore-existing "$tar_dir/etc" "$KISS_ROOT/"
+
+ # Remove any leftover files if this is an upgrade.
+ [ -f "$cac_dir/m-$pkg_name" ]
+ awk 'NR==FNR{lines[$0];next}!($0 in lines)' \
+ "$KISS_ROOT/$pkg_db/$pkg_name/manifest" "$cac_dir/m-$pkg_name" |
+ while read -r file; do
+ rm -f "$KISS_ROOT/$file"
+ done
# Reset 'trap' to its original value. Installation is done so
# we no longer need to block 'Ctrl+C'.
@@ -852,12 +842,8 @@ pkg_clean() {
# Remove temporary directories.
rm -rf -- "$mak_dir" "$pkg_dir" "$tar_dir"
- # Remove cached commands.
- rm -f -- "$cac_dir/find" "$cac_dir/mv" "$cac_dir/rsync" \
- "$cac_dir/rm" "$cac_dir/rmdir"
-
# Remove temporary files.
- rm -f "$repo_dir/.checksums"
+ rm -f "$repo_dir/.checksums" "$cac_dir/m-"*
}
root_check() {
@@ -961,7 +947,7 @@ args() {
# Print version and exit.
v*)
- log "$kiss 0.4.2"
+ log "$kiss 0.5.0"
;;
# Catch all invalid arguments as well as