kiss: reduce indentation

This commit is contained in:
Dylan Araps 2021-07-17 17:49:43 +03:00
parent ddbefa66b7
commit fc05246b3b
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 42 additions and 50 deletions

92
kiss
View File

@ -1149,62 +1149,54 @@ file_rwx() {
} }
pkg_install_files() { pkg_install_files() {
while read -r file; do # Copy files and create directories (preserving permissions).
_file=$KISS_ROOT$file while { read -r file && _file=$KISS_ROOT$file; } do case $file in
/etc/*[!/])
# Handle /etc/ files in a special way (via a 3-way checksum) to
# determine how these files should be installed. Do we overwrite
# the existing file? Do we install it as $file.new to avoid
# deleting user configuration? etc.
#
# This is more or less similar to Arch Linux's Pacman with the
# user manually handling the .new files when and if they appear.
test "$1" "$_file" || pkg_etc "$file" "$_tmp_file_pre_pre"
;;
# Copy files and create directories (preserving permissions), */)
# skipping anything located in /etc/. # Skip directories if they already exist in the file system.
# # (Think /usr/bin, /usr/lib, etc).
# The 'test' will run with '-e' for no-overwrite and '-z' [ -d "$_file" ] || {
# for overwrite. file_rwx "$2/${file#/}"
case $file in mkdir -m "$oct" "$_file"
/etc/*[!/]) }
# Handle /etc/ files in a special way (via a 3-way checksum) to ;;
# determine how these files should be installed. Do we overwrite
# the existing file? Do we install it as $file.new to avoid
# deleting user configuration? etc.
#
# This is more or less similar to Arch Linux's Pacman with the
# user manually handling the .new files when and if they appear.
test "$1" "$_file" || pkg_etc "$file" "$_tmp_file_pre_pre"
;;
*/) *)
# Skip directories if they already exist in the file system. if [ -d "$_file" ] || test "$1" "$_file"; then
# (Think /usr/bin, /usr/lib, etc). # Skip directories as they're likely symlinks in this case.
[ -d "$_file" ] || { # Pure directories in manifests have a suffix of '/'.
file_rwx "$2/${file#/}" continue
mkdir -m "$oct" "$_file"
}
;;
*) elif [ -h "$_file" ]; then
if [ -d "$_file" ] || test "$1" "$_file"; then # Copy the file to the destination directory overwriting
# Skip directories as they're likely symlinks in this case. # any existing file.
# Pure directories in manifests have a suffix of '/'. cp -fP "$2$file" "${_file%/*}/."
continue
elif [ -h "$_file" ]; then else
# Copy the file to the destination directory overwriting # Construct a temporary filename which is a) unique and
# any existing file. # b) identifiable as related to the package manager.
cp -fP "$2$file" "${_file%/*}/." __tmp=${_file%/*}/__kiss-tmp-$_pkg-${file##*/}-$KISS_PID
else # Copy the file to the destination directory with the
# Construct a temporary filename which is a) unique and # temporary name created above.
# b) identifiable as related to the package manager. cp -fP "$2$file" "$__tmp" &&
__tmp=${_file%/*}/__kiss-tmp-$_pkg-${file##*/}-$KISS_PID
# Copy the file to the destination directory with the # Atomically move the temporary file to its final
# temporary name created above. # destination. The running processes will either get
cp -fP "$2$file" "$__tmp" && # the old file or the new one.
mv -f "$__tmp" "$_file"
# Atomically move the temporary file to its final fi
# destination. The running processes will either get esac || return 1; done
# the old file or the new one.
mv -f "$__tmp" "$_file"
fi
esac || return 1
done
unset _etc_cnt unset _etc_cnt
} }