1From e52c323bf63319aefe6b91f712b52dc69591f30c Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 8 Oct 2021 16:39:52 +0800
4Subject: [PATCH 27/28] HACK: qmake: Workaround installation race of
5 qtdeclarative qmltypes
6
7When doing in-place building, the generated qtdeclarative's
8plugins.qmltypes might be installed from qtbase's qml2build and
9qtdeclarative's install_qmltypes stages.
10
11That would cause a parallel installation race which might lead to:
12Error copying xxx/plugins.qmltypes to xxx/plugins.qmltypes: Destination file exists
13
14Let's workaround it by simply adding a few retries.
15
16Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
17---
18 qmake/main.cpp | 5 +++++
19 1 file changed, 5 insertions(+)
20
21diff --git a/qmake/main.cpp b/qmake/main.cpp
22index 15b1b23f..01c4e6f0 100644
23--- a/qmake/main.cpp
24+++ b/qmake/main.cpp
25@@ -289,6 +289,11 @@ static int installFile(const QString &source, const QString &target, bool exe =
26         QDir::root().mkpath(QFileInfo(target).absolutePath());
27     }
28
29+    /* HACK: Workaround installation race of qtdeclarative's qmltypes */
30+    if (!sourceFile.copy(target))
31+        /* Wait for other installers and retry later */
32+        if (({ sleep(10); QFile::remove(target); !sourceFile.copy(target); }))
33+
34     if (!sourceFile.copy(target)) {
35         fprintf(stderr, "Error copying %s to %s: %s\n", source.toLatin1().constData(), qPrintable(target), qPrintable(sourceFile.errorString()));
36         return 3;
37--
382.20.1
39
40