Exheredludis/paludis/syncers/dorsync.in
David Leverton da6f52c936 Remove --new-compress from rsync
Doesn't work with older servers.  Since no server version supports
both --compress and --new-compress, use neither and let users specify
it in sync_options if they need it.

complaints -> rsync upstream
2015-08-04 17:13:13 +01:00

96 lines
2.6 KiB
Bash

#!/usr/bin/env bash
source "${PALUDIS_EBUILD_DIR}/echo_functions.bash"
old_set=$-
set -a
for f in ${PALUDIS_BASHRC_FILES}; do
[[ -f "${f}" ]] && source "${f}"
done
[[ "${old_set}" == *a* ]] || set +a
LOCAL=
REMOTE=
unset LANG ${!LC_*}
export LC_ALL=C
RSYNC_OPTIONS=( )
while [[ $# -gt 0 ]]; do
case "${1}" in
--exclude=*)
RSYNC_OPTIONS[${#RSYNC_OPTIONS[@]}]=--exclude
RSYNC_OPTIONS[${#RSYNC_OPTIONS[@]}]="${1#*=}"
;;
--exclude-from=*)
RSYNC_OPTIONS[${#RSYNC_OPTIONS[@]}]=--exclude-from
RSYNC_OPTIONS[${#RSYNC_OPTIONS[@]}]="${1#*=}"
;;
--rsync-option=*)
RSYNC_OPTIONS[${#RSYNC_OPTIONS[@]}]="${1#*=}"
;;
--help)
PROTO="${0##*/do}"
if [[ "${PROTO}" == rsync ]]; then
echo " URL syntax: ${PROTO}://[USERNAME@]SERVER[:PORT]/PATH"
elif [[ "${PROTO}" == file ]]; then
echo " URL syntax: file:///PATH"
elif [[ "${PROTO}" == 'rsync+ssh' ]]; then
echo " URL syntax: rsync+ssh://[USERNAME@]SERVER:/PATH"
else
ewarn "URL syntax for ${PROTO} is unknown. This script will likely not work with the ${PROTO} protocol"
fi
echo " Options:"
echo " --exclude=PATTERN Use PATTERN as an exclude pattern"
echo " --exclude-from=FILE Use FILE as a list of exclude patterns"
echo " --rsync-option=OPTION Pass OPTION to rsync"
exit 0
;;
--revision=*)
eerror "${0}: --revision unsupported"
exit 1
;;
--*)
ewarn "${0}: unknown option '${1%%=*}'"
;;
*)
if [[ -z "${LOCAL}" ]]; then
LOCAL="${1}"
elif [[ -z "${REMOTE}" ]]; then
REMOTE="${1}"
else
eerror "${0}: extra argument '${1}'"
exit 1
fi
;;
esac
shift
done
if [[ -z "${LOCAL}" ]]; then
eerror "${0}: unspecified local repository directory"
exit 1
elif [[ -z "${REMOTE}" ]]; then
eerror "${0}: unspecified remote repository URL"
exit 1
fi
REMOTE="${REMOTE#file://}"
REMOTE="${REMOTE#rsync+ssh://}"
${RSYNC_WRAPPER} rsync --recursive --links --safe-links --perms --times \
--force --whole-file --delete --delete-delay --stats --timeout=180 \
${PALUDIS_SYNC_FILTER_FILE:+--filter "merge ${PALUDIS_SYNC_FILTER_FILE}"} \
--exclude=/.cache --progress "${RSYNC_OPTIONS[@]}" "${REMOTE%/}/" "${LOCAL}/"