From 840e43f6aea0ea82769ed0a1cd27cdef8888aa68 Mon Sep 17 00:00:00 2001
From: Johan Klokkhammer Helsing <johan.helsing@qt.io>
Date: Mon, 26 Mar 2018 17:05:05 +0200
Subject: [PATCH] Split cloning and checkout into two

---
 Dockerfile             |  4 ++++
 scripts/checkout-qt.sh | 14 ++++++++++++++
 scripts/run.sh         |  6 ++++--
 3 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100755 scripts/checkout-qt.sh

diff --git a/Dockerfile b/Dockerfile
index ce50d46..67057af 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,5 +29,9 @@ ENV XDG_RUNTIME_DIR=/tmp
 ENV QT_QPA_PLATFORM=wayland
 ENV MAKEFLAGS=-j8
 
+# Keep Qt source code as part of the image to avoid duplication
+COPY scripts/clone-qt.sh /home/build/scripts/clone-qt.sh
+RUN scripts/clone-qt.sh
+
 COPY scripts/ /home/build/scripts
 CMD "./scripts/run.sh"
diff --git a/scripts/checkout-qt.sh b/scripts/checkout-qt.sh
new file mode 100755
index 0000000..6d14317
--- /dev/null
+++ b/scripts/checkout-qt.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+set -ex
+srcdir=$(pwd)/qt5
+qt5_rev=${QT_DOCKERTEST_QT5_REV:-5.11}
+
+git fetch --depth 1 origin "$qt5_rev"
+git checkout FETCH_HEAD
+git submodule update --init -- qtbase qtxmlpatterns qtdeclarative qtwayland
+
+if [[ -v QT_DOCKERTEST_QTWAYLAND_REV ]] ; then
+    cd "$srcdir/qtwayland"
+    git fetch --depth 1 origin "$QT_DOCKERTEST_QTWAYLAND_REV"
+    git checkout FETCH_HEAD
+fi
diff --git a/scripts/run.sh b/scripts/run.sh
index 15cfbb7..7c86b7b 100755
--- a/scripts/run.sh
+++ b/scripts/run.sh
@@ -1,7 +1,9 @@
 #!/bin/bash
 set -ex
-time scripts/clone-qt.sh
-echo Finished cloning
+#time scripts/clone-qt.sh
+#echo Finished cloning
+time scripts/update-qt.sh
+echo Finished preparing sources
 time scripts/build-qt.sh
 echo Finished building
 time scripts/build-qtbase-tests.sh
-- 
GitLab