Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-10-20 17:11:34 +0200
committerErich Eckner <git@eckner.net>2020-10-20 17:11:34 +0200
commit0e1be34687beccc0bdbccfac6a83006e040d54b7 (patch)
tree90d904510368fdc692a7d87ebd8361952642b153 /lib
parent17bd4887275d28a63e514ad0f6ff5d4f66e598fe (diff)
lib/common-functions: failsafe_sftp(): use less magic for $master_mirror_sftp_root - simply cd $master_mirror_sftp_root before doing anything else
Diffstat (limited to 'lib')
-rwxr-xr-xlib/common-functions20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/common-functions b/lib/common-functions
index b64af00..8b842ff 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -871,12 +871,6 @@ failsafe_sftp() {
trial_counter=20
trap 'rm -rf --one-file-system "${temp_dir}"' EXIT
cat > "${temp_dir}/input"
- if [ -n "${master_mirror_sftp_root}" ]; then
- sed -i '
- /^\(rm\|rename\) / s@"\([^"]\+\)"@"'"${master_mirror_sftp_root}"'/\1"@g
- /^ln / s@"\([^"]\+\)"$@"'"${master_mirror_sftp_root}"'/\1"@
- ' "${temp_dir}/input"
- fi
sed -n '
s/^rm "\([^"]\+\)"$/- \1/
s/^ln\( [^"]\S*\)* "[^"]\+" "\([^"]\+\)"$/+ \2/
@@ -885,7 +879,10 @@ failsafe_sftp() {
p
' "${temp_dir}/input" > \
"${temp_dir}/expectations"
- if ${master_mirror_sftp_command} < "${temp_dir}/input"; then
+ if sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" \
+ | ${master_mirror_sftp_command}; then
# we're done
exit 0
fi
@@ -901,13 +898,18 @@ failsafe_sftp() {
# - succeeding sftp command to create listing (e.g. all expected
# files are found)
# - no unexpected files were found
- if ${master_mirror_sftp_command} < \
- "${temp_dir}/input" && \
+ if sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" \
+ | ${master_mirror_sftp_command} && \
sed '
s/^+ \(\S\+\)$/ls -1 "\1"/
s,^- \(\S\+/\)[^/]\+$,ls -1 "\1",
' "${temp_dir}/expectations" | \
sort -u | \
+ sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" | \
${master_mirror_sftp_command} > "${temp_dir}/check" && \
! grep -qxF "$(
sed -n '