Support rsync://
This commit is contained in:
parent
e2de0ce73f
commit
b1f7d3ec22
2 changed files with 32 additions and 22 deletions
11
README.rst
11
README.rst
|
@ -16,12 +16,13 @@ Remote helper programs are invoked by git to handle network transport.
|
||||||
This helper handles gcrypt:: URLs that will access a remote repository
|
This helper handles gcrypt:: URLs that will access a remote repository
|
||||||
encrypted with GPG, using our custom format.
|
encrypted with GPG, using our custom format.
|
||||||
|
|
||||||
Supported locations are `local`, `ssh://` and `sftp://`, where the
|
Supported locations are `local`, `ssh://`, `rsync://` and `sftp`, where
|
||||||
repository is stored as a set of files. If the location instead is any
|
the repository is stored as a set of files, or instead any `<giturl>`
|
||||||
`<giturl>`, gcrypt will store the same representation in a git
|
where gcrypt will store the same representation in a git repository,
|
||||||
repository, and so it can be bridged over any git transport.
|
bridged over arbitrary git transport.
|
||||||
|
|
||||||
.. NOTE:: Repository format MAY STILL change, incompatibly
|
.. NOTE:: Repository format MAY STILL change, incompatibly. We may
|
||||||
|
not continue to support all types of remote transport.
|
||||||
|
|
||||||
Quickstart
|
Quickstart
|
||||||
..........
|
..........
|
||||||
|
|
|
@ -121,46 +121,52 @@ gitception_new_repo()
|
||||||
}
|
}
|
||||||
## end gitception
|
## end gitception
|
||||||
|
|
||||||
# Fetch repo $1, file $2
|
# Fetch repo $1, file $2, tmpfile in $3
|
||||||
GET()
|
GET()
|
||||||
{
|
{
|
||||||
if isurl ssh "$1"
|
if isurl ssh "$1"
|
||||||
then
|
then
|
||||||
splitcolon "${1#ssh://}"
|
splitcolon "${1#ssh://}"
|
||||||
(exec 0>&-; ssh "$prefix_" "cat $suffix_/$2")
|
(exec 0>&-; ssh "$prefix_" "cat $suffix_/$2") > "$3"
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
(exec 0>&-; curl -s -S -k "$1/$2")
|
(exec 0>&-; curl -s -S -k "$1/$2") > "$3"
|
||||||
|
elif isurl rsync "$1"
|
||||||
|
then
|
||||||
|
(exec 0>&-; rsync -I -W "${1#rsync://}"/"$2" "$3" >&2)
|
||||||
elif islocalrepo "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
cat "$1/$2"
|
cat "$1/$2" > "$3"
|
||||||
else
|
else
|
||||||
gitception_get "${1#gitception://}" "$2"
|
gitception_get "${1#gitception://}" "$2" > "$3"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Put repo $1, file $2 or fail
|
# Put repo $1, file $2 or fail, tmpfile in $3
|
||||||
PUT()
|
PUT()
|
||||||
{
|
{
|
||||||
if isurl ssh "$1"
|
if isurl ssh "$1"
|
||||||
then
|
then
|
||||||
splitcolon "${1#ssh://}"
|
splitcolon "${1#ssh://}"
|
||||||
ssh "$prefix_" "cat > $suffix_/$2"
|
ssh "$prefix_" "cat > $suffix_/$2" < "$3"
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
curl -s -S -k --ftp-create-dirs -T - "$1/$2"
|
curl -s -S -k --ftp-create-dirs -T "$3" "$1/$2"
|
||||||
|
elif isurl rsync "$1"
|
||||||
|
then
|
||||||
|
rsync -I -W "$3" "${1#rsync://}"/"$2" >&2
|
||||||
elif islocalrepo "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
cat > "$1/$2"
|
cat > "$1/$2" < "$3"
|
||||||
else
|
else
|
||||||
gitception_put "${1#gitception://}" "$2"
|
gitception_put "${1#gitception://}" "$2" < "$3"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Put all PUT changes for repo $1 at once
|
# Put all PUT changes for repo $1 at once
|
||||||
PUT_FINAL()
|
PUT_FINAL()
|
||||||
{
|
{
|
||||||
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
|
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1"
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
|
@ -178,6 +184,9 @@ PUTREPO()
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
|
elif isurl rsync "$1"
|
||||||
|
then
|
||||||
|
rsync -q -r --exclude='*' "$Localdir/" "${1#rsync://}" >&2
|
||||||
elif islocalrepo "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
mkdir -p "$1"
|
mkdir -p "$1"
|
||||||
|
@ -188,7 +197,7 @@ PUTREPO()
|
||||||
|
|
||||||
CLEAN_FINAL()
|
CLEAN_FINAL()
|
||||||
{
|
{
|
||||||
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
|
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1"
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
|
@ -330,7 +339,7 @@ ensure_connected()
|
||||||
|
|
||||||
TmpManifest_Enc="$Localdir/manifest.$$"
|
TmpManifest_Enc="$Localdir/manifest.$$"
|
||||||
trap 'rm -f "$TmpManifest_Enc"' EXIT
|
trap 'rm -f "$TmpManifest_Enc"' EXIT
|
||||||
GET "$URL" "$Repoid" 2>/dev/null > "$TmpManifest_Enc" ||
|
GET "$URL" "$Repoid" "$TmpManifest_Enc" 2>/dev/null ||
|
||||||
echo_die "Repository not found: $url_id at $URL"
|
echo_die "Repository not found: $url_id at $URL"
|
||||||
|
|
||||||
Did_find_repo=yes
|
Did_find_repo=yes
|
||||||
|
@ -413,8 +422,8 @@ do_fetch()
|
||||||
do
|
do
|
||||||
isnonnull "$packline_" || continue
|
isnonnull "$packline_" || continue
|
||||||
pack_=${packline_#"$Packpfx"}
|
pack_=${packline_#"$Packpfx"}
|
||||||
rcv_id="$(GET "$URL" "$pack_" | \
|
GET "$URL" "$pack_" "$TmpPack_Encrypted"
|
||||||
tee "$TmpPack_Encrypted" | pack_hash)"
|
rcv_id=$(pack_hash < "$TmpPack_Encrypted")
|
||||||
if isnoteq "$rcv_id" "$pack_"
|
if isnoteq "$rcv_id" "$pack_"
|
||||||
then
|
then
|
||||||
echo_die "Packfile $pack_ does not match digest!"
|
echo_die "Packfile $pack_ does not match digest!"
|
||||||
|
@ -490,7 +499,7 @@ EOF
|
||||||
then
|
then
|
||||||
pack_id=$(pack_hash < "$TmpPack_Encrypted")
|
pack_id=$(pack_hash < "$TmpPack_Encrypted")
|
||||||
Packlist=$(append "$Packlist" "$Packpfx$pack_id $key_")
|
Packlist=$(append "$Packlist" "$Packpfx$pack_id $key_")
|
||||||
PUT "$URL" "$pack_id" < "$TmpPack_Encrypted"
|
PUT "$URL" "$pack_id" "$TmpPack_Encrypted"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$TmpPack_Encrypted"
|
rm -f "$TmpPack_Encrypted"
|
||||||
|
@ -508,7 +517,7 @@ EOF
|
||||||
repoidstr; xecho "$Extension_list") |
|
repoidstr; xecho "$Extension_list") |
|
||||||
PRIVENCRYPT "$Recipients" > "$TmpManifest_Enc"
|
PRIVENCRYPT "$Recipients" > "$TmpManifest_Enc"
|
||||||
|
|
||||||
PUT "$URL" "$Repoid" < "$TmpManifest_Enc"
|
PUT "$URL" "$Repoid" "$TmpManifest_Enc"
|
||||||
|
|
||||||
PUT_FINAL "$URL"
|
PUT_FINAL "$URL"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue