[pacman-dev] [PATCH 1/2] makepkg: Bazaar VCS support.
This patch adds Bazaar VCS support to makepkg. Fragments can be any bzr revision spec. eg: http://example.com/project/#revno:62 or just http://example.com/project/#62 For more info, see `bzr help revisionspec`. Writing a pkgver func is easy with `bzr version-info`, eg: pkgver() { cd $srcdir/$pkgname bzr version-info --custom --template="{revno}\n" } --- doc/PKGBUILD.5.txt | 5 ++++- scripts/makepkg.sh.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 47f9e88..c0f96c2 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 `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*;; + revisionspec (see `bzr help revisionspec` for details) + *svn*;; revision diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dd4066b..3460824 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%%#*} # fall-through @@ -572,6 +572,57 @@ download_svn() { popd &>/dev/null } +download_bzr() { + local netfile=$1 + + local url=$(get_url "$netfile") + url=${url##*bzr+} + url=${url%%#*} + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + local revisionspec="-r-1" + local displaylocation="$url" + else + local revisionspec="-r$fragment" + local displaylocation="$url -r $fragment" + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Branching %s ...")" "${displaylocation}" + if ! bzr branch "$url" "$dir" $revisionspec --no-tree; then + error "$(gettext "Failure while branching %s")" "${displaylocation}" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Pulling %s ...")" "${displaylocation}" + cd_safe "$dir" + if ! bzr pull "$url" $revisionspec --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 + + cd_safe "${dir##*/}" + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -602,6 +653,9 @@ download_sources() { svn*) (( GET_VCS )) && download_svn "$netfile" ;; + bzr*) + (( GET_VCS )) && download_bzr "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -974,7 +1028,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*|hg*|svn*) + git*|hg*|svn*|bzr*) sum="SKIP" ;; *) -- 1.7.11.4
--- doc/PKGBUILD.5.txt | 5 ++++- scripts/makepkg.sh.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 47f9e88..c0f96c2 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 `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*;; + revisionspec (see `bzr help revisionspec` for details) + *svn*;; revision diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dd4066b..3460824 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%%#*} # fall-through @@ -572,6 +572,57 @@ download_svn() { popd &>/dev/null } +download_bzr() { + local netfile=$1 + + local url=$(get_url "$netfile") + url=${url##*bzr+} + url=${url%%#*} + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + local revisionspec="-r-1" + local displaylocation="$url" + else + local revisionspec="-r$fragment" + local displaylocation="$url -r $fragment" + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Branching %s ...")" "${displaylocation}" + if ! bzr branch "$url" "$dir" $revisionspec --no-tree; then + error "$(gettext "Failure while branching %s")" "${displaylocation}" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Pulling %s ...")" "${displaylocation}" + cd_safe "$dir" + if ! bzr pull "$url" $revisionspec --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 + + cd_safe "${dir##*/}" + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -602,6 +653,9 @@ download_sources() { svn*) (( GET_VCS )) && download_svn "$netfile" ;; + bzr*) + (( GET_VCS )) && download_bzr "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -974,7 +1028,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*|hg*|svn*) + git*|hg*|svn*|bzr*) sum="SKIP" ;; *) -- 1.7.11.4
* For any vcs other that git, the fall through resulted in being handled by the code for std url, hence fragments were being left on. * Handle vcs urls than end in a slash correctly, eg http://example.com/project/ --- scripts/makepkg.sh.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3460824..7284c12 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -236,12 +236,14 @@ get_filename() { local proto=$(get_protocol "$netfile") case $proto in - git*|hg*|svn*|bzr*) - filename=${netfile##*/} - filename=${filename%%#*} - # fall-through - ;;& + hg*|svn*|bzr*) + filename=${netfile%%#*} + filename=${filename%/} + filename=${filename##*/} + ;; git*) + filename=${netfile%%#*} + filename=${filename##*/} filename=${filename%%.git*} ;; *) -- 1.7.11.4
On 13/08/12 17:27, Gary van der Merwe wrote:
* For any vcs other that git, the fall through resulted in being handled by the code for std url, hence fragments were being left on.
I have tried... but I can not parse that sentence. Can you give an example of what was wrong? The svn and hg urls I tried both removed the fragment.
* Handle vcs urls than end in a slash correctly, eg http://example.com/project/ --- scripts/makepkg.sh.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3460824..7284c12 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -236,12 +236,14 @@ get_filename() { local proto=$(get_protocol "$netfile")
case $proto in - git*|hg*|svn*|bzr*) - filename=${netfile##*/} - filename=${filename%%#*} - # fall-through - ;;& + hg*|svn*|bzr*) + filename=${netfile%%#*} + filename=${filename%/} + filename=${filename##*/} + ;; git*) + filename=${netfile%%#*} + filename=${filename##*/} filename=${filename%%.git*} ;; *)
On 13/08/2012 09:57, Allan McRae wrote:
On 13/08/12 17:27, Gary van der Merwe wrote:
* For any vcs other that git, the fall through resulted in being handled by the code for std url, hence fragments were being left on.
I have tried... but I can not parse that sentence. Can you give an example of what was wrong?
I think you understood me correctly. Let me try again: code for vcs url: git*|hg*|svn*) filename=${netfile##*/} filename=${filename%%#*} # fall-through ;;& code for std url: *) # if it is just an URL, we only keep the last component filename="${netfile##*/}" ;; If proto is hg*|svn*|bzr*, then the code for vcs url runs, but so does code for std url. Hence the fragment is striped in the code for vcs url, but the code for std url overwrites the value filename value, and the end result is the fragment is left on.
The svn and hg urls I tried both removed the fragment.
My experience was different. To double check myself, I have since created a minimal test case to check this. This is my test case and results: http://dpaste.com/hold/785819/ Thanks, Gary
On 14/08/12 06:42, Gary van der Merwe wrote:
On 13/08/2012 09:57, Allan McRae wrote:
On 13/08/12 17:27, Gary van der Merwe wrote:
* For any vcs other that git, the fall through resulted in being handled by the code for std url, hence fragments were being left on.
I have tried... but I can not parse that sentence. Can you give an example of what was wrong?
I think you understood me correctly. Let me try again:
code for vcs url:
git*|hg*|svn*) filename=${netfile##*/} filename=${filename%%#*} # fall-through ;;&
code for std url:
*) # if it is just an URL, we only keep the last component filename="${netfile##*/}" ;;
If proto is hg*|svn*|bzr*, then the code for vcs url runs, but so does code for std url.
Hence the fragment is striped in the code for vcs url, but the code for std url overwrites the value filename value, and the end result is the fragment is left on.
The svn and hg urls I tried both removed the fragment.
My experience was different. To double check myself, I have since created a minimal test case to check this. This is my test case and results: http://dpaste.com/hold/785819/
Ah... crap! My testcases all had the folder name specified before the url so I completely missed that.
From here it appears that git URLs can end in a "/" too, so that will need to be modified.
Can you resend the patch with that fixed based on current master (i.e. before your bzr patch)? Thanks, Allan
* For any vcs other that git, the fall through resulted in being handled by the code for std url, hence fragments were being left on. * Handle vcs urls than end in a slash correctly, eg http://example.com/project/ Signed-off-by: Gary van der Merwe <garyvdm@gmail.com> --- scripts/makepkg.sh.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dd4066b..31dbef6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -237,12 +237,12 @@ get_filename() { case $proto in git*|hg*|svn*) - filename=${netfile##*/} - filename=${filename%%#*} - # fall-through - ;;& - git*) - filename=${filename%%.git*} + filename=${netfile%%#*} + filename=${filename%/} + filename=${filename##*/} + if [[ $proto = git* ]]; then + filename=${filename%%.git*} + fi ;; *) # if it is just an URL, we only keep the last component -- 1.7.11.5
On 13/08/12 17:27, Gary van der Merwe wrote:
This patch adds Bazaar VCS support to makepkg.
Fragments can be any bzr revision spec. eg:
http://example.com/project/#revno:62
or just
http://example.com/project/#62
For more info, see `bzr help revisionspec`.
All the current VCS use the format url#<what>=<value>. From your patch, it seems that bzr has only one thing for "<what>", but we should stick to that syntax anyway - much like SVN that only supports revision. Maybe I should make the fragment syntax clearer in the man page. Anyway, reading document for bzr, would using: url#revision=revno:3:/path/to/branch be suitable? From what I can see "revision" is used to describe the parameter "e.g. --revision in bzr branch", so that should hopefully not be too confusing (and all confusion might be due to my lack of bzr knowledge).
Writing a pkgver func is easy with `bzr version-info`, eg:
pkgver() { cd $srcdir/$pkgname bzr version-info --custom --template="{revno}\n" }
--- doc/PKGBUILD.5.txt | 5 ++++- scripts/makepkg.sh.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 47f9e88..c0f96c2 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 `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*;; + revisionspec (see `bzr help revisionspec` for details) + *svn*;; revision
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dd4066b..3460824 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%%#*} # fall-through @@ -572,6 +572,57 @@ download_svn() { popd &>/dev/null }
+download_bzr() { + local netfile=$1 + + local url=$(get_url "$netfile") + url=${url##*bzr+} + url=${url%%#*} + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + local revisionspec="-r-1" + local displaylocation="$url" + else + local revisionspec="-r$fragment" + local displaylocation="$url -r $fragment" + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + if [[ ! -d "$dir" ]]; then
Add check if directory is there but empty - recent patch by Mohammad Alsaleh for git on this list.
+ msg2 "$(gettext "Branching %s ...")" "${displaylocation}" + if ! bzr branch "$url" "$dir" $revisionspec --no-tree; then
All other VCS functions do a full checkout here and do the checkout of the revision when creating the working branch. With that, you can get rid of the $displaylocation variable.
+ error "$(gettext "Failure while branching %s")" "${displaylocation}" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Pulling %s ...")" "${displaylocation}" + cd_safe "$dir"
is it possible to check that the contents of this directory are a bzr repo from the given url?
+ if ! bzr pull "$url" $revisionspec --overwrite; then
As mentioned above, do the revision checkout here.
+ # 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##*/}" + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")"
@@ -602,6 +653,9 @@ download_sources() { svn*) (( GET_VCS )) && download_svn "$netfile" ;; + bzr*) + (( GET_VCS )) && download_bzr "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -974,7 +1028,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")"
case $proto in - git*|hg*|svn*) + git*|hg*|svn*|bzr*) sum="SKIP" ;; *)
I'm really sorry about the delay replying to this. Some how, I did not see your reply till today. On Thu 16 Aug 2012 05:38:55 SAST, Allan McRae wrote:
All the current VCS use the format url#<what>=<value>. From your patch, it seems that bzr has only one thing for "<what>", but we should stick to that syntax anyway - much like SVN that only supports revision.
Maybe I should make the fragment syntax clearer in the man page.
Anyway, reading document for bzr, would using:
url#revision=revno:3:/path/to/branch
be suitable? From what I can see "revision" is used to describe the parameter "e.g. --revision in bzr branch", so that should hopefully not be too confusing (and all confusion might be due to my lack of bzr knowledge).
Ok, After reading PKGBUILD.5.txt again, I see the inconsistency. I've updated the patch so that the revisionspec fragment would be specified like this, so that is consistent with the others: url#revision=[any bzr revisionspec] url#revision=3 url#revision=tag:mytag
+ if [[ ! -d "$dir" ]]; then
Add check if directory is there but empty - recent patch by Mohammad Alsaleh for git on this list.
Done.
+ msg2 "$(gettext "Branching %s ...")" "${displaylocation}" + if ! bzr branch "$url" "$dir" $revisionspec --no-tree; then
All other VCS functions do a full checkout here and do the checkout of the revision when creating the working branch. With that, you can get rid of the $displaylocation variable.
That would not work for Bazaar. This is why: Unlike git/hg, bzr urls refer to a branch, not a repo. When you do a bzr branch/pull, it only fetches revisions that are descendants of the branch tip into the local repo. Hence, doing a branch/pull without specifying the fragment revision, it is possible that the fragment revision is not available. Here is an example revision dag for which this would happen: fragment revision = tag:mytag c (branch tip | b (tag:mytag |/ a
+ elif (( ! HOLDVER )); then + msg2 "$(gettext "Pulling %s ...")" "${displaylocation}" + cd_safe "$dir"
is it possible to check that the contents of this directory are a bzr repo from the given url?
Done. Signed-off-by: Gary van der Merwe <garyvdm@gmail.com> --- 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 `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##*#} + 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" $revisionspec --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" $revisionspec --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 + + cd_safe "${dir##*/}" + + 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" ;; *) -- 1.7.12
On 11/09/12 00:24, Gary van der Merwe wrote: <snip>
Signed-off-by: Gary van der Merwe <garyvdm@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" ;; *)
On Thu 13 Sep 2012 07:52:16 SAST, Allan McRae wrote:
Please change this (and throughout the patch) to keep protocols in alphabetical order.
Ah, I like beening first :-) Done
+ 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.
Done
+ local revision="-r-1"
Strings starting with a "-" can lead to issues... Changes this to: revision=('-r-1')
+ revision="-r${fragment##*=}"
revision=("-r${fragment##*=}")
Done
+ if ! bzr branch "$url" "$dir" $revisionspec --no-tree --use-existing-dir; then
+ if ! bzr pull "$url" $revisionspec --overwrite; then
I guess $revisionspec should be $revision? And with comment above it will be $(revision[@])
Gee. That was a big mistake that I made. Fixed. Signed-off-by: Gary van der Merwe <garyvdm@gmail.com> --- doc/PKGBUILD.5.txt | 5 +++- 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 47f9e88..0dca4a2 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 6de7b4f..971e2f4 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" ;; *) -- 1.7.12
participants (2)
-
Allan McRae
-
Gary van der Merwe