[Reproducible-builds] Bug#794681: qt4-x11: please support timestamps from environment

Dhole dhole at openmailbox.org
Wed Aug 5 16:03:38 UTC 2015


Source: qt4-x11
Version: 4:4.8.7+dfsg-2
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-builds at lists.alioth.debian.org

Hi,

While working on the "reproducible builds" effort [1], we have noticed
that the qhelpgenerator tool from qt4-x11 embeds timestamps on the
creation of qch files.

For the Reproducible Builds effort we are proposing an environment
variable (SOURCE_DATE_EPOCH) [2] that will contain a deterministic epoch
timestamp (based on the latest debian/changelog entry) that could be
used, which should be automatically exported by debhelper in the future [3].

The attached patch proposes a way to use this variable to get
reproducible timestamps in the qch files generated by qhelpgenerator, if
the variable has been set (if not, it falls back to the old behavior).
With the attached patch packages using qhelpgenerator would then
automatically embed reproducible timestamps in qch files.


[1]: https://wiki.debian.org/ReproducibleBuilds
[2]: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
[3]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=791815

Regards,
-- 
Dhole
-------------- next part --------------
diff -Nru qt4-x11-4.8.7+dfsg/debian/changelog qt4-x11-4.8.7+dfsg/debian/changelog
--- qt4-x11-4.8.7+dfsg/debian/changelog	2015-08-02 22:01:18.000000000 +0200
+++ qt4-x11-4.8.7+dfsg/debian/changelog	2015-08-04 15:19:05.000000000 +0200
@@ -1,3 +1,11 @@
+qt4-x11 (4:4.8.7+dfsg-2.0~reproducible1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add support for reproducible builds by using $SOURCE_DATE_EPOCH as the
+    embedded timestamps in qch files generated with qhelpgenerator.
+
+ -- Eduard Sanou <dhole at openmailbox.org>  Tue, 04 Aug 2015 15:17:35 +0200
+
 qt4-x11 (4:4.8.7+dfsg-2) experimental; urgency=medium
 
   * Add Daniel Schepler's QtScript_x32_config.diff and x32.diff to let Qt4
diff -Nru qt4-x11-4.8.7+dfsg/debian/patches/Replace_timestamp_with_SOURCE_DATE_EPOCH_in_qhelpgenerator.patch qt4-x11-4.8.7+dfsg/debian/patches/Replace_timestamp_with_SOURCE_DATE_EPOCH_in_qhelpgenerator.patch
--- qt4-x11-4.8.7+dfsg/debian/patches/Replace_timestamp_with_SOURCE_DATE_EPOCH_in_qhelpgenerator.patch	1970-01-01 01:00:00.000000000 +0100
+++ qt4-x11-4.8.7+dfsg/debian/patches/Replace_timestamp_with_SOURCE_DATE_EPOCH_in_qhelpgenerator.patch	2015-08-04 15:41:15.000000000 +0200
@@ -0,0 +1,102 @@
+Description: Allow the timestamps from qhelpgenerator to be externally set
+ In order to make qhelpgenerator output reproducible, we need a way to
+ set the embedded timestamps to other values than the current time.
+ We define a new method for QDateTime (reproducibleDateTime) that returns
+ a deterministic datetime object when the SOURCE_DATE_EPOCH environment 
+ variable is set with a unix epoch timestamp, containing the datetime 
+ defined by SOURCE_DATE_EPOCH in UTC. We replace some instances of
+ QDateTime::currentDateTime() by QDateTime::reproducibleDateTime() in the
+ sources of qhelpgenerator to make the output reproducible.
+Author: Eduard Sanou <dhole at openmailbox.org>
+
+--- qt4-x11-4.8.7+dfsg.orig/src/corelib/tools/qdatetime.cpp
++++ qt4-x11-4.8.7+dfsg/src/corelib/tools/qdatetime.cpp
+@@ -2892,6 +2892,15 @@ bool QDateTime::operator<(const QDateTim
+ */
+ 
+ /*!
++    \fn QDateTime QDateTime::reproducibleDateTime()
++    If the environment variable SOURCE_DATE_EPOCH containing a unix epoch date
++    is set, returns the datetime in SOURCE_DATE_EPOCH, in UTC.
++    If SOURCE_DATE_EPOCH is not set, behaves as QDateTime::currentDateTime().
++
++    \sa currentDateTimeUtc(), QDate::currentDate(), QTime::currentTime(), toTimeSpec()
++*/
++
++/*!
+     \fn QDateTime QDateTime::currentDateTimeUtc()
+     \since 4.7
+     Returns the current datetime, as reported by the system clock, in
+@@ -3120,6 +3129,29 @@ QDateTime QDateTime::currentDateTime()
+     return dt;
+ }
+ 
++QDateTime QDateTime::reproducibleDateTime()
++{
++    QByteArray env_date;
++    QDateTime date;
++    bool env_date_ok;
++    long timestamp;
++
++    env_date = qgetenv("SOURCE_DATE_EPOCH");
++    if (env_date.length() != 0) {
++        timestamp = env_date.toLong(&env_date_ok, 10);
++        if (!env_date_ok) {
++            // "SOURCE_DATE_EPOCH is not a number!
++            timestamp = 0;
++        }
++        date = QDateTime::fromTime_t(timestamp).toUTC();
++    } else {
++        date = QDateTime::currentDateTime();
++    }
++
++    return date;
++}
++
++
+ QDateTime QDateTime::currentDateTimeUtc()
+ {
+     // posix compliant system
+--- qt4-x11-4.8.7+dfsg.orig/src/corelib/tools/qdatetime.h
++++ qt4-x11-4.8.7+dfsg/src/corelib/tools/qdatetime.h
+@@ -264,6 +264,7 @@ public:
+     int utcOffset() const;
+ 
+     static QDateTime currentDateTime();
++    static QDateTime reproducibleDateTime();
+     static QDateTime currentDateTimeUtc();
+ #ifndef QT_NO_DATESTRING
+     static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
+--- qt4-x11-4.8.7+dfsg.orig/tools/assistant/lib/qhelpgenerator.cpp
++++ qt4-x11-4.8.7+dfsg/tools/assistant/lib/qhelpgenerator.cpp
+@@ -381,7 +381,7 @@ bool QHelpGenerator::createTables()
+     d->query->exec(QLatin1String("INSERT INTO MetaDataTable VALUES('qchVersion', '1.0')"));
+ 
+     d->query->prepare(QLatin1String("INSERT INTO MetaDataTable VALUES('CreationDate', ?)"));
+-    d->query->bindValue(0, QDateTime::currentDateTime().toString(Qt::ISODate));
++    d->query->bindValue(0, QDateTime::reproducibleDateTime().toString(Qt::ISODate));
+     d->query->exec();
+ 
+     return true;
+--- qt4-x11-4.8.7+dfsg.orig/tools/assistant/tools/qcollectiongenerator/main.cpp
++++ qt4-x11-4.8.7+dfsg/tools/assistant/tools/qcollectiongenerator/main.cpp
+@@ -521,7 +521,7 @@ int main(int argc, char *argv[])
+     CollectionConfiguration::setAddressBarVisible(helpEngine,
+          !config.hideAddressBar());
+     CollectionConfiguration::setCreationTime(helpEngine,
+-        QDateTime::currentDateTime().toTime_t());
++        QDateTime::reproducibleDateTime().toTime_t());
+     CollectionConfiguration::setFullTextSearchFallbackEnabled(helpEngine,
+         config.fullTextSearchFallbackEnabled());
+ 
+--- qt4-x11-4.8.7+dfsg.orig/tools/assistant/tools/shared/collectionconfiguration.cpp
++++ qt4-x11-4.8.7+dfsg/tools/assistant/tools/shared/collectionconfiguration.cpp
+@@ -282,7 +282,7 @@ const QDateTime CollectionConfiguration:
+ 
+ void CollectionConfiguration::updateLastRegisterTime(QHelpEngineCore &helpEngine)
+ {
+-    helpEngine.setCustomValue(LastRegisterTime, QDateTime::currentDateTime());
++    helpEngine.setCustomValue(LastRegisterTime, QDateTime::reproducibleDateTime());
+ }
+ 
+ bool CollectionConfiguration::isNewer(const QHelpEngineCore &newer,
diff -Nru qt4-x11-4.8.7+dfsg/debian/patches/series qt4-x11-4.8.7+dfsg/debian/patches/series
--- qt4-x11-4.8.7+dfsg/debian/patches/series	2015-08-02 20:14:37.000000000 +0200
+++ qt4-x11-4.8.7+dfsg/debian/patches/series	2015-08-04 15:34:59.000000000 +0200
@@ -55,3 +55,4 @@
 parisc-atomic.patch
 QtScript_x32_config.diff
 x32.diff
+Replace_timestamp_with_SOURCE_DATE_EPOCH_in_qhelpgenerator.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/reproducible-builds/attachments/20150805/9a40e6bc/attachment.sig>


More information about the Reproducible-builds mailing list