Arch Linux package: version string to use and how to access?

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report. For problems building from source, post in Compile.

Moderators: Oberlus, Oberlus

Post Reply
Message
Author
Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Arch Linux package: version string to use and how to access?

#1 Post by Chriss » Thu Jul 23, 2015 8:41 pm

I'm currently updating the Arch package to use the Git repo, and making some arch specific transitions along the way. Arch has an automatic version bump for VCS Packages, eg SVN, Git and the like. For SVN, it simply uses the revision. For Git, there are several possibilities. The relevant wiki section is here: https://wiki.archlinux.org/index.php/VC ... 9_function

The first thing they mention would be:

Code: Select all

git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
v0.4.3.r2632.g092c700
Which I don't think is current...

Another Possibility:

Code: Select all

printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
r8778.092c700
Which looks better. Both is not what is used ingame.

So my question would be: should / can I use the mechanism which cmake uses at build time? If yes, how? If no, ideas for an alternative? Otherwise I'd tend to use the second alternative here, simply to have something and in the hopes that the first number is growing continuously...
Attached patches are released under GPL 2.0 or later.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Arch Linux package: version string to use and how to acc

#2 Post by Dilvish » Fri Jul 24, 2015 7:13 am

Chriss wrote:So my question would be: should / can I use the mechanism which cmake uses at build time? If yes, how?
I think the answer to the first question is yes, at least to the extent reasonably possible for you. cmake uses the python file in cmake/make_version.cpp.py (together with a little template info in util/Version.cpp.in). You'll have already run cmake when you do this part of your packaging process, right? So instead of the

Code: Select all

git blah | sed blah
you could just

Code: Select all

cat util/Version.cpp | sed new_blah
, so long as your sed-fu is up to it. Or, couldn't you just run a python file instead of executing git, and use the output from that, not evening needing to put it through sed. Just a small bit of adaptation of our normal make_version.cpp.py file should be fine for it to print out the version string you need, I would think.

Caveat: I have no real expertise in this particular area :D
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Re: Arch Linux package: version string to use and how to acc

#3 Post by Chriss » Fri Jul 24, 2015 2:39 pm

No, the according pkgver() function is called directly after the sources are downloaded, before patches are applied, and before cmake and make is run in the build step. But it's a bash function - I can pretty much do everything bash let's me do, so I can in theory run cmake or a python script. Preference on a python script I think.

But the current version string is nothing that I think should be used as a "package manager" version string... ideally it's some monotonic number, at least in parts. Arch has a semantic of <release version>r<monotonic number> which may fit here. I'm just not that deep in the git development prodecure to know what to use.

The "what version number to use" question is probably not specific to arch...
Attached patches are released under GPL 2.0 or later.

User avatar
Vezzra
Release Manager, Design
Posts: 5002
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Arch Linux package: version string to use and how to acc

#4 Post by Vezzra » Fri Jul 24, 2015 3:09 pm

Chriss wrote:The "what version number to use" question is probably not specific to arch...
Yep, quite right. I've replied to that in another thread that IMO fits better, please continue the discussion there...

User avatar
Vezzra
Release Manager, Design
Posts: 5002
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Arch Linux package: version string to use and how to acc

#5 Post by Vezzra » Sun Jul 26, 2015 4:52 pm

Chriss wrote:No, the according pkgver() function is called directly after the sources are downloaded, before patches are applied, and before cmake and make is run in the build step. But it's a bash function - I can pretty much do everything bash let's me do, so I can in theory run cmake or a python script. Preference on a python script I think.
Well, it doesn't look like the build number discussion will be wrapped up within the next few hours, and fumbling around with that after creation of the release branch... I don't know. Currently I'd prefer to do that after the 0.4.5 release.

So, if you want to build the build number composition logic into a bash/Python script, here are the relevant lines from our make_versioncpp.py script which construct the build number:

Code: Select all

    commit = check_output(["git", "show", "-s", "--format=%h", "HEAD"]).strip()
    timestamp = float(check_output(["git", "show", "-s", "--format=%ct", "HEAD"]).strip())
    build_no = ".".join([datetime.utcfromtimestamp(timestamp).strftime("%Y-%m-%d"), commit])
Basically, the timestamp of the commit gets fetched, converted into UTC timezone and after that into a string of the format "YYYY-MM-DD", where YYYY is the four digit year number, and MM and DD the two digit month and day numbers of that timestamp. That string is suffixed with "." and the commit hash as returned by:

Code: Select all

git show -s --format=%h HEAD
HTH :D

Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Re: Arch Linux package: version string to use and how to acc

#6 Post by Chriss » Sun Aug 02, 2015 8:31 am

Thanks. I decided to go with this for now:

Code: Select all

#/bin/python

from subprocess import check_output
from datetime import datetime

commit = check_output(["git", "show", "-s", "--format=%h", "HEAD"]).strip().decode("utf-8")
#timestamp = float(check_output(["git", "show", "-s", "--format=%ct", "HEAD"]).strip())
numCommits = check_output(["git", "rev-list", "--count", "HEAD"]).strip().decode("utf-8")

#print(commit)
#print(timestamp)
#print(datetime.utcfromtimestamp(timestamp).strftime("%Y-%m-%d"))
#print(numCommits)

print("r%s.%s"%(numCommits, commit))
Which yields "r8778.092c700". For now, that is also the closest to the number currently in use.
Attached patches are released under GPL 2.0 or later.

Post Reply