Allow SVN repo sources in the form: source=("<folder>::<repo>#<fragment>") where <repo> must start with svn (e.g svn+http://) and a <fragment> can specify a revision (e.g. revision=22). Signed-off-by: Allan McRae <allan@archlinux.org> --- If anyone knows stuff about CVS, Mercurial, Darcs or Bazaar and what fragments should be supported for them, let me know... scripts/makepkg.sh.in | 73 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 56f2871..8d20d44 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -196,7 +196,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 @@ -437,6 +437,72 @@ download_git() { popd &>/dev/null } +download_svn() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local folder=$(get_filepath "$netfile") + [[ -z "$folder" ]] && folder="$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 $folder ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn" + if ! svn checkout --config-dir $folder "$url" "$folder"; 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 "$folder" + 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 ${folder##*/} + cp -a $folder . + + cd_safe ${folder##*/} + + if [[ -n $fragment ]]; then + case $fragment in + revision=*) + ref=${fragment##*=} + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if [[ -n $ref ]]; then + if ! svn up -r $ref; then + error "$(gettext "Failure while checking out reference %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + fi + fi + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -456,6 +522,9 @@ download_sources() { git*) download_git "$netfile" ;; + svn*) + download_svn "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -827,7 +896,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*) + git*|svn*) sum="SKIP" ;; *) -- 1.7.10.3