Portage patches the version number in configure.ac to be the git hash instead of the original version (in this case 0.85), which results in an obscure and long version number. Another issue appears to be that the HEAD object in the git repo isn't initialised correctly, leaving the string after "+git:" empty, which would usually contain the short git hash. Reproducible: Always Steps to Reproduce: 1. root@server ~ # emerge mtr (assuming =net-analyzer/mtr-9999 ** is in package.accept_keywords or similar) 2. root@server ~ # mtr -v Actual Results: mtr reports a version of "mtr 99dbe3f1146be11452309291606d327fe099f892+git:" Expected Results: mtr should report a version with the format of "mtr 0.85+git:99dbe3f1"
(In reply to James from comment #0) > Portage patches the version number in configure.ac to be the git hash > instead of the original version (in this case 0.85), which results in an > obscure and long version number. Without the sed script we get: # mtr --version 0.85+git: Is that preferable? I can simply remove the sed script. > Another issue appears to be that the HEAD object in the git repo isn't > initialised correctly, leaving the string after "+git:" empty, which would > usually contain the short git hash. Isn't that precisely the same issue, obsoleting the sed script? > 2. root@server ~ # mtr -v > Actual Results: > mtr reports a version of "mtr 99dbe3f1146be11452309291606d327fe099f892+git:" > Expected Results: > mtr should report a version with the format of "mtr 0.85+git:99dbe3f1" So it comes down to this. We remove the sed script and then, how do we do this?
From the point of view of an outsider who doesn't know how package building really works, I see two obvious simple options: 1.) Fix it so HEAD gets set properly. Remove the sed thing. 2.) Instead of sed'ing configure.ac, sed Makefile.am with something like this: sed -e "/^\s*xver=/s/HEAD/${EGIT_VERSION}/" Makefile.am || die This way, the git revision is passed directly to it, so "HEAD" doesn't need to exist.
(In reply to Matt Nordhoff from comment #2) > From the point of view of an outsider who doesn't know how package building > really works, I see two obvious simple options: > > 1.) Fix it so HEAD gets set properly. Remove the sed thing. I did that already. Now --version outputs "mtr 0.85+git:" > 2.) Instead of sed'ing configure.ac, sed Makefile.am with something like > this: > > sed -e "/^\s*xver=/s/HEAD/${EGIT_VERSION}/" Makefile.am || die Using ..: sed -i -e "/^\s*xver=/s/HEAD/${EGIT_VERSION}/" Makefile.am || die .. I see no useful change at all and git still says: fatal: bad object 99dbe3f1146be11452309291606d327fe099f892
It does? Oh. I'm sorry. What the heck is wrong with git, then? Why doesn't it work? How about change the xver to just be 'xver="+git:${EGIT_VERSION}"' (or a truncated version thereof) and not run git at all? Something like... sed -e "/^\s*xver=/s/\"[^\"]*\"/\"+git:${EGIT_VERSION}\"/" Makefile.am || die That would use the full, untruncated hash, which is kind of yucky, but I don't know what the most convenient way to truncate it would be. (Two seds!?)
Or, playing code golf: sed -e "/^\s*xver=/s/$.*)/${EGIT_VERSION}/" Makefile.am
sed -e "/^\s*xver=/s/$.*)/${EGIT_VERSION:0:8}/" Makefile.am || die ^ just the first 8 characters of the hash. I'll stop fooling around now.
Created attachment 364640 [details] Modified net-analyzer/mtr-9999 ebuild with suggested sed line
(In reply to Matt Nordhoff from comment #6) > sed -e "/^\s*xver=/s/$.*)/${EGIT_VERSION:0:8}/" Makefile.am || die > > ^ just the first 8 characters of the hash. I'll stop fooling around now. That works, and now mtr presents a version with the expected format root@server ~ # mtr -v mtr 0.85+git:99dbe3f1 One minor alteration was the addition of the -i flag to actually perform the sed on the file, and not uselessly print to the screen. sed -i -e "/^\s*xver=/s/$.*)/${EGIT_VERSION:0:8}/" Makefile.am || die
(In reply to James Taylor from comment #7) > Created attachment 364640 [details] > Modified net-analyzer/mtr-9999 ebuild with suggested sed line Applied. Now let's see when that breaks. :)