You are not logged in.

#1 2013-05-22 03:21:06

pivotraze
Member
From: Missoula, MT
Registered: 2011-08-21
Posts: 111

Appending the git commit # to the actual version number?

For the program, is it possible to just append the git version number to the actual version number?

For example, the current version number of my program is 0.9.2. The git commit number f2b19c0752. I would like the version number to be something like 0.9.2.f2b19c0752 in the PKGBUILD.

Also, why is PKGBUILD pkgver come out as pkgver=6620271 when the last commit was 36d9ff82ec?

Thanks in advance

Last edited by pivotraze (2013-05-22 03:23:53)

Offline

#2 2013-05-22 03:24:04

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Appending the git commit # to the actual version number?

As long as your project has tagged version numbers:

pkgver() {
  cd "$_gitname"
  echo $(git describe --tags).$(git rev-parse --short master)
}

Scott

Offline

#3 2013-05-22 03:33:28

pivotraze
Member
From: Missoula, MT
Registered: 2011-08-21
Posts: 111

Re: Appending the git commit # to the actual version number?

For some reason, I get this:

==> Updated version: wifiz 0.9.2-2-g833fd3f.-1
==> ERROR: pkgver is not allowed to contain colons, hyphens or whitespace.

The PKGBUILD:

# Maintainer: Cody Dostal <dostalcody@gmail.com>

pkgname=wifiz
_gitname=WiFiz
pkgver=0.9.1.2-8-g833fd3f.31403fc
pkgrel=1
pkgdesc="NetCTL GUI Frontend, written in wxPython. Stable Version."
arch=('any')
url="https://github.com/codywd/WiFiz"
license=('MIT')
depends=('python2' 'wxpython' 'wireless_tools' 'netctl' 
'wpa_supplicant')
makedepends=('git')
conflicts=('wifiz-nightly')
provides=('wifiz')
source=('git://github.com/codywd/WiFiz.git#branch=develop')
# Because the sources are not static, skip Git checksum:
md5sums=('SKIP')

pkgver() {
  cd "$_gitname"
  echo $(git describe --tags).$(git rev-parse --short master)
}

package() {
  cd $srcdir/$_gitname
  pwd
  python2 setup.py install --root="$pkgdir/" --optimize=1
}

What causes the hyphens?

Last edited by pivotraze (2013-05-22 03:47:24)

Offline

#4 2013-05-22 03:51:28

proudzhu
Member
Registered: 2012-09-13
Posts: 17

Re: Appending the git commit # to the actual version number?

Hyphens is not allowed in pkgver, so "0.9.1.2-8-g833fd3f.31403fc" could not be used.
You can just find where the hyphens come from, and add

sed 's|-|.|g'

to use dots instead of hyphens

Offline

#5 2013-05-22 03:56:59

pivotraze
Member
From: Missoula, MT
Registered: 2011-08-21
Posts: 111

Re: Appending the git commit # to the actual version number?

Here is the actual code I had to use:

pkgver() {
  cd "$_gitname"
  echo $(git describe --tags).$(git rev-parse --short develop) |
sed 's|-|.|g'
}

Thank you!

However, is there any way to remove the extraneous .s?

Like, here is the package name: wifiz-0.9.2.3.g2d3e0a8.-1-any.pkg.tar.xz
I would like it to be something like: "wifiz-0.9.2.g2d3e0a8-1-any.pkg.tar.xz" preferably, but "wifiz-0.9.2.3.g2d3e0a8-1-any.pkg.tar.xz" would be fine.

Last edited by pivotraze (2013-05-22 03:59:04)

Offline

#6 2013-05-22 09:34:13

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,126

Re: Appending the git commit # to the actual version number?

first off, git describe already includes the short hash of the commit, get rid of git rev-parse. echo $(git describe --long | sed 's/-/./g') is really all you need.
second, you don't really want what you say you want. "wifiz-0.9.2.g2d3e0a8-1-any.pkg.tar.xz" will not give you a linear versioning. The next commit could give you "wifiz-0.9.2.g19ab453-1-any.pkg.tar.xz", which would then be interpreted as a downgrade because the version number is less than the previous one. Having the count of commits in there is important to advance the version on each update.

Offline

#7 2013-05-22 16:43:06

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Appending the git commit # to the actual version number?

Scimmia wrote:

first off, git describe already includes the short hash of the commit, get rid of git rev-parse. echo $(git describe --long | sed 's/-/./g') is really all you need.
second, you don't really want what you say you want. "wifiz-0.9.2.g2d3e0a8-1-any.pkg.tar.xz" will not give you a linear versioning. The next commit could give you "wifiz-0.9.2.g19ab453-1-any.pkg.tar.xz", which would then be interpreted as a downgrade because the version number is less than the previous one. Having the count of commits in there is important to advance the version on each update.

Ahh, thanks for that...now I understand the rationale behind the wiki entry! So obvious in hindsight....

Scott

Offline

#8 2013-05-23 00:24:32

pivotraze
Member
From: Missoula, MT
Registered: 2011-08-21
Posts: 111

Re: Appending the git commit # to the actual version number?

That seems to work better. It produces wifiz-0.9.2.8.gc38cae9-1-any.pkg.tar.xz which is more akin to what i wanted smile Thanks.

This is the final code for PKGBUILD:

# Maintainer: Cody Dostal <dostalcody@gmail.com>

pkgname=wifiz
_gitname=WiFiz
pkgver=0.9.2.8.gc38cae9
pkgrel=2
pkgdesc="NetCTL GUI Frontend, written in wxPython. Stable Version."
arch=('any')
url="https://github.com/codywd/WiFiz"
license=('MIT')
depends=('python2' 'wxpython' 'wireless_tools' 'netctl' 
'wpa_supplicant')
makedepends=('git')
optdepends=('gedit: Manually editing profiles.')
conflicts=('wifiz-nightly')
provides=('wifiz')
source=('git://github.com/codywd/WiFiz.git#branch=develop')
# Because the sources are not static, skip Git checksum:
md5sums=('SKIP')

pkgver() {
  cd "$_gitname"
  echo $(git describe --long | sed 's/-/./g')
}

package() {
  cd $srcdir/$_gitname
  pwd
  python2 setup.py install --root="$pkgdir/" --optimize=1
}

Offline

#9 2013-05-23 05:12:49

Jristz
Member
From: America/Santiago
Registered: 2011-06-11
Posts: 924

Re: Appending the git commit # to the actual version number?

proudzhu wrote:

Hyphens is not allowed in pkgver, so "0.9.1.2-8-g833fd3f.31403fc" could not be used.
You can just find where the hyphens come from, and add

sed 's|-|.|g'

to use dots instead of hyphens

bad idea
1.2.1 is greater tha 1.2.0 right?
but whit this a 2.0-299 become 2.0.299 and a 2.0.1-299 become 2.0.1.299
who is bigger, 2.0.299 or 2.0.1.299? vercmp say the first

I actually use

sed 's|-|.git|g'

and for now work as expeted making 2.0.git299 lower than 2.0.1.git299

and not sure what is the oppinion of dev about .r vs .git por git versions like that because for me adding .git mean git and .r is release like any common upstream release

Last edited by Jristz (2013-05-23 05:15:25)


Well, I suppose that this is somekind of signature, no?

Offline

#10 2013-05-23 11:14:11

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,199
Website

Re: Appending the git commit # to the actual version number?

I'm not sure I get all this, but doesn't `git rev-list --count HEAD` provide the propper sequential commit number?

In my git PKGBUILDS I use the following:

pkgver() {
	cd "${_gitname}";
	echo "2.$(git rev-list --count HEAD).$(git describe --always )"
}

Where the initial "2." can be any version prefix.  In this case, this is a development version of the second major version and it provides sequential minor version numbers followed by non-sequential minor-minor version numbers, but this is fine as every change increments the minor version:
2.223.<hash>
2.224.<hash>
2.225.<hash>
...


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#11 2013-05-23 11:21:15

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,126

Re: Appending the git commit # to the actual version number?

Trilby wrote:

I'm not sure I get all this, but doesn't `git rev-list --count HEAD` provide the propper sequential commit number?

In my git PKGBUILDS I use the following:

pkgver() {
	cd "${_gitname}";
	echo "2.$(git rev-list --count HEAD).$(git describe --always )"
}

Where the initial "2." can be any version prefix.  In this case, this is a development version of the second major version and it provides sequential minor version numbers followed by non-sequential minor-minor version numbers, but this is fine as every change increments the minor version:
2.223.<hash>
2.224.<hash>
2.225.<hash>
...

Yes it does, but "git describe" already includes a count, so "git rev-list --count" isn't needed here.

Offline

#12 2013-05-23 11:28:57

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,126

Re: Appending the git commit # to the actual version number?

Jristz wrote:
proudzhu wrote:

Hyphens is not allowed in pkgver, so "0.9.1.2-8-g833fd3f.31403fc" could not be used.
You can just find where the hyphens come from, and add

sed 's|-|.|g'

to use dots instead of hyphens

bad idea
1.2.1 is greater tha 1.2.0 right?
but whit this a 2.0-299 become 2.0.299 and a 2.0.1-299 become 2.0.1.299
who is bigger, 2.0.299 or 2.0.1.299? vercmp say the first

I actually use

sed 's|-|.git|g'

and for now work as expeted making 2.0.git299 lower than 2.0.1.git299

and not sure what is the oppinion of dev about .r vs .git por git versions like that because for me adding .git mean git and .r is release like any common upstream release

Also a bad idea (or at least not really ideal), you'd actually end up with end up with  2.0.1.git299.gitg833fd3f. KaiSforza, who's been doing a lot of work on pacman, proposes this: https://wiki.archlinux.org/index.php/Ta … .28.29.27s. It adds "r" after the first occurrence of "-" only. Personally, I would use awk if there was a chance you'd run into this situation. git describe --long | awk -F - '{print $1 ".r" $2 "." $3}'

Offline

#13 2013-05-23 11:45:38

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,199
Website

Re: Appending the git commit # to the actual version number?

git describe only seems to work with tags - I've never used tags, so git describe returns nothing unless I add the 'always' flag, then there is just a non-sequential hash.

Last edited by Trilby (2013-05-23 11:46:46)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#14 2013-05-23 12:16:25

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,126

Re: Appending the git commit # to the actual version number?

Right. This thread is about a repo that uses tags, though, so again, git rev-list isn't relevant here.

Offline

#15 2013-05-23 12:42:12

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,199
Website

Re: Appending the git commit # to the actual version number?

Sorry, I didn't mean to go OT, I thought this was more of a general discussion about pkgver functions for git PKGBUILDS.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

Board footer

Powered by FluxBB