Summary: | gpkg binary packages have timestamps in the past | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Ulrich Müller <ulm> |
Component: | Binary packages support | Assignee: | Portage team <dev-portage> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | syu.os |
Priority: | Normal | Keywords: | InVCS |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: | https://github.com/gentoo/portage/pull/1060 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 908971 | ||
Bug Blocks: | 913920 |
Description
Ulrich Müller
![]() 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). hmmm, timestamp() seems will take your local timezone into account even if it's marked as 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. 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(-) 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(+) |