1
0
Fork 0
mirror of synced 2024-11-04 17:08:56 -05:00

Remove unused function alt_past_linking

Unused as of b19c78b8
This commit is contained in:
Erik Flodin 2020-10-18 22:20:06 +02:00
parent b19c78b8e2
commit 3ce59314f5
No known key found for this signature in database
GPG key ID: 420A7C865EE3F85F

74
yadm
View file

@ -670,80 +670,6 @@ function alt_linking() {
}
function alt_past_linking() {
if [ -z "$local_class" ] ; then
match_class="%"
else
match_class="$local_class"
fi
match_class="(%|$match_class)"
match_system="(%|$local_system)"
match_host="(%|$local_host)"
match_user="(%|$local_user)"
# regex for matching "<file>##CLASS.SYSTEM.HOSTNAME.USER"
match1="^(.+)##(()|$match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user)$"
match2="^(.+)##($match_class|$match_class\.$match_system|$match_class\.$match_system\.$match_host|$match_class\.$match_system\.$match_host\.$match_user)$"
# loop over all "tracked" files
# for every file which matches the above regex, create a symlink
for match in $match1 $match2; do
last_linked=''
local IFS=$'\n'
# the alt_paths looped over here are a unique sorted list of both files and their immediate parent directory
for alt_path in $(for tracked in "${tracked_files[@]}"; do printf "%s\n" "$tracked" "${tracked%/*}"; done | LC_ALL=C sort -u) "${ENCRYPT_INCLUDE_FILES[@]}"; do
alt_path="$YADM_BASE/$alt_path"
if [ -e "$alt_path" ] ; then
if [[ $alt_path =~ $match ]] ; then
if [ "$alt_path" != "$last_linked" ] ; then
new_link="${BASH_REMATCH[1]}"
debug "Linking $alt_path to $new_link"
[ -n "$loud" ] && echo "Linking $alt_path to $new_link"
if [ "$do_copy" -eq 1 ]; then
if [ -L "$new_link" ]; then
rm -f "$new_link"
fi
cp -f "$alt_path" "$new_link"
else
ln_relative "$alt_path" "$new_link"
fi
last_linked="$alt_path"
fi
fi
fi
done
done
# loop over all "tracked" files
# for every file which is a *##yadm.j2 create a real file
local match="^(.+)##yadm\\.j2$"
for tracked_file in "${tracked_files[@]}" "${ENCRYPT_INCLUDE_FILES[@]}"; do
tracked_file="$YADM_BASE/$tracked_file"
if [ -e "$tracked_file" ] ; then
if [[ $tracked_file =~ $match ]] ; then
real_file="${BASH_REMATCH[1]}"
if envtpl_available; then
debug "Creating $real_file from template $tracked_file"
[ -n "$loud" ] && echo "Creating $real_file from template $tracked_file"
temp_file="${real_file}.$$.$RANDOM"
YADM_CLASS="$local_class" \
YADM_OS="$local_system" \
YADM_HOSTNAME="$local_host" \
YADM_USER="$local_user" \
YADM_DISTRO="$local_distro" \
"$ENVTPL_PROGRAM" --keep-template "$tracked_file" -o "$temp_file"
[ -f "$temp_file" ] && mv -f "$temp_file" "$real_file"
else
debug "envtpl not available, not creating $real_file from template $tracked_file"
[ -n "$loud" ] && echo "envtpl not available, not creating $real_file from template $tracked_file"
fi
fi
fi
done
}
function ln_relative() {
local full_source full_target target_dir
full_source="$1"