Subject: [PATCH 4/4] gnu: qtwebengine: separate substitution and configure phase

From: Mike Rosset <[email-masked]>
Date: Wed, 1 Jan 2020 08:03:55 -0800

* gnu/packages/qt.scm (qtwebengine)[phases]: This moves the store
  substitutions to a substitute-source phase. And now a set-env phase sets
  environment build variables.

  format is no longer used when substituting translations and data paths
---
 gnu/packages/qt.scm | 65 ++++++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index f4908d1f27..a4a039dc80 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -2034,17 +2034,15 @@ time Web content can be enhanced with native controls.")
   (package (inherit qtsvg)
     (name "qtwebengine")
     (version (package-version qtbase))
-    (source
-     (origin
-       (method url-fetch)
-       (uri
-        (string-append "https://download.qt.io/official_releases/qt/"
-                       (version-major+minor version) "/" version
-                       "/submodules/" name "-everywhere-src-"
-                       version ".tar.xz"))
-       (sha256
-        (base32
-         "08c60nh95m98mcqk444axs76xi6m9x0wvdxrzk9c2cxwqdbz59fa"))))
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://download.qt.io/official_releases/qt/"
+                                  (version-major+minor version) "/" version
+                                  "/submodules/" name "-everywhere-src-"
+                                  version ".tar.xz"))
+              (sha256
+               (base32
+                "08c60nh95m98mcqk444axs76xi6m9x0wvdxrzk9c2cxwqdbz59fa"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("bison" ,bison)
@@ -2107,29 +2105,36 @@ time Web content can be enhanced with native controls.")
      (substitute-keyword-arguments (package-arguments qtsvg)
        ((#:phases phases)
         `(modify-phases ,phases
-           (replace 'configure
+           (add-before 'configure 'substitue-source
              (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out"))
+                     (nss (assoc-ref inputs "nss"))
+                     (udev (assoc-ref inputs "udev")))
+                 ;; Qtwebengine is not installed into the same prefix as
+                 ;; qtbase. Some qtbase QTLibraryInfo constants will not
+                 ;; work. Replace with the full path to the qtwebengine
+                 ;; translations and locales in the store.
+                 (substitute* "src/core/web_engine_library_info.cpp"
+                   (("QLibraryInfo::location\\(QLibraryInfo::TranslationsPath\\)")
+                    (string-append "QLatin1String(\"" out "/share/qt5/translations\")"))
+                   (("QLibraryInfo::location\\(QLibraryInfo::DataPath\\)")
+                    (string-append "QLatin1String(\"" out "/share/qt5\")")))
+                 ;; Substitute full dynamic library path for nss
+                 (substitute* "src/3rdparty/chromium/crypto/nss_util.cc"
+                   (("libnssckbi.so")
+                    (string-append nss "/lib/nss/libnssckbi.so")))
+                 ;; Substitute full dynamic library path for udev
+                 (substitute* "src/3rdparty/chromium/device/udev_linux/udev1_loader.cc"
+                   (("libudev.so.1")
+                    (string-append udev "/lib/libudev.so.1"))))))
+           (add-before 'configure 'set-env
+             (lambda _
                ;; Avoids potential race conditions
                (setenv "PYTHONDONTWRITEBYTECODE" "1")
                ;; Make ninja build output less verbose
-               (setenv "NINJAFLAGS" "-k1")
-               ;; Qtwebengine is not installed into the same prefix as
-               ;; qtbase. Some qtbase QTLibraryInfo constants will not
-               ;; work. Replace with the full path to the qtwebengine
-               ;; translations and locales in the store.
-               (substitute* "src/core/web_engine_library_info.cpp"
-                 (("QLibraryInfo::location\\(QLibraryInfo::TranslationsPath\\)")
-                  (format #f "QLatin1String(\"~a\")" (string-append (assoc-ref outputs "out") "/share/qt5/translations")))
-                 (("QLibraryInfo::location\\(QLibraryInfo::DataPath\\)")
-                  (format #f "QLatin1String(\"~a\")" (string-append (assoc-ref outputs "out") "/share/qt5"))))
-               ;; Substitute full dynamic library path for nss
-               (substitute* "src/3rdparty/chromium/crypto/nss_util.cc"
-                 (("libnssckbi.so")
-                  (string-append (assoc-ref inputs "nss") "/lib/nss/libnssckbi.so")))
-               ;; Substitute full dynamic library path for udev
-               (substitute* "src/3rdparty/chromium/device/udev_linux/udev1_loader.cc"
-                 (("libudev.so.1")
-                  (string-append (assoc-ref inputs "udev") "/lib/libudev.so.1")))
+               (setenv "NINJAFLAGS" "-k1")))
+           (replace 'configure
+             (lambda _
                ;; Valid QT_BUILD_PARTS variables are:
                ;; libs tools tests examples demos docs translations
                (invoke "qmake" "QT_BUILD_PARTS = libs tools" "--"
-- 
2.24.1