diff options
author | James Addison <jay@jp-hosting.net> | 2023-12-30 21:20:41 +0000 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-01-01 20:28:42 +0000 |
commit | 3abe60b2023dfd9cac6937df8c5a540f20eb8164 (patch) | |
tree | c5d93096b618cae683cd0658043019ee72b0f4e5 | |
parent | c73d137dcc7ba8ce0688f61b3c6632db2f121abc (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
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit f11d7e4af73ca474ab71310961b155f6c9bc71da)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 20be13855f78bf1c5110997c1ce8baf6c1123cdc)
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler.cpp | 4 | ||||
-rw-r--r-- | src/assistant/qhelpgenerator/main.cpp | 1 |
2 files changed, 4 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()) diff --git a/src/assistant/qhelpgenerator/main.cpp b/src/assistant/qhelpgenerator/main.cpp index cad0095c4..ca5549974 100644 --- a/src/assistant/qhelpgenerator/main.cpp +++ b/src/assistant/qhelpgenerator/main.cpp @@ -92,6 +92,7 @@ int generateCollectionFile(const QByteArray &data, const QString &basePath, cons if (!config.filesToRegister().isEmpty()) { if (Q_UNLIKELY(qEnvironmentVariableIsSet("SOURCE_DATE_EPOCH"))) { QDateTime dt; + dt.setTimeZone(QTimeZone::UTC); dt.setSecsSinceEpoch(qEnvironmentVariableIntValue("SOURCE_DATE_EPOCH")); CollectionConfiguration::updateLastRegisterTime(helpEngine, dt); } else { |