[pacman-dev] [PATCH] Add the ability to always build from the repo's HEAD
--- A task has also been added: https://bugs.archlinux.org/task/35499 scripts/makepkg.sh.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c27c74d..cd7ed48 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -557,6 +557,9 @@ download_git() { if ! git fetch --all -p; then # only warn on failure to allow offline builds warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + else + git fetch origin HEAD + echo "$(git rev-parse FETCH_HEAD)" > HEAD fi fi } @@ -597,6 +600,9 @@ extract_git() { branch) ref=origin/${fragment##*=} ;; + HEAD) + ref=HEAD + ;; *) error "$(gettext "Unrecognized reference: %s")" "${fragment}" plain "$(gettext "Aborting...")" @@ -604,6 +610,8 @@ extract_git() { esac fi + ref=$(git rev-parse "$ref") + if [[ -n $ref ]]; then if ! git checkout -b makepkg $ref; then error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" -- 1.8.2.3
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? You will need to explain what you are trying to do. Allan
scripts/makepkg.sh.in | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c27c74d..cd7ed48 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -557,6 +557,9 @@ download_git() { if ! git fetch --all -p; then # only warn on failure to allow offline builds warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + else + git fetch origin HEAD + echo "$(git rev-parse FETCH_HEAD)" > HEAD fi fi } @@ -597,6 +600,9 @@ extract_git() { branch) ref=origin/${fragment##*=} ;; + HEAD) + ref=HEAD + ;; *) error "$(gettext "Unrecognized reference: %s")" "${fragment}" plain "$(gettext "Aborting...")" @@ -604,6 +610,8 @@ extract_git() { esac fi
+ ref=$(git rev-parse "$ref") + if [[ -n $ref ]]; then if ! git checkout -b makepkg $ref; then error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? Noop, "branch=HEAD' won't work, git clone --mirror will set the 'HEAD' ref correctly, but next time, 'git fetch' won't.
You will need to explain what you are trying to do.
Allan
scripts/makepkg.sh.in | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c27c74d..cd7ed48 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -557,6 +557,9 @@ download_git() { if ! git fetch --all -p; then # only warn on failure to allow offline builds warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + else + git fetch origin HEAD + echo "$(git rev-parse FETCH_HEAD)" > HEAD In the case of fetching in an existed git source, we need to hack a bit to make sure the HEAD is correctly set. fi fi } @@ -597,6 +600,9 @@ extract_git() { branch) ref=origin/${fragment##*=} ;; + HEAD) + ref=HEAD + ;; None of 'branch=','commit=','tag=' works for HEAD correctly, we need to handle HEAD separately. *) error "$(gettext "Unrecognized reference: %s")" "${fragment}" plain "$(gettext "Aborting...")" @@ -604,6 +610,8 @@ extract_git() { esac fi
+ ref=$(git rev-parse "$ref") + Instead of use 'branch/*' something, it is always better to directly use commit hash. if [[ -n $ref ]]; then if ! git checkout -b makepkg $ref; then error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
On 28/05/13 14:29, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? Noop, "branch=HEAD' won't work, git clone --mirror will set the 'HEAD' ref correctly, but next time, 'git fetch' won't.
Does just specifying the URL not do what you want? e.g. source=('git://projects.archlinux.org/pacman.git') Allan
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 14:29, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? Noop, "branch=HEAD' won't work, git clone --mirror will set the 'HEAD' ref correctly, but next time, 'git fetch' won't.
Does just specifying the URL not do what you want? e.g.
source=('git://projects.archlinux.org/pacman.git')
Yes, you are right, there is no need to introduce a "HEAD" fragment, but the later hack for 'git fetch' is necessary, otherwise, the HEAD won't get update in a 'git fetch'.
Allan
On 28/05/13 15:07, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 14:29, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? Noop, "branch=HEAD' won't work, git clone --mirror will set the 'HEAD' ref correctly, but next time, 'git fetch' won't.
Does just specifying the URL not do what you want? e.g.
source=('git://projects.archlinux.org/pacman.git')
Yes, you are right, there is no need to introduce a "HEAD" fragment, but the later hack for 'git fetch' is necessary, otherwise, the HEAD won't get update in a 'git fetch'.
Explain to me as though I am incredibly stupid. Because I have no idea what is actually wrong. Everything updates fine here: allan@arya /var/abs/local/toolchain/glibc-git $ grep source PKGBUILD source=(git://sourceware.org/git/glibc.git allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ cat HEAD ref: refs/heads/master allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ git show-ref --head | grep refs/heads/master 5d5ef5dbfc5be7aec31e5d33d28b2e93dc4b8a8d refs/heads/master allan@arya /var/abs/local/toolchain/glibc-git $ makepkg ==> Making package: glibc 2.17_637_g8de398d-1 (Tue May 28 15:16:39 EST 2013) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... -> Updating glibc git repo... ... allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ git show-ref --head | grep refs/heads/master 528c24058fb100fb27fe5c211b92be84c67a6659 refs/heads/master
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 15:07, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 14:29, 郑文辉(Techlive Zheng) wrote:
2013/5/28 Allan McRae <allan@archlinux.org>:
On 28/05/13 02:08, Techlive Zheng wrote:
--- A task has also been added:
Am I missing something completely here? Does not specifying "ref=" etc in the URL build from HEAD? Noop, "branch=HEAD' won't work, git clone --mirror will set the 'HEAD' ref correctly, but next time, 'git fetch' won't.
Does just specifying the URL not do what you want? e.g.
source=('git://projects.archlinux.org/pacman.git')
Yes, you are right, there is no need to introduce a "HEAD" fragment, but the later hack for 'git fetch' is necessary, otherwise, the HEAD won't get update in a 'git fetch'.
Explain to me as though I am incredibly stupid. Because I have no idea what is actually wrong. Everything updates fine here:
allan@arya /var/abs/local/toolchain/glibc-git $ grep source PKGBUILD source=(git://sourceware.org/git/glibc.git
allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ cat HEAD ref: refs/heads/master
allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ git show-ref --head | grep refs/heads/master 5d5ef5dbfc5be7aec31e5d33d28b2e93dc4b8a8d refs/heads/master
allan@arya /var/abs/local/toolchain/glibc-git $ makepkg ==> Making package: glibc 2.17_637_g8de398d-1 (Tue May 28 15:16:39 EST 2013) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... -> Updating glibc git repo... ...
allan@arya /var/abs/local/toolchain/glibc-git/glibc (BARE:master) $ git show-ref --head | grep refs/heads/master 528c24058fb100fb27fe5c211b92be84c67a6659 refs/heads/master
Try this: 1. set the git source of your PKGBUILD to a local repo
$ grep source PKGBUILD source=(git+file:///path/to/some/local/repo)
2. check the local repo's HEAD
$ cd /path/to/some/local/repo $ git rev-parse HEAD 123456789 #say this is the current commit hash of the HEAD
3. run makepkg, and check the local abs copy of this repo
$ makepkg $ cd /path/to/the/local/copy/of/the/repo #this is directory does not exist until the makepkg, and created by makepkg by 'git clone --mirror' $ git rev-parse HEAD 123456789 # yes, same as the original HEAD, no problem now
4. change the HEAD of the original repo
$ cd /path/to/some/local/repo $ git co HEAD~ $ git rev-parse HEAD 987654321 #not he commit hash of the HEAD has been changed
5. run makepkg again, and check again the local abs copy of the repo
$ makepkg $ cd /path/to/the/local/copy/of/the/repo #this is directory is preserved since last makepkg, and updated by makepkg using 'git fetch --all' $ git rev-parse HEAD 123456789 # noop, the commit HASH of the HEAD is still the old one, not updated
This is a hack to make sure 'git fetch' inside an existing repository still gets its HEAD tracking remote's HEAD. --- scripts/makepkg.sh.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c27c74d..30288db 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -557,6 +557,9 @@ download_git() { if ! git fetch --all -p; then # only warn on failure to allow offline builds warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + else + git fetch origin HEAD + echo "$(git rev-parse FETCH_HEAD)" > HEAD fi fi } -- 1.8.3
participants (3)
-
Allan McRae
-
Techlive Zheng
-
郑文辉(Techlive Zheng)