diff options
author | merakor <cem@ckyln.com> | 2020-04-22 13:39:19 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-04-22 13:39:19 +0000 |
commit | 717fb53a41037631ae457caf132f655481f0c019 (patch) | |
tree | 9c9f02f2b2293a0a8359da20f4e415e8147b534a | |
parent | 3bde88ae33aa109fc114c47b7a07f3c77188fbb0 (diff) | |
download | cpt-717fb53a41037631ae457caf132f655481f0c019.tar.gz |
kiss: drop rsync
FossilOrigin-Name: 583ddf62134c3fc795653d43a9c131883b88d36c802794867b44b8ece97ebcf7
-rwxr-xr-x | kiss | 52 |
1 files changed, 40 insertions, 12 deletions
@@ -853,6 +853,43 @@ pkg_swap() { sed -i "$(esc "$PWD/$alt" "$2")" "../installed/$1/manifest" } +pkg_install_files() { + # Store the total lines in the manifest file for use in the + # installation counter output. + man_tot=$(wc -l < "$2/$pkg_db/${2##*/}/manifest") + + # Do a dictionary sort of the file so that we list directories first. + sort -d "$2/$pkg_db/${2##*/}/manifest" | + while read -r line; do i=$((i+1)) + # Grab the permissions so that we can preserve them. + perms=$(stat -c %a "$tar_dir/$pkg_name/$line") + + # Copy files and create directories (preserving permissions), + # skipping anything located in /etc/. + # + # The 'test' will run with '-e' for no-overwrite and '-z' + # for overwrite. + case $line in /etc/*) ;; + */) [ -d "$line" ] || mkdir -m "$perms" "$line" ;; + *) test "$1" "$line" || cp -Pp "$2/$line" "${line%/*}" ;; + esac + + # Set the ownership of the result to root:root. + chown root:root "$line" + + # Preserve permissions by using chmod. This runs after + # chown as chown will reset suid/guid when ownership changes. + # + # This only runs on non-directories as we desire the reset + # behavior mentioned above. + [ -d "$line" ] || chmod "$perms" "$line" + + printf '%s %s (%s)\e[K\r' "$3" "$i/$man_tot" "$line" + done + + printf '\n' +} + pkg_etc() { [ -d "$tar_dir/$pkg_name/etc" ] || return 0 @@ -1027,16 +1064,9 @@ pkg_install() { cp -f "$sys_db/$pkg_name/manifest" "$mak_dir/m" 2>/dev/null ||: cp -f "$sys_db/$pkg_name/etcsums" "$mak_dir/c" 2>/dev/null ||: - # This is repeated multiple times. Better to make it a function. - pkg_rsync() { - rsync --chown=root:root --chmod=Du-s,Dg-s,Do-s \ - -WhHKa --no-compress --exclude /etc "$1" \ - "$tar_dir/$pkg_name/" "$KISS_ROOT/" - } + # The sort command is used to list directories first. - # Install the package by using 'rsync' and overwrite any existing files - # (excluding '/etc/'). - pkg_rsync --info=progress2 + pkg_install_files -z "$tar_dir/$pkg_name" "Installing file" pkg_etc # Remove any leftover files if this is an upgrade. @@ -1065,9 +1095,7 @@ pkg_install() { fi done ||: - # Install the package again to fix any non-leftover files being - # removed above. - { pkg_rsync --; pkg_rsync --; } ||: + pkg_install_files -e "$tar_dir/$pkg_name" "Checking file" # Reset 'trap' to its original value. Installation is done so # we no longer need to block 'Ctrl+C'. |