diff options
author | Gary van der Merwe <garyvdm@gmail.com> | 2012-09-15 04:24:01 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-09-18 15:41:35 +0200 |
commit | 3b02f80dcb3159a7ab0c673d5eae971ad7504e7f (patch) | |
tree | 93e442dde7205f7a0b0227ada9cf0d10ec7b648f | |
parent | ea452d027731e007e58e84e93df72ca66b034f47 (diff) | |
download | pacman-3b02f80dcb3159a7ab0c673d5eae971ad7504e7f.tar.gz pacman-3b02f80dcb3159a7ab0c673d5eae971ad7504e7f.tar.xz |
makepkg: Add Bazaar VCS support
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | doc/PKGBUILD.5.txt | 5 | ||||
-rw-r--r-- | scripts/makepkg.sh.in | 75 |
2 files changed, 76 insertions, 4 deletions
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 47f9e884..0dca4a2d 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -405,7 +405,7 @@ Using VCS Sources[[VCS]] ------------------------ Building a developmental version of a package using sources from a version control system (VCS) is enabled by specifying the source in the form -`source=('folder::url#fragment')`. Currently makepkg supports the `git`, `hg` and +`source=('folder::url#fragment')`. Currently makepkg supports the `bzr`, `git`, `hg` and `svn` protocols. The source URL is divided into three components: @@ -427,6 +427,9 @@ The source URL is divided into three components: have the format `source=(url#revision=123)`. The available fragments depends on the VCS being used: + *bzr*;; + revision (see `bzr help revisionspec` for details) + *git*;; branch, commit, tag diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6de7b4f3..b86084f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -200,7 +200,7 @@ get_filepath() { local proto="$(get_protocol "$1")" case $proto in - git*|hg*|svn*) + bzr*|git*|hg*|svn*) if [[ -d "$startdir/$file" ]]; then file="$startdir/$file" elif [[ -d "$SRCDEST/$file" ]]; then @@ -236,7 +236,7 @@ get_filename() { local proto=$(get_protocol "$netfile") case $proto in - git*|hg*|svn*) + bzr*|git*|hg*|svn*) filename=${netfile%%#*} filename=${filename%/} filename=${filename##*/} @@ -377,6 +377,72 @@ download_file() { ln -s "$SRCDEST/$filename" "$srcdir/" } +download_bzr() { + local netfile=$1 + + local url=$(get_url "$netfile") + url=${url##*bzr+} + url=${url%%#*} + + local fragment=${netfile#*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local displaylocation="$url" + local revision=('-r-1') + + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + revision) + revision=("-r${fragment##*=}") + displaylocation="$url -r ${fragment##*=}" + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then + msg2 "$(gettext "Branching %s ...")" "${displaylocation}" + if ! bzr branch "$url" "$dir" ${revision[@]} --no-tree --use-existing-dir; then + error "$(gettext "Failure while branching %s")" "${displaylocation}" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + # Make sure we are fetching the right repo + if [[ "$url" != "$(bzr config parent_location -d $dir)" ]] ; then + error "$(gettext "%s is not a branch of %s")" "$dir" "$url" + plain "$(gettext "Aborting...")" + exit 1 + fi + msg2 "$(gettext "Pulling %s ...")" "${displaylocation}" + cd_safe "$dir" + if ! bzr pull "$url" ${revision[@]} --overwrite; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while pulling %s")" "${displaylocation}" + fi + fi + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${dir}" "bzr" + pushd "$srcdir" &>/dev/null + rm -rf "${dir##*/}" + + if ! bzr checkout "$dir" --lightweight; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${dir}" "bzr" + plain "$(gettext "Aborting...")" + exit 1 + fi + + popd &>/dev/null +} + download_git() { local netfile=$1 @@ -596,6 +662,9 @@ download_sources() { local) download_local "$netfile" ;; + bzr*) + (( GET_VCS )) && download_bzr "$netfile" + ;; git*) (( GET_VCS )) && download_git "$netfile" ;; @@ -975,7 +1044,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*|hg*|svn*) + bzr*|git*|hg*|svn*) sum="SKIP" ;; *) |