diff options
author | Allan McRae <allan@archlinux.org> | 2012-06-07 10:12:31 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2012-08-03 16:16:38 +0200 |
commit | 2042b79bcc7904afc195103dfa1fc6b3978d60f7 (patch) | |
tree | d79be7f8bf816b16f8abce488458cfcdf9a3000a | |
parent | 888020de9068218fafe820e631222bc85c47b453 (diff) | |
download | pacman-2042b79bcc7904afc195103dfa1fc6b3978d60f7.tar.gz pacman-2042b79bcc7904afc195103dfa1fc6b3978d60f7.tar.xz |
makepkg: add support for SVN urls
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>
-rw-r--r-- | scripts/makepkg.sh.in | 73 |
1 files 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" ;; *) |