cpt

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

commit 5a1f80efc2d1d5b90f095e54100ca69e0d5d0e82
parent 0a7d30269150f09994c41a772c63439c5153a257
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 22 Apr 2020 16:39:20 +0300

kiss: drop rsync

Diffstat:
Mkiss | 52++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/kiss b/kiss @@ -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'.