Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 493308 - =net-analyzer/mtr-9999 - mtr reports malformed version number due to being mangled in ebuild
Summary: =net-analyzer/mtr-9999 - mtr reports malformed version number due to being ma...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-04 12:22 UTC by James Taylor
Modified: 2013-12-05 12:14 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Modified net-analyzer/mtr-9999 ebuild with suggested sed line (file_493308.txt,2.05 KB, text/plain)
2013-12-05 07:17 UTC, James Taylor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Taylor 2013-12-04 12:22:31 UTC
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"
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2013-12-04 14:18:27 UTC
(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?
Comment 2 Matt Nordhoff 2013-12-04 15:42:13 UTC
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.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2013-12-04 15:58:10 UTC
(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
Comment 4 Matt Nordhoff 2013-12-04 17:02:57 UTC
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!?)
Comment 5 Matt Nordhoff 2013-12-04 19:30:45 UTC
Or, playing code golf:

	sed -e "/^\s*xver=/s/$.*)/${EGIT_VERSION}/" Makefile.am
Comment 6 Matt Nordhoff 2013-12-04 23:44:05 UTC
	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.
Comment 7 James Taylor 2013-12-05 07:17:19 UTC
Created attachment 364640 [details]
Modified net-analyzer/mtr-9999 ebuild with suggested sed line
Comment 8 James Taylor 2013-12-05 07:20:17 UTC
(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
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2013-12-05 12:14:36 UTC
(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. :)