Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtcore/, dev-qt/qtcore/files/
Date: Sat, 10 Oct 2020 17:40:09
Message-Id: 1602351600.8cc44eb4b719129f109dfa623efd5420d1665b63.dilfridge@gentoo
1 commit: 8cc44eb4b719129f109dfa623efd5420d1665b63
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 10 17:39:33 2020 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 10 17:40:00 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8cc44eb4
7
8 dev-qt/qtcore: Revert timezone handling to 5.14 state
9
10 This is an obvious workaround, until we and upstream have
11 decided what to do...
12
13 Closes: https://bugs.gentoo.org/737914
14 Package-Manager: Portage-3.0.4, Repoman-3.0.1
15 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
16
17 dev-qt/qtcore/files/qtcore-5.15.1-timezone-1.patch | 271 +++++++++++++++++++++
18 dev-qt/qtcore/files/qtcore-5.15.1-timezone-2.patch | 47 ++++
19 dev-qt/qtcore/qtcore-5.15.1-r1.ebuild | 104 ++++++++
20 3 files changed, 422 insertions(+)
21
22 diff --git a/dev-qt/qtcore/files/qtcore-5.15.1-timezone-1.patch b/dev-qt/qtcore/files/qtcore-5.15.1-timezone-1.patch
23 new file mode 100644
24 index 00000000000..1c8f1e89e7d
25 --- /dev/null
26 +++ b/dev-qt/qtcore/files/qtcore-5.15.1-timezone-1.patch
27 @@ -0,0 +1,271 @@
28 +From c337f6fae51b987ce7dbed1fd9bea41e6073efbb Mon Sep 17 00:00:00 2001
29 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfridge@g.o>
30 +Date: Sat, 10 Oct 2020 19:26:13 +0200
31 +Subject: [PATCH 1/2] Revert "Cache system zone ID when fetched from the
32 + file-system"
33 +
34 +This reverts commit c70ce3d042025c858faffe661f85d2482a2a0d8c.
35 +---
36 + src/corelib/time/qtimezoneprivate_tz.cpp | 205 +++++++----------------
37 + 1 file changed, 64 insertions(+), 141 deletions(-)
38 +
39 +diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
40 +index c5c70b7364..01f9a6cce0 100644
41 +--- a/src/corelib/time/qtimezoneprivate_tz.cpp
42 ++++ b/src/corelib/time/qtimezoneprivate_tz.cpp
43 +@@ -1,6 +1,5 @@
44 + /****************************************************************************
45 + **
46 +-** Copyright (C) 2020 The Qt Company Ltd.
47 + ** Copyright (C) 2019 Crimson AS <info@×××××××.no>
48 + ** Copyright (C) 2013 John Layt <jlayt@×××.org>
49 + ** Contact: https://www.qt.io/licensing/
50 +@@ -43,19 +42,18 @@
51 + #include "qtimezoneprivate_p.h"
52 + #include "private/qlocale_tools_p.h"
53 +
54 +-#include <QtCore/QDataStream>
55 +-#include <QtCore/QDateTime>
56 + #include <QtCore/QFile>
57 +-#include <QtCore/QHash>
58 + #include <QtCore/QMutex>
59 ++#include <QtCore/QHash>
60 ++#include <QtCore/QDataStream>
61 ++#include <QtCore/QDateTime>
62 +
63 + #include <qdebug.h>
64 +-#include <qplatformdefs.h>
65 +
66 + #include <algorithm>
67 + #include <errno.h>
68 + #include <limits.h>
69 +-#ifndef Q_OS_INTEGRITY
70 ++#if !defined(Q_OS_INTEGRITY)
71 + #include <sys/param.h> // to use MAXSYMLINKS constant
72 + #endif
73 + #include <unistd.h> // to use _SC_SYMLOOP_MAX constant
74 +@@ -1102,146 +1100,28 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs
75 + return last > tranCache().cbegin() ? dataForTzTransition(*--last) : invalidData();
76 + }
77 +
78 +-bool QTzTimeZonePrivate::isTimeZoneIdAvailable(const QByteArray &ianaId) const
79 +-{
80 +- return tzZones->contains(ianaId);
81 +-}
82 +-
83 +-QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const
84 +-{
85 +- QList<QByteArray> result = tzZones->keys();
86 +- std::sort(result.begin(), result.end());
87 +- return result;
88 +-}
89 +-
90 +-QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
91 ++static long getSymloopMax()
92 + {
93 +- // TODO AnyCountry
94 +- QList<QByteArray> result;
95 +- for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end; ++it) {
96 +- if (it.value().country == country)
97 +- result << it.key();
98 +- }
99 +- std::sort(result.begin(), result.end());
100 +- return result;
101 +-}
102 +-
103 +-// Getting the system zone's ID:
104 +-
105 +-namespace {
106 +-class ZoneNameReader : public QObject
107 +-{
108 +-public:
109 +- QByteArray name()
110 +- {
111 +- /* Assumptions:
112 +- a) Systems don't change which of localtime and TZ they use without a
113 +- reboot.
114 +- b) When they change, they use atomic renames, hence a new device and
115 +- inode for the new file.
116 +- c) If we change which *name* is used for a zone, while referencing
117 +- the same final zoneinfo file, we don't care about the change of
118 +- name (e.g. if Europe/Oslo and Europe/Berlin are both symlinks to
119 +- the same CET file, continuing to use the old name, after
120 +- /etc/localtime changes which of the two it points to, is
121 +- harmless).
122 +-
123 +- The alternative would be to use a file-system watcher, but they are a
124 +- scarce resource.
125 +- */
126 +- const StatIdent local = identify("/etc/localtime");
127 +- const StatIdent tz = identify("/etc/TZ");
128 +- if (!m_name.isEmpty() && m_last.isValid() && (m_last == local || m_last == tz))
129 +- return m_name;
130 +-
131 +- m_name = etcLocalTime();
132 +- if (!m_name.isEmpty()) {
133 +- m_last = local;
134 +- return m_name;
135 +- }
136 +-
137 +- m_name = etcTZ();
138 +- m_last = m_name.isEmpty() ? StatIdent() : tz;
139 +- return m_name;
140 +- }
141 +-
142 +-
143 +-private:
144 +- QByteArray m_name;
145 +- struct StatIdent
146 +- {
147 +- static constexpr unsigned long bad = ~0ul;
148 +- unsigned long m_dev, m_ino;
149 +- StatIdent() : m_dev(bad), m_ino(bad) {}
150 +- StatIdent(const QT_STATBUF &data) : m_dev(data.st_dev), m_ino(data.st_ino) {}
151 +- bool isValid() { return m_dev != bad || m_ino != bad; }
152 +- bool operator==(const StatIdent &other)
153 +- { return other.m_dev == m_dev && other.m_ino == m_ino; }
154 +- };
155 +- StatIdent m_last;
156 +-
157 +- static StatIdent identify(const char *path)
158 +- {
159 +- QT_STATBUF data;
160 +- return QT_STAT(path, &data) == -1 ? StatIdent() : StatIdent(data);
161 +- }
162 +-
163 +- static QByteArray etcLocalTime()
164 +- {
165 +- // On most distros /etc/localtime is a symlink to a real file so extract
166 +- // name from the path
167 +- const QLatin1String zoneinfo("/zoneinfo/");
168 +- QString path = QStringLiteral("/etc/localtime");
169 +- long iteration = getSymloopMax();
170 +- // Symlink may point to another symlink etc. before being under zoneinfo/
171 +- // We stop on the first path under /zoneinfo/, even if it is itself a
172 +- // symlink, like America/Montreal pointing to America/Toronto
173 +- do {
174 +- path = QFile::symLinkTarget(path);
175 +- int index = path.indexOf(zoneinfo);
176 +- if (index >= 0) // Found zoneinfo file; extract zone name from path:
177 +- return path.midRef(index + zoneinfo.size()).toUtf8();
178 +- } while (!path.isEmpty() && --iteration > 0);
179 +-
180 +- return QByteArray();
181 +- }
182 +-
183 +- static QByteArray etcTZ()
184 +- {
185 +- // Some systems (e.g. uClibc) have a default value for $TZ in /etc/TZ:
186 +- const QString path = QStringLiteral("/etc/TZ");
187 +- QFile zone(path);
188 +- if (zone.open(QIODevice::ReadOnly))
189 +- return zone.readAll().trimmed();
190 +-
191 +- return QByteArray();
192 +- }
193 +-
194 +- // Any chain of symlinks longer than this is assumed to be a loop:
195 +- static long getSymloopMax()
196 +- {
197 +-#ifdef SYMLOOP_MAX
198 +- // If defined, at runtime it can only be greater than this, so this is a safe bet:
199 +- return SYMLOOP_MAX;
200 ++#if defined(SYMLOOP_MAX)
201 ++ return SYMLOOP_MAX; // if defined, at runtime it can only be greater than this, so this is a safe bet
202 + #else
203 +- errno = 0;
204 +- long result = sysconf(_SC_SYMLOOP_MAX);
205 +- if (result >= 0)
206 +- return result;
207 +- // result is -1, meaning either error or no limit
208 +- Q_ASSERT(!errno); // ... but it can't be an error, POSIX mandates _SC_SYMLOOP_MAX
209 +-
210 +- // therefore we can make up our own limit
211 +-# ifdef MAXSYMLINKS
212 +- return MAXSYMLINKS;
213 ++ errno = 0;
214 ++ long result = sysconf(_SC_SYMLOOP_MAX);
215 ++ if (result >= 0)
216 ++ return result;
217 ++ // result is -1, meaning either error or no limit
218 ++ Q_ASSERT(!errno); // ... but it can't be an error, POSIX mandates _SC_SYMLOOP_MAX
219 ++
220 ++ // therefore we can make up our own limit
221 ++# if defined(MAXSYMLINKS)
222 ++ return MAXSYMLINKS;
223 + # else
224 +- return 8;
225 ++ return 8;
226 + # endif
227 + #endif
228 +- }
229 +-};
230 + }
231 +
232 ++// TODO Could cache the value and monitor the required files for any changes
233 + QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
234 + {
235 + // Check TZ env var first, if not populated try find it
236 +@@ -1256,9 +1136,28 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
237 + else if (ianaId.startsWith(':'))
238 + ianaId = ianaId.mid(1);
239 +
240 ++ // On most distros /etc/localtime is a symlink to a real file so extract name from the path
241 ++ if (ianaId.isEmpty()) {
242 ++ const QLatin1String zoneinfo("/zoneinfo/");
243 ++ QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime"));
244 ++ int index = -1;
245 ++ long iteration = getSymloopMax();
246 ++ // Symlink may point to another symlink etc. before being under zoneinfo/
247 ++ // We stop on the first path under /zoneinfo/, even if it is itself a
248 ++ // symlink, like America/Montreal pointing to America/Toronto
249 ++ while (iteration-- > 0 && !path.isEmpty() && (index = path.indexOf(zoneinfo)) < 0)
250 ++ path = QFile::symLinkTarget(path);
251 ++ if (index >= 0) {
252 ++ // /etc/localtime is a symlink to the current TZ file, so extract from path
253 ++ ianaId = path.midRef(index + zoneinfo.size()).toUtf8();
254 ++ }
255 ++ }
256 ++
257 ++ // Some systems (e.g. uClibc) have a default value for $TZ in /etc/TZ:
258 + if (ianaId.isEmpty()) {
259 +- thread_local static ZoneNameReader reader;
260 +- ianaId = reader.name();
261 ++ QFile zone(QStringLiteral("/etc/TZ"));
262 ++ if (zone.open(QIODevice::ReadOnly))
263 ++ ianaId = zone.readAll().trimmed();
264 + }
265 +
266 + // Give up for now and return UTC
267 +@@ -1268,4 +1167,28 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
268 + return ianaId;
269 + }
270 +
271 ++bool QTzTimeZonePrivate::isTimeZoneIdAvailable(const QByteArray &ianaId) const
272 ++{
273 ++ return tzZones->contains(ianaId);
274 ++}
275 ++
276 ++QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const
277 ++{
278 ++ QList<QByteArray> result = tzZones->keys();
279 ++ std::sort(result.begin(), result.end());
280 ++ return result;
281 ++}
282 ++
283 ++QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
284 ++{
285 ++ // TODO AnyCountry
286 ++ QList<QByteArray> result;
287 ++ for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end; ++it) {
288 ++ if (it.value().country == country)
289 ++ result << it.key();
290 ++ }
291 ++ std::sort(result.begin(), result.end());
292 ++ return result;
293 ++}
294 ++
295 + QT_END_NAMESPACE
296 +--
297 +2.28.0
298 +
299
300 diff --git a/dev-qt/qtcore/files/qtcore-5.15.1-timezone-2.patch b/dev-qt/qtcore/files/qtcore-5.15.1-timezone-2.patch
301 new file mode 100644
302 index 00000000000..611c979a469
303 --- /dev/null
304 +++ b/dev-qt/qtcore/files/qtcore-5.15.1-timezone-2.patch
305 @@ -0,0 +1,47 @@
306 +From ffc9093a199a542791920b30d1835c3248920aa0 Mon Sep 17 00:00:00 2001
307 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfridge@g.o>
308 +Date: Sat, 10 Oct 2020 19:26:35 +0200
309 +Subject: [PATCH 2/2] Revert "Purge two old time-zone lookup fallbacks"
310 +
311 +This reverts commit b0383cbd388336f698ceeac11a4f50cdff931dd9.
312 +---
313 + src/corelib/time/qtimezoneprivate_tz.cpp | 23 +++++++++++++++++++++++
314 + 1 file changed, 23 insertions(+)
315 +
316 +diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
317 +index 01f9a6cce0..eea6f5e962 100644
318 +--- a/src/corelib/time/qtimezoneprivate_tz.cpp
319 ++++ b/src/corelib/time/qtimezoneprivate_tz.cpp
320 +@@ -1153,6 +1153,29 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
321 + }
322 + }
323 +
324 ++ // On Debian Etch up to Jessie, /etc/localtime is a copy of the relevant
325 ++ // zoneinfo file, whose name is recorded in /etc/timezone:
326 ++ if (ianaId.isEmpty()) {
327 ++ QFile tzif(QStringLiteral("/etc/timezone"));
328 ++ if (tzif.open(QIODevice::ReadOnly))
329 ++ ianaId = tzif.readAll().trimmed();
330 ++ }
331 ++
332 ++ // On some Red Hat distros /etc/localtime is real file with name held in /etc/sysconfig/clock
333 ++ // in a line like ZONE="Europe/Oslo" or TIMEZONE="Europe/Oslo"
334 ++ if (ianaId.isEmpty()) {
335 ++ QFile tzif(QStringLiteral("/etc/sysconfig/clock"));
336 ++ if (tzif.open(QIODevice::ReadOnly)) {
337 ++ while (ianaId.isEmpty() && !tzif.atEnd()) {
338 ++ const QByteArray line(tzif.readLine().trimmed());
339 ++ if (line.startsWith("ZONE="))
340 ++ ianaId = line.mid(6, line.length() - 7);
341 ++ else if (line.startsWith("TIMEZONE="))
342 ++ ianaId = line.mid(10, line.length() - 11);
343 ++ }
344 ++ }
345 ++ }
346 ++
347 + // Some systems (e.g. uClibc) have a default value for $TZ in /etc/TZ:
348 + if (ianaId.isEmpty()) {
349 + QFile zone(QStringLiteral("/etc/TZ"));
350 +--
351 +2.28.0
352 +
353
354 diff --git a/dev-qt/qtcore/qtcore-5.15.1-r1.ebuild b/dev-qt/qtcore/qtcore-5.15.1-r1.ebuild
355 new file mode 100644
356 index 00000000000..e5a80a34d43
357 --- /dev/null
358 +++ b/dev-qt/qtcore/qtcore-5.15.1-r1.ebuild
359 @@ -0,0 +1,104 @@
360 +# Copyright 1999-2020 Gentoo Authors
361 +# Distributed under the terms of the GNU General Public License v2
362 +
363 +EAPI=7
364 +
365 +QT5_MODULE="qtbase"
366 +inherit linux-info qt5-build
367 +
368 +DESCRIPTION="Cross-platform application development framework"
369 +SLOT=5/$(ver_cut 1-3)
370 +
371 +if [[ ${QT5_BUILD_TYPE} == release ]]; then
372 + KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
373 +fi
374 +
375 +IUSE="icu old-kernel systemd"
376 +
377 +DEPEND="
378 + dev-libs/double-conversion:=
379 + dev-libs/glib:2
380 + dev-libs/libpcre2[pcre16,unicode]
381 + sys-libs/zlib:=
382 + icu? ( dev-libs/icu:= )
383 + !icu? ( virtual/libiconv )
384 + systemd? ( sys-apps/systemd:= )
385 +"
386 +RDEPEND="${DEPEND}
387 + !<dev-qt/qtcore-4.8.7-r4:4
388 +"
389 +
390 +QT5_TARGET_SUBDIRS=(
391 + src/tools/bootstrap
392 + src/tools/moc
393 + src/tools/rcc
394 + src/corelib
395 + src/tools/qlalr
396 + doc
397 +)
398 +
399 +QT5_GENTOO_PRIVATE_CONFIG=(
400 + !:network
401 + !:sql
402 + !:testlib
403 + !:xml
404 +)
405 +
406 +PATCHES=(
407 + "${FILESDIR}/${PN}-5.14.1-cmake-macro-backward-compat.patch" # bug 703306
408 + "${FILESDIR}/${PN}-5.15.1-timezone-1.patch" # bug 737914
409 + "${FILESDIR}/${PN}-5.15.1-timezone-2.patch"
410 +)
411 +
412 +pkg_pretend() {
413 + use kernel_linux || return
414 + get_running_version
415 + if kernel_is -lt 4 11 && ! use old-kernel; then
416 + ewarn "The running kernel is older than 4.11. USE=old-kernel is needed for"
417 + ewarn "dev-qt/qtcore to function on this kernel properly. Bugs #669994, #672856"
418 + fi
419 +}
420 +
421 +src_prepare() {
422 + # don't add -O3 to CXXFLAGS, bug 549140
423 + sed -i -e '/CONFIG\s*+=/s/optimize_full//' src/corelib/corelib.pro || die
424 +
425 + # fix missing qt_version_tag symbol w/ LTO, bug 674382
426 + sed -i -e 's/^gcc:ltcg/gcc/' src/corelib/global/global.pri || die
427 +
428 + qt5-build_src_prepare
429 +}
430 +
431 +src_configure() {
432 + local myconf=(
433 + $(qt_use icu)
434 + $(qt_use !icu iconv)
435 + $(qt_use systemd journald)
436 + )
437 + use old-kernel && myconf+=(
438 + -no-feature-renameat2 # needs Linux 3.16, bug 669994
439 + -no-feature-getentropy # needs Linux 3.17, bug 669994
440 + -no-feature-statx # needs Linux 4.11, bug 672856
441 + )
442 + qt5-build_src_configure
443 +}
444 +
445 +src_install() {
446 + qt5-build_src_install
447 +
448 + local flags=(
449 + DBUS FREETYPE IMAGEFORMAT_JPEG IMAGEFORMAT_PNG
450 + OPENGL OPENSSL SSL WIDGETS
451 + )
452 +
453 + for flag in ${flags[@]}; do
454 + cat >> "${D}"/${QT5_HEADERDIR}/QtCore/qconfig.h <<- _EOF_ || die
455 +
456 + #if defined(QT_NO_${flag}) && defined(QT_${flag})
457 + # undef QT_NO_${flag}
458 + #elif !defined(QT_NO_${flag}) && !defined(QT_${flag})
459 + # define QT_NO_${flag}
460 + #endif
461 + _EOF_
462 + done
463 +}