aboutsummaryrefslogtreecommitdiff
path: root/paludis/syncers/dodarcs.in
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/syncers/dodarcs.in')
-rw-r--r--paludis/syncers/dodarcs.in90
1 files changed, 90 insertions, 0 deletions
diff --git a/paludis/syncers/dodarcs.in b/paludis/syncers/dodarcs.in
new file mode 100644
index 000000000..6281c4e80
--- /dev/null
+++ b/paludis/syncers/dodarcs.in
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+source "${PALUDIS_EBUILD_DIR}/echo_functions.bash"
+
+for f in ${PALUDIS_BASHRC_FILES}; do
+ [[ -f "${f}" ]] && source "${f}"
+done
+
+LOCAL=
+REMOTE=
+
+DARCS_GET_OPTIONS=( )
+DARCS_PULL_OPTIONS=( )
+
+while [[ $# -gt 0 ]]; do
+ case "${1}" in
+
+ --darcs-get-option=*)
+ DARCS_GET_OPTIONS[${#DARCS_GET_OPTIONS[@]}]="${1#*=}"
+ ;;
+
+ --darcs-pull-option=*)
+ DARCS_PULL_OPTIONS[${#DARCS_PULL_OPTIONS[@]}]="${1#*=}"
+ ;;
+
+ --help)
+ PROTO="${0##*/do}"
+ if [[ "${PROTO}" == darcs+ssh ]]; then
+ echo " URL syntax: darcs+ssh://[USERNAME[:PASSWORD]@]SERVER:/PATH"
+ elif [[ "${PROTO}" == darcs+http ]]; then
+ echo " URL syntax: darcs+http://[USERNAME[:PASSWORD]@]SERVER[:PORT]/PATH"
+ else
+ # darcs can handle any protocol as long as you define
+ # environment variables telling it how. The user can
+ # symlink/copy this syncer to enable support for other
+ # protocols, but we can't give them much help with the
+ # syntax....
+ PROTO="${PROTO#darcs+}"
+ echo " URL syntax: darcs+${PROTO}://[$( tr [:lower:] [:upper:] <<<"${PROTO}" )-URL]"
+ fi
+
+ echo " Options:"
+ echo " --darcs-get-option=OPTION Pass OPTION to darcs get"
+ echo " --darcs-pull-option=OPTION Pass OPTION to darcs pull"
+ exit 0
+ ;;
+
+ --*)
+ 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#darcs+ssh://}"
+REMOTE="${REMOTE#darcs+}"
+
+if [[ -d "${LOCAL}" && ! -d "${LOCAL}/_darcs" ]]; then
+ eerror "'${LOCAL}' exists but it is not a Darcs repository"
+ exit 1
+fi
+
+if [[ -d "${LOCAL}/_darcs" ]]; then
+ cd "${LOCAL}" && ${DARCS_WRAPPER} darcs pull --all \
+ --set-scripts-executable "${DARCS_PULL_OPTIONS[@]}" "${REMOTE}"
+else
+ ${DARCS_WRAPPER} darcs get --partial --set-scripts-executable \
+ "${DARCS_GET_OPTIONS[@]}" --repo-name="${LOCAL}" "${REMOTE}"
+fi
+