diff options
author | James Addison <jay@jp-hosting.net> | 2023-12-30 21:20:41 +0000 |
---|---|---|
committer | James Addison <jay@jp-hosting.net> | 2024-01-01 13:26:18 +0000 |
commit | f11d7e4af73ca474ab71310961b155f6c9bc71da (patch) | |
tree | 61eb805a1a5690c1f2d605f657a7afe38d68d933 /src/assistant/help/qhelpcollectionhandler.cpp | |
parent | e66b37641bee97d0e52931ee73d1ba9ac609a7d0 (diff) |
qhelpgenerator: localize SOURCE_DATE_EPOCH to UTC
The SOURCE_DATE_EPOCH environment variable is used as an anchor
timestamp that software builds can use when they embed timestamps
that refer to the build-time into their build artifacts.
The value of the variable is specified[1] as an integer number of
seconds since the Unix epoch (1970-01-01T00:00:00Z).
To ensure that the value is interpreted correctly, and to ensure
that the resulting timestamps embedded by qhelpgenerator cannot
drift with the build environment's timezone settings, we should
store the SOURCE_DATE_EPOCH in QDateTime instances that have a UTC
timezone.
[1] - https://reproducible-builds.org/specs/source-date-epoch/
Task-number: QTBUG-62697
Change-Id: I24a79088886adf9334cd7c3c6f723eb9f064007d
Pick-to: 6.6 6.7
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Diffstat (limited to 'src/assistant/help/qhelpcollectionhandler.cpp')
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp index c02ffdf62..a79b8dacb 100644 --- a/src/assistant/help/qhelpcollectionhandler.cpp +++ b/src/assistant/help/qhelpcollectionhandler.cpp @@ -2170,8 +2170,10 @@ bool QHelpCollectionHandler::registerIndexTable(const QHelpDBReader::IndexTable const QString sourceDateEpochStr = qEnvironmentVariable("SOURCE_DATE_EPOCH"); bool ok; const qlonglong sourceDateEpoch = sourceDateEpochStr.toLongLong(&ok); - if (ok && sourceDateEpoch < lastModified.toSecsSinceEpoch()) + if (ok && sourceDateEpoch < lastModified.toSecsSinceEpoch()) { + lastModified.setTimeZone(QTimeZone::UTC); lastModified.setSecsSinceEpoch(sourceDateEpoch); + } } m_query->addBindValue(lastModified.toString(Qt::ISODate)); if (!m_query->exec()) |