From 2042b79bcc7904afc195103dfa1fc6b3978d60f7 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 7 Jun 2012 18:12:31 +1000 Subject: makepkg: add support for SVN urls Allow SVN repo sources in the form: source=("::#") where must start with svn (e.g svn+http://) and a can specify a revision (e.g. revision=22). Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 73 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5ff4bb6d..749492cb 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -198,7 +198,7 @@ get_filepath() { local proto="$(get_protocol "$1")" case $proto in - git*) + git*|svn*) if [[ -d "$startdir/$file" ]]; then file="$startdir/$file" elif [[ -d "$SRCDEST/$file" ]]; then @@ -234,9 +234,12 @@ get_filename() { local proto=$(get_protocol "$netfile") case $proto in - git*) + git*|svn*) filename=${netfile##*/} filename=${filename%%#*} + # fall-through + ;;& + git*) filename=${filename%%.git*} ;; *) @@ -446,6 +449,67 @@ download_git() { popd &>/dev/null } +download_svn() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + local repo=${netfile##*/} + repo=${repo%%#*} + + local url=$(get_url "$netfile") + if [[ $url != svn+ssh* ]]; then + url=${url##*svn+} + fi + url=${url%%#*} + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn" + if ! svn checkout --config-dir "$dir" "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + exit 1 + fi + else + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn" + cd_safe "$dir" + if ! svn update; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn" + fi + fi + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn" + pushd "$srcdir" &>/dev/null + rm -rf "${dir##*/}" + + local ref + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + revision) + ref=('-r' "${fragment##*=}") + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if ! svn export $(ref[@]) "$dir"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + fi + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -465,6 +529,9 @@ download_sources() { git*) download_git "$netfile" ;; + svn*) + download_svn "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -835,7 +902,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*) + git*|svn*) sum="SKIP" ;; *) -- cgit v1.2.3