[pacman-dev] [PATCH] Bazaar VCS support
Allan McRae
allan at archlinux.org
Thu Sep 13 01:52:16 EDT 2012
On 11/09/12 00:24, Gary van der Merwe wrote:
<snip>
> Signed-off-by: Gary van der Merwe <garyvdm at gmail.com>
Almost there! Fairly minor comments below.
Thanks for the explanation of the different behaviour of the bzr
checkout compared to git, hg, etc.
> ---
> doc/PKGBUILD.5.txt | 5 +++-
> scripts/makepkg.sh.in | 77 +++++++++++++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
> index 47f9e88..052c2eb 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 `git`, `hg`, `bzr` and
Please change this (and throughout the patch) to keep protocols in
alphabetical order.
> `svn` protocols.
>
> The source URL is divided into three components:
> @@ -433,6 +433,9 @@ The source URL is divided into three components:
> *hg*;;
> branch, revision, tag
>
> + *bzr*;;
> + revision (see `bzr help revisionspec` for details)
> +
> *svn*;;
> revision
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 6de7b4f..ca99566 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*)
> + git*|hg*|svn*|bzr*)
> 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*)
> + git*|hg*|svn*|bzr*)
> filename=${netfile%%#*}
> filename=${filename%/}
> filename=${filename##*/}
> @@ -578,6 +578,74 @@ download_svn() {
> popd &>/dev/null
> }
>
> +download_bzr() {
> + local netfile=$1
> +
> + local url=$(get_url "$netfile")
> + url=${url##*bzr+}
> + url=${url%%#*}
> +
> + local fragment=${netfile##*#}
This has been changed in the other vcs functons on my git branch to
${netfile#*#} as that allows the fragment to contain a "#" character.
> + if [[ $fragment = "$netfile" ]]; then
> + unset fragment
> + fi
> +
> + local displaylocation="$url"
> + local revision="-r-1"
Strings starting with a "-" can lead to issues... Changes this to:
revision=('-r-1')
> +
> + if [[ -n $fragment ]]; then
> + case ${fragment%%=*} in
> + revision)
> + revision="-r${fragment##*=}"
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" $revisionspec --no-tree --use-existing-dir; then
I guess $revisionspec should be $revision? And with comment above it
will be $(revision[@])
> + 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" $revisionspec --overwrite; then
And again.
> + # 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
> +
> + cd_safe "${dir##*/}"
cd right before popd? Delete.
> + popd &>/dev/null
> +}
> +
> download_sources() {
> msg "$(gettext "Retrieving Sources...")"
>
> @@ -605,6 +673,9 @@ download_sources() {
> svn*)
> (( GET_VCS )) && download_svn "$netfile"
> ;;
> + bzr*)
> + (( GET_VCS )) && download_bzr "$netfile"
> + ;;
> *)
> download_file "$netfile"
> ;;
> @@ -975,7 +1046,7 @@ generate_checksums() {
> proto="$(get_protocol "$netfile")"
>
> case $proto in
> - git*|hg*|svn*)
> + git*|hg*|svn*|bzr*)
> sum="SKIP"
> ;;
> *)
>
More information about the pacman-dev
mailing list