Fix handling ownership of parent directories.
This commit is contained in:
parent
f1eaaf12b3
commit
c947def321
@ -64,12 +64,8 @@ let
|
|||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
find ${source} -type f -print0 | while read -r -d "" file; do
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
relative_path=$(realpath -s --relative-to ${source} "$file")
|
||||||
full_dest=${destination}/"$relative_path"
|
full_dest=${destination}/"$relative_path"
|
||||||
containing_directory=$(dirname "$full_dest")
|
create_containing_directories "$full_dest" ${dir_flags}
|
||||||
if [ ! -e "$containing_directory" ]; then
|
$DRY_RUN_CMD install $VERBOSE_ARG --compare ${flags} "$file" "$full_dest"
|
||||||
echo ""
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG -d ${dir_flags} "$containing_directory"
|
|
||||||
fi
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare ${flags} "$file" "$full_dest"
|
|
||||||
done
|
done
|
||||||
''
|
''
|
||||||
]
|
]
|
||||||
@ -137,10 +133,7 @@ let
|
|||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
find ${source} -type f -print0 | while read -r -d "" file; do
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
relative_path=$(realpath -s --relative-to ${source} "$file")
|
||||||
full_dest=${destination}/"$relative_path"
|
full_dest=${destination}/"$relative_path"
|
||||||
containing_directory=$(dirname "$full_dest")
|
create_containing_directories "$full_dest" ${dir_flags}
|
||||||
if [ ! -e "$containing_directory" ]; then
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG -d ${dir_flags} "$containing_directory"
|
|
||||||
fi
|
|
||||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s "$file" "$full_dest"
|
$DRY_RUN_CMD ln $VERBOSE_ARG -s "$file" "$full_dest"
|
||||||
$DRY_RUN_CMD chown $VERBOSE_ARG -h ${owner} "$full_dest"
|
$DRY_RUN_CMD chown $VERBOSE_ARG -h ${owner} "$full_dest"
|
||||||
done
|
done
|
||||||
@ -318,6 +311,7 @@ in
|
|||||||
''
|
''
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
source ${./files/lib.bash}
|
||||||
''
|
''
|
||||||
+ (lib.strings.concatStringsSep "\n" (
|
+ (lib.strings.concatStringsSep "\n" (
|
||||||
[
|
[
|
||||||
@ -329,6 +323,7 @@ in
|
|||||||
''
|
''
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
source ${./files/lib.bash}
|
||||||
''
|
''
|
||||||
+ (lib.strings.concatStringsSep "\n" uninstall_commands);
|
+ (lib.strings.concatStringsSep "\n" uninstall_commands);
|
||||||
};
|
};
|
||||||
|
38
nix/configuration/util/install_files/files/lib.bash
Normal file
38
nix/configuration/util/install_files/files/lib.bash
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
|
||||||
|
############## Setup #########################
|
||||||
|
|
||||||
|
function die {
|
||||||
|
local status_code="$1"
|
||||||
|
shift
|
||||||
|
(>&2 echo "${@}")
|
||||||
|
exit "$status_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
function log {
|
||||||
|
(>&2 echo "${@}")
|
||||||
|
}
|
||||||
|
|
||||||
|
############## Program #########################
|
||||||
|
|
||||||
|
function create_containing_directories {
|
||||||
|
local full_dest="$1"
|
||||||
|
shift 1
|
||||||
|
local dirs_to_create=()
|
||||||
|
local containing_directory="$full_dest"
|
||||||
|
while true; do
|
||||||
|
containing_directory=$(dirname "$containing_directory")
|
||||||
|
if [ -e "$containing_directory" ] || [ "$containing_directory" = "/" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
dirs_to_create+=($containing_directory)
|
||||||
|
done
|
||||||
|
|
||||||
|
for (( idx=${#dirs_to_create[@]}-1 ; idx>=0 ; idx-- )) ; do
|
||||||
|
local containing_directory="${dirs_to_create[idx]}"
|
||||||
|
log "Creating $containing_directory"
|
||||||
|
$DRY_RUN_CMD install $VERBOSE_ARG -d "${@}" "$containing_directory"
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user