pkg_install_files: fix internal path issue.

When KISS_ROOT is empty path is //path/to/file.
This commit is contained in:
Dylan Araps 2021-06-28 21:39:43 +00:00
parent e9a2e3472b
commit 17815b698c
1 changed files with 9 additions and 8 deletions

17
kiss
View File

@ -1003,11 +1003,11 @@ pkg_install_files() {
# going down the tree. # going down the tree.
sort "$2/$pkg_db/${2##*/}/manifest" | sort "$2/$pkg_db/${2##*/}/manifest" |
while read -r line; do while read -r file; do
# Grab the octal permissions so that directory creation # Grab the octal permissions so that directory creation
# preserves permissions. # preserves permissions.
# See: [2] at top of script. # See: [2] at top of script.
rwx=$(ls -ld "$2/$line") oct='' b='' o=0 rwx=$(ls -ld "$2/${file#/}") oct='' b='' o=0
# Convert the output of 'ls' (rwxrwx---) to octal. This is simply # Convert the output of 'ls' (rwxrwx---) to octal. This is simply
# a 1-9 loop with the second digit being the value of the field. # a 1-9 loop with the second digit being the value of the field.
@ -1023,28 +1023,29 @@ pkg_install_files() {
[ "$((${c%?} % 3))" = 0 ] && oct=$oct$o o=0 [ "$((${c%?} % 3))" = 0 ] && oct=$oct$o o=0
done done
_file=$KISS_ROOT/${file#/}
# Copy files and create directories (preserving permissions), # Copy files and create directories (preserving permissions),
# skipping anything located in /etc/. # skipping anything located in /etc/.
# #
# The 'test' will run with '-e' for no-overwrite and '-z' # The 'test' will run with '-e' for no-overwrite and '-z'
# for overwrite. # for overwrite.
case $line in /etc/*) ;; case $file in /etc/*) ;;
*/) */)
# Skip directories if they already exist in the file system. # Skip directories if they already exist in the file system.
# (Think /usr/bin, /usr/lib, etc). # (Think /usr/bin, /usr/lib, etc).
[ -d "$KISS_ROOT/$line" ] || mkdir -m "$oct" "$KISS_ROOT/$line" [ -d "$_file" ] || mkdir -m "$oct" "$_file"
;; ;;
*) *)
# Skip directories as they're likely symlinks in this case. # Skip directories as they're likely symlinks in this case.
# Pure directories in manifests have a suffix of '/'. # Pure directories in manifests have a suffix of '/'.
[ -d "$KISS_ROOT/$line" ] || test "$1" "$KISS_ROOT/$line" || { [ -d "$_file" ] || test "$1" "$_file" || {
cp -fP "$2/$line" "$KISS_ROOT/$line" cp -fP "$2/${file#/}" "$_file"
# Skip changing permissions of symlinks. This prevents # Skip changing permissions of symlinks. This prevents
# errors when the symlink exists prior to the target. # errors when the symlink exists prior to the target.
[ -h "$KISS_ROOT/$line" ] || [ -h "$_file" ] || chmod "$b$oct" "$_file"
chmod "$b$oct" "$KISS_ROOT/$line"
} }
esac esac
done ||: done ||: