[pacman-dev] [PATCH 11/11] makepkg: add support for SVN urls
Allan McRae
allan at archlinux.org
Tue Jun 26 19:18:54 EDT 2012
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 at archlinux.org>
---
scripts/makepkg.sh.in | 72 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 69 insertions(+), 3 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 5cc378d..f113581 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
@@ -232,9 +232,11 @@ get_filename() {
local proto=$(get_protocol "$netfile")
case $proto in
- git*)
+ git*|svn*)
filename=${netfile##*/}
filename=${filename%%#*}
+ ;;&
+ git*)
filename=${filename%%.git*}
;;
*)
@@ -444,6 +446,67 @@ 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##*/}
+
+ 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 $folder; 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...")"
@@ -463,6 +526,9 @@ download_sources() {
git*)
download_git "$netfile"
;;
+ svn*)
+ download_svn "$netfile"
+ ;;
*)
error "$(gettext "Unknown download protocol: %s")" "$proto"
plain "$(gettext "Aborting...")"
@@ -834,7 +900,7 @@ generate_checksums() {
proto="$(get_protocol "$netfile")"
case $proto in
- git*)
+ git*|svn*)
sum="SKIP"
;;
*)
--
1.7.11.1
More information about the pacman-dev
mailing list