You are not logged in.

#1 2014-07-17 08:30:33

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

[solved] How to source a specific commit in a Git package?

Hi there,

I wonder whether it is possible to use a certain Git commit in the source array of a package.

Example:

freshplayerplugin-git

For debugging purposes I would like to use the commit

8ff0bd0282205802c482c7d47f216feb0d3394a9

I tried the following in the source array and it successfully built the package:

source=('git://github.com/i-rinat/freshplayerplugin.git#commit=8ff0bd0282205802c482c7d47f216feb0d3394a9')

However, I have no idea how to detect whether it actually built from the specific commit or just skipped the #commit appending.

Does anyone know how to source a specific commit?

Thanks ahead!

Last edited by orschiro (2014-07-17 11:21:17)

Offline

#2 2014-07-17 09:11:08

mkoskar
Member
Registered: 2014-07-16
Posts: 64
Website

Re: [solved] How to source a specific commit in a Git package?

Correct syntax for Git repository as a source would be:

source=('git+https://<repo-url>#[commit|tag|branch]=<ref>')

To verify it's building correct tree, and moreover to keep sane when dealing with multiple trees I like following pkgver (check https://wiki.archlinux.org/index.php/VC … Guidelines):

pkgver() {
    cd "$srcdir/<repo-name>"
    printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

producing something like:

<package-name-git>-r4.34e558d-1-any.pkg.tar.xz

Also just going to fetched Git tree and checking out what's there is an option (look for makepkg branch), for example:

$ git show-ref
34e558d2ef8b2cae212da3ab3f74513a99f9ee1b refs/heads/makepkg
86350ab5a3a209de4339ef04d75d27c7bd399746 refs/heads/master
86350ab5a3a209de4339ef04d75d27c7bd399746 refs/remotes/origin/HEAD
86350ab5a3a209de4339ef04d75d27c7bd399746 refs/remotes/origin/master

Last edited by mkoskar (2014-07-17 09:13:11)

Offline

#3 2014-07-17 09:11:37

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [solved] How to source a specific commit in a Git package?

One way would be to do

git checkout

in the build function.

Offline

#4 2014-07-17 11:21:04

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] How to source a specific commit in a Git package?

@mkoskar

Great solution. Thank you for providing the correct URL syntax and also ways of checking the current built version.

Offline

#5 2014-11-09 21:21:05

bartonc
Member
From: Minden, Nevada, USA
Registered: 2012-02-27
Posts: 25

Re: [solved] How to source a specific commit in a Git package?

Since we're talking about git tags and PKGBUILD pkgver functions, excelent examples are listed in the wiki.
For example

Using the most recent un-annotated tag reachable from the last commit:

pkgver() {
  cd "$pkgname"
  git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
}

I guess that I'll need to pick up a little sed, now.

UPDATE: Since the linked wiki page has a note about out of date prototypes, here is the Manjaro wiki with excelent git prototype.

Last edited by bartonc (2014-11-10 04:01:22)

Offline

Board footer

Powered by FluxBB