From 4c93fe83e89473b2d16b93900c87e0da0ceecd6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 3 Nov 2016 11:24:39 +0100
Subject: [PATCH] gnu: mesa: Apply MIPS patch conditionally.

Fixes <http://bugs.gnu.org/24833>.
Reported by Mark H Weaver <mhw@netris.org>.

* gnu/packages/gl.scm (mesa)[source](patches): Remove.
[native-inputs]: Add conditional "mips-patch" input.
[arguments]: Add conditional 'apply-mips-patch' phase.
---
 gnu/packages/gl.scm | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index 07e490d58bd..50b474c623a 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -204,15 +204,7 @@ (define-public mesa
                             version "/mesa-" version ".tar.xz"))
         (sha256
          (base32
-          "12b3i59xdn2in2hchrkgh4fwij8zhznibx976l3pdj3qkyvlzcms"))
-        (patches
-         ;; XXX To prevent a large number of rebuilds on other systems,
-         ;; apply the following patch on MIPS systems only.  In the next
-         ;; core-updates cycle, this patch could be applied on all platforms.
-         (if (string-prefix? "mips" (or (%current-target-system)
-                                        (%current-system)))
-             (search-patches "mesa-wayland-egl-symbols-check-mips.patch")
-             '()))))
+          "12b3i59xdn2in2hchrkgh4fwij8zhznibx976l3pdj3qkyvlzcms"))))
     (build-system gnu-build-system)
     (propagated-inputs
       `(("glproto" ,glproto)
@@ -239,7 +231,16 @@ (define-public mesa
         ("wayland" ,wayland)))
     (native-inputs
       `(("pkg-config" ,pkg-config)
-        ("python" ,python-2)))
+        ("python" ,python-2)
+
+         ;; XXX To prevent a large number of rebuilds on other systems,
+         ;; apply the following patch on MIPS systems only.  In the next
+         ;; core-updates cycle, this patch could be applied on all platforms.
+        ,@(if (string-prefix? "mips" (or (%current-target-system)
+                                         (%current-system)))
+              `(("mips-patch"
+                 ,(search-patch "mesa-wayland-egl-symbols-check-mips.patch")))
+              '())))
     (arguments
      `(#:configure-flags
        '(;; drop r300 from default gallium drivers, as it requires llvm
@@ -266,6 +267,16 @@ (define-public mesa
               '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
        #:phases
        (modify-phases %standard-phases
+         ;; Add an 'apply-mips-patch' phase conditionally (see above.)
+         ,@(if (string-prefix? "mips" (or (%current-target-system)
+                                          (%current-system)))
+               `((add-after 'unpack 'apply-mips-patch
+                   (lambda* (#:key inputs #:allow-other-keys)
+                     (let ((patch (assoc-ref inputs "mips-patch")))
+                       (zero? (system* "patch" "-p1" "--force"
+                                       "--input" patch))))))
+               '())
+
          (add-after
            'unpack 'patch-create_test_cases
            (lambda _
-- 
GitLab