chiark / gitweb /
Mirroring: dgit-mirror-rsync copes with invocation via relative pathname
[dgit.git] / infra / dgit-mirror-rsync
index e73d9a5bcf982fd109902973a4f310f843bf7c67..9afd39f1659c62de4114dd84dd9f6ae4a3fdcca7 100755 (executable)
@@ -30,7 +30,20 @@ case "$DGIT_DRS_DEBUG" in
 *)             set -x  ;;
 esac
 
+fail () {
+       echo >&2 "dgit-mirror-rsync: $*"; exit 127
+}
+
+if [ $# -lt 2 ]; then fail "too few arguments"; fi
+
 self=$0
+
+case "$self" in
+/*)                            ;;
+*/*)   self="$PWD/$self"       ;;
+*)                             ;;
+esac
+
 distrodir=$1;  shift
 action=$1;     shift
 package=$1
@@ -54,10 +67,6 @@ rsyncssh='ssh -o batchmode=yes'
 cd $repos
 queue=_mirror-queue
 
-fail () {
-       echo >&2 "dgit-mirror-rsync: $*"; exit 127
-}
-
 case "$remoterepos" in
 *:/*|/*)       ;;
 '')            fail "remoterepos config not set" ;;
@@ -77,7 +86,7 @@ reinvoke () {
 
        exec                                                    \
        "$@"                                                    \
-       "$0"    "$distrodir" "reinvoke$newaction" "$package"
+       "$self" "$distrodir" "reinvoke$newaction" "$package"
 }
 
 check-package-mirrorable () {