[aur-general] PKGBUILD-git that actually works with branches
Hi there. According to http://www.archlinux.org/pacman/PKGBUILD.5.html PKGBUILD-git.proto should work with git branches, but it doesn't. I did have quite some trouble to get it to work as expected, but eventually it was scj7t4 on IRC who wrote a working script for me. I'd really love to spare other packagers that trouble and would like to get the improved script into PKGBUILD-git.proto. I merged it with the original PKGBUILD-git.proto and hope it's fine this way, but please feel free to make any changes necessary. http://pastebin.com/deqgqjJe -- Regards, Philipp ----- "Wir stehen selbst enttäuscht und sehn betroffen / Den Vorhang zu und alle Fragen offen." Bertolt Brecht, Der gute Mensch von Sezuan
Excerpts from Philipp's message of 2010-05-28 11:24:52 -0400:
I merged it with the original PKGBUILD-git.proto and hope it's fine this way, but please feel free to make any changes necessary.
You should probably submit the changes as a patch to what is currently in abs[1], with some comments saying what the changes are and maybe why they improve the PKGBUILD prototype. That said, I don't know if this mailing list is the right place for submitting abs patches. [1]: http://projects.archlinux.org/abs.git/ -- David Campbell
Excerpts from David Campbell's message of 2010-05-28 20:03:29 +0200:
Excerpts from Philipp's message of 2010-05-28 11:24:52 -0400:
I merged it with the original PKGBUILD-git.proto and hope it's fine this way, but please feel free to make any changes necessary.
You should probably submit the changes as a patch to what is currently in abs[1], with some comments saying what the changes are and maybe why they improve the PKGBUILD prototype. That said, I don't know if this mailing list is the right place for submitting abs patches.
I thought this list is appropriate because it's mostly useful to AUR packagers. I frequently package -git versions, most of the time though the master branch is what I'm after, and for that the normal PKGBUILD-git.proto works fine. That's why I defaulted to "master", but I get the following error: fatal: git checkout: branch master already exists It works, but I need some input on whether and how the default case can be handled more gracefully. -- Regards, Philipp ----- "Wir stehen selbst enttäuscht und sehn betroffen / Den Vorhang zu und alle Fragen offen." Bertolt Brecht, Der gute Mensch von Sezuan
On 2010-05-28 at 19:38 +0200, Philipp Überbacher wrote:
That's why I defaulted to "master", but I get the following error: fatal: git checkout: branch master already exists
It works, but I need some input on whether and how the default case can be handled more gracefully.
There isn't really a need to create a new branch if you just want to do a checkout. Simply change git checkout --track -b ${_gitbranch} origin/${_gitbranch} in http://pastebin.com/deqgqjJe to git checkout origin/${_gitbranch} See the amendment of the paste at http://pastebin.com/C8sC7wAe
Excerpts from Sebastian Schwarz's message of 2010-05-28 20:49:31 +0200:
On 2010-05-28 at 19:38 +0200, Philipp Überbacher wrote:
That's why I defaulted to "master", but I get the following error: fatal: git checkout: branch master already exists
It works, but I need some input on whether and how the default case can be handled more gracefully.
There isn't really a need to create a new branch if you just want to do a checkout. Simply change
git checkout --track -b ${_gitbranch} origin/${_gitbranch}
in http://pastebin.com/deqgqjJe to
git checkout origin/${_gitbranch}
See the amendment of the paste at http://pastebin.com/C8sC7wAe
Thanks Sebastian, I guess it makes sense, but I get a new message from git: Note: checking out 'origin/master'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 0cb24fc... add some text to README .. -- Regards, Philipp ----- "Wir stehen selbst enttäuscht und sehn betroffen / Den Vorhang zu und alle Fragen offen." Bertolt Brecht, Der gute Mensch von Sezuan
On 2010-05-28 at 21:39 +0200, Philipp Überbacher wrote:
Thanks Sebastian, I guess it makes sense, but I get a new message from git:
(...)
Ah, I forgot about this. To suppress this notice just tell git-checkout to be `--quiet`.
On May 28, 2010, at 1:18 PM, Sebastian Schwarz wrote:
Ah, I forgot about this. To suppress this notice just tell git-checkout to be `--quiet`.
Is there a reason not to just use 'git checkout "$_gitbranch"' instead ? -Justin
On 2010-05-28 at 13:24 -0700, Justin Davis wrote:
Is there a reason not to just use 'git checkout "$_gitbranch"' instead?
By default git-clone only creates a remote tracking branch for master or whichever branch is specified with the `-b` option. Thus you either have to checkout the branch from the remote, which defaults to "origin", or tell git to setup with the desired branch right from the beginning using: git clone -b "$_gitbranch" "$_gitname" "$_gitroot" Then additional checkout of $_gitbranch isn't needed.
On May 28, 2010, at 1:52 PM, Sebastian Schwarz wrote:
By default git-clone only creates a remote tracking branch for master or whichever branch is specified with the `-b` option. Thus you either have to checkout the branch from the remote,
I am no git wiz but it seems like you are making things more complicated than they have to be. When you type 'git checkout <branchname>' it automatically creates a remote tracking branch. I can see no good reason to checkout the remote branch (the one prefixed with origin/) and force it to suppress its warning when you can just checkout a branch normally. Your response was informative but did not tell me why you choose a more complicated route, instead of the straightforward 'git checkout <branchname>'. -Justin
On 2010-05-28 at 15:31 -0700, Justin Davis wrote:
I am no git wiz but it seems like you are making things more complicated than they have to be. When you type 'git checkout <branchname>' it automatically creates a remote tracking branch.
Well, I wasn't aware of the fact that git does this for you automatically. This indeed simplifies things a bit.
On 29/05/10 04:49, Sebastian Schwarz wrote:
On 2010-05-28 at 19:38 +0200, Philipp Überbacher wrote:
That's why I defaulted to "master", but I get the following error: fatal: git checkout: branch master already exists
It works, but I need some input on whether and how the default case can be handled more gracefully.
There isn't really a need to create a new branch if you just want to do a checkout. Simply change
git checkout --track -b ${_gitbranch} origin/${_gitbranch}
in http://pastebin.com/deqgqjJe to
git checkout origin/${_gitbranch}
See the amendment of the paste at http://pastebin.com/C8sC7wAe
I have been using this for my makepkg-git package for ages: if [ -d $_gitname ] ; then cd $_gitname && git pull origin working msg "The local files are updated." else git clone $_gitroot cd $_gitname && git checkout origin/working fi Seems to work... Allan
Excerpts from Allan McRae's message of 2010-05-29 00:41:24 +0200:
On 29/05/10 04:49, Sebastian Schwarz wrote:
On 2010-05-28 at 19:38 +0200, Philipp Überbacher wrote:
That's why I defaulted to "master", but I get the following error: fatal: git checkout: branch master already exists
It works, but I need some input on whether and how the default case can be handled more gracefully.
There isn't really a need to create a new branch if you just want to do a checkout. Simply change
git checkout --track -b ${_gitbranch} origin/${_gitbranch}
in http://pastebin.com/deqgqjJe to
git checkout origin/${_gitbranch}
See the amendment of the paste at http://pastebin.com/C8sC7wAe
I have been using this for my makepkg-git package for ages:
if [ -d $_gitname ] ; then cd $_gitname && git pull origin working msg "The local files are updated." else git clone $_gitroot cd $_gitname && git checkout origin/working fi
Seems to work...
Allan
This doesn't simply allow you to switch between branches. The current PKGBUILD-git.proto clones once and then works on a copy. I try to keep this behavior. However, I just ran into a potential problem when switching between branches: cp: cannot create regular file `/home/murks/build/mine/pyjacksm-git/src/pyjacksm-build/pyjacksm/.git/objects/pack/pack-17d65751e48b8cabe9a720cabff133d636077bd7.idx': Permission denied cp: cannot create regular file `/home/murks/build/mine/pyjacksm-git/src/pyjacksm-build/pyjacksm/.git/objects/pack/pack-17d65751e48b8cabe9a720cabff133d636077bd7.pack': Permission denied The PKGBUILD I test this on currently looks like this: # Maintainer: Philipp Überbacher <murks at lavabit dot com> pkgname=pyjacksm-git pkgver=20100529 pkgrel=1 pkgdesc="A simple manager for jack-session" arch=('any') url="http://trac.jackaudio.org/wiki/WalkThrough/User/jack_session" license=('GPL') depends=('python') makedepends=('git') provides=('pyjacksm') _gitroot="git://hochstrom.endofinternet.org/pyjacksm.git" _gitname="pyjacksm" _gitbranch="master" #bpjack build() { cd "${srcdir}" msg "Connecting to GIT server...." if [ -d $_gitname ] ; then cd $_gitname && git pull origin msg "The local files are updated." else git clone $_gitroot $_gitname fi msg "GIT checkout done or server timeout" msg "Starting make..." cp -r "$srcdir/$_gitname" "$srcdir/$_gitname-build" cd "$srcdir/$_gitname-build" #^ Creates a copy that still has remote branches available! git checkout ${_gitbranch} # # BUILD HERE # python setup.py install --root=$pkgdir/ --optimize=1 || return 1 } -- Regards, Philipp ----- "Wir stehen selbst enttäuscht und sehn betroffen / Den Vorhang zu und alle Fragen offen." Bertolt Brecht, Der gute Mensch von Sezuan
participants (6)
-
Allan McRae
-
David Campbell
-
Justin Davis
-
Philipp
-
Philipp Überbacher
-
Sebastian Schwarz