Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 909067 - gpkg binary packages have timestamps in the past
Summary: gpkg binary packages have timestamps in the past
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Binary packages support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 908971
Blocks:
  Show dependency tree
 
Reported: 2023-06-24 08:37 UTC by Ulrich Müller
Modified: 2023-08-09 02:57 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2023-06-24 08:37:15 UTC
# date
Sat 24 Jun 10:32:27 CEST 2023
# BINPKG_FORMAT=gpkg emerge -B app-editors/mg
[...]
>>> Emerging (1 of 1) app-editors/mg-20230501::gentoo
[...]
>>> Done

The timestamps in the resulting (outer) tarball are 2 hours in the past:

# tar tvf /var/cache/binpkgs/app-editors/mg/mg-20230501-1.gpkg.tar
-rw-r--r-- 0/0               0 2023-06-24 08:32 mg-20230501-1/gpkg-1
-rw-r--r-- 0/0           16694 2023-06-24 08:32 mg-20230501-1/metadata.tar.bz2
-rw-r--r-- 0/0          393791 2023-06-24 08:32 mg-20230501-1/image.tar.bz2
-rw-r--r-- 0/0             887 2023-06-24 08:32 mg-20230501-1/Manifest

I am in the CET/CEST time zone, i.e. 2 hours ahead of UTC.
Comment 1 Ulrich Müller gentoo-dev 2023-06-24 09:07:42 UTC
I see that gpkg.py uses datetime.utcnow().timestamp() for the mtime. I suspect that it should be datetime.now().timestamp() instead.

A short test shows this:

$ date; date +%s
Sat 24 Jun 11:00:05 CEST 2023
1687597205

So today 11:00 CEST = 09:00 UTC is 1687597200 seconds after the epoch.

$ python
Python 3.11.4 (main, Jun 10 2023, 11:13:46) [GCC 12.3.1 20230526] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.utcnow().timestamp()
1687590009.838177
>>> datetime.now().timestamp()
1687597211.389014
>>> 

now() gives the correct number of seconds since the epoch, while utcnow() appears to subtract 2 hours.

$ TZ=Z python
Python 3.11.4 (main, Jun 10 2023, 11:13:46) [GCC 12.3.1 20230526] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.utcnow().timestamp()
1687597216.533068
>>> datetime.now().timestamp()
1687597218.097988
>>> 

Unsurprisingly, the two times are identical in the UTC timezone (except for my slow typing).
Comment 2 Sheng Yu 2023-06-24 20:09:34 UTC
hmmm, timestamp() seems will take your local timezone into account even if it's marked as UTC.
Comment 3 dwfreed 2023-06-24 20:16:54 UTC
This is explained in the docs:

https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

utcnow() produces a naive datetime object, and most methods of datetime objects treat naive datetime objects as local time.
Comment 4 Larry the Git Cow gentoo-dev 2023-06-29 08:22:56 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=ffba5c4c48d8b937927ee67ac7c3dfc226827ddc

commit ffba5c4c48d8b937927ee67ac7c3dfc226827ddc
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-25 07:56:41 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-29 08:22:53 +0000

    NEWS: update
    
    Bug: https://bugs.gentoo.org/640658
    Bug: https://bugs.gentoo.org/909067
    Signed-off-by: Sam James <sam@gentoo.org>

 NEWS | 9 +++++++++
 1 file changed, 9 insertions(+)

https://gitweb.gentoo.org/proj/portage.git/commit/?id=59973d0f5829ebbae615a001a97abb652431a61b

commit 59973d0f5829ebbae615a001a97abb652431a61b
Author:     Sheng Yu <syu.os@protonmail.com>
AuthorDate: 2023-06-24 20:28:20 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-29 08:22:53 +0000

    gpkg: fix incorrect gpkg timestamp
    
    [sam: Quoting dwfreed from the bug:
    "utcnow() produces a naive datetime object, and most methods of datetime objects
    treat naive datetime objects as local time."]
    
    Bug: https://bugs.gentoo.org/909067
    Signed-off-by: Sheng Yu <syu.os@protonmail.com>
    Closes: https://github.com/gentoo/portage/pull/1060
    Signed-off-by: Sam James <sam@gentoo.org>

 lib/portage/gpkg.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
Comment 5 Larry the Git Cow gentoo-dev 2023-08-09 02:57:29 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=858dfd771ac4c6c9315ac5851f4aeeb233fc21d5

commit 858dfd771ac4c6c9315ac5851f4aeeb233fc21d5
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-08-09 02:54:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-08-09 02:54:12 +0000

    sys-apps/portage: add 3.0.50
    
    Closes: https://bugs.gentoo.org/908971
    Closes: https://bugs.gentoo.org/640658
    Closes: https://bugs.gentoo.org/894398
    Closes: https://bugs.gentoo.org/895908
    Closes: https://bugs.gentoo.org/909067
    Closes: https://bugs.gentoo.org/909148
    Closes: https://bugs.gentoo.org/909853
    Closes: https://bugs.gentoo.org/910035
    Closes: https://bugs.gentoo.org/910376
    Closes: https://bugs.gentoo.org/911594
    Closes: https://bugs.gentoo.org/911574
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.50.ebuild | 229 +++++++++++++++++++++++++++++++++
 2 files changed, 230 insertions(+)