summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Addison <jay@jp-hosting.net>2023-12-30 21:20:41 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-01 14:01:42 +0000
commit20be13855f78bf1c5110997c1ce8baf6c1123cdc (patch)
treec1bb9d5e206a5d3e5d5eba331893702b9754513f
parentc0c5fa0a33055ee17c5146558bbe6a97639ce029 (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 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>
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp4
-rw-r--r--src/assistant/qhelpgenerator/main.cpp1
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 {