Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 433964 - [PATCH] AgeSet and DateSet should use BUILD_TIME instead of COUNTER filestamp
Summary: [PATCH] AgeSet and DateSet should use BUILD_TIME instead of COUNTER filestamp
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 210077
  Show dependency tree
 
Reported: 2012-09-04 20:15 UTC by Martin Väth
Modified: 2012-09-08 23:49 UTC (History)
0 users

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


Attachments
Make AgeSet and DateSet use BUILD_TIME key instead of COUNTER mtime (build_time.patch,1.91 KB, text/plain)
2012-09-04 20:15 UTC, Martin Väth
Details
Fix previous patch, but with more reliable int(date) conversions (build_time.patch,2.95 KB, patch)
2012-09-05 15:59 UTC, Martin Väth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Väth 2012-09-04 20:15:06 UTC
Created attachment 322940 [details]
Make AgeSet and DateSet use BUILD_TIME key instead of COUNTER mtime

Sorry to bother again because of AgeSet and DateSet:

Since there is quite a while the BUILD_TIME key in portage,
this is probably what should be used instead of the
mtime of COUNTER:

If a package was emerged from a *.tbz2, the BUILD_TIME is
probably what the user means by the age of a package when
he uses the AgeSet/DateSet classes. (And moreover, it
appears not so clean to use undocumented timestamps.)

For "ancient" packages which were emerged before the
BUILD_TIME key was supported by portage, it is probably
reasonable to assume that they are older than any date
specified in AgeSet/DateSet.

I attach a corresponding patch.

(BTW: Thanks for improving the option parsing logic and
fixing the exception handling in DateSet.)
Comment 1 Zac Medico gentoo-dev 2012-09-04 21:01:28 UTC
You should handle ValueError from float(date), in case BUILD_TIME is corrupt.

Also, it looks like you forgot to convert the date string to a float in a couple of places (BUILD_TIME is suppose to be an int, so you could use int(date) instead).
Comment 2 Zac Medico gentoo-dev 2012-09-05 04:08:15 UTC
Also, note that aux_get will return an empty string for any packages installed by older portage which did not support BUILD_TIME, so you could handle that specially (maybe that's what the KeyError handling was intended for, but it won't work since an empty string is simply returned).
Comment 3 Martin Väth 2012-09-05 15:59:31 UTC
Created attachment 323012 [details, diff]
Fix previous patch, but with more reliable int(date) conversions

Thanks for your hints.

> BUILD_TIME is suppose to be an int

In this case, it makes no sense to allow "date" being a flow.
I made it now an int throughout.

> Also, note that aux_get will return an empty string for
> any packages installed by older portage which did not
> support BUILD_TIME

Thanks. I didn't expect this, since my impression was that
the RebuiltBinaries class (in the same file) used KeyError
for checking it; but it has in addition a check for a
nonempty string...

So the new patch just needs to verify that int(BUILD_TIME) succeeds:
This also covers BUILD_TIME == "", since int("") fails with ValueError.
Comment 5 Zac Medico gentoo-dev 2012-09-08 23:49:16 UTC
This is fixed in 2.2.0_alpha125.