Subject: [PATCH 5/9] gnu: Use ‘current-target-nix-system’ in prefix checks

From: Thiago Jung Bauermann <[email-masked]>
Date: Tue, 20 Jul 2021 22:00:39 -0300

Some places check whether the system identifier starts with “<arch>-linux”,
which is a Nix system identifier. The GNU triplet identifier stored in
‘%current-target-system’ may not match the pattern if it includes a vendor
field.

Fix the problem by checking against ‘current-target-nix-system’, which
always returns a Nix system identifier.

* gnu/packages/bootloaders.scm (u-boot-tools)[arguments]<#:phases>: Use
‘current-target-nix-system’.
* gnu/packages/c.scm (tcc)[arguments]<#:configure-flags>: Likewise.
* gnu/packages/databases.scm (rocksdb)[arguments]<#:tests>: Likewise.
* gnu/packages/debug.scm (american-fuzzy-lop): Likewise.
(qemu-for-american-fuzzy-lop): Likewise.
* gnu/packages/golang.scm (go-1.4)[arguments]<#:system>: Likewise.
(go-1.14)[arguments]<#:system>: Likewise.
* gnu/packages/lisp.scm (clisp)[arguments]<#:configure-flags>: Likewise.
* gnu/packages/mes.scm (mes-0.19)[native-inputs]: Likewise.
---
 gnu/packages/bootloaders.scm | 4 +---
 gnu/packages/c.scm           | 3 +--
 gnu/packages/databases.scm   | 3 +--
 gnu/packages/debug.scm       | 6 ++----
 gnu/packages/golang.scm      | 6 ++----
 gnu/packages/lisp.scm        | 3 +--
 gnu/packages/mes.scm         | 3 +--
 7 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index be51fb0c3de4..669574468bd2 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -622,9 +622,7 @@ def test_ctrl_c"))
                (invoke "test/image/test-imagetools.sh")))
            ;; Only run full test suite on x86_64 systems, as many tests
            ;; assume x86_64.
-           ,@(if (string-match "^x86_64-linux"
-                               (or (%current-target-system)
-                                   (%current-system)))
+           ,@(if (string-match "^x86_64-linux" (current-target-nix-system))
                  '((add-after 'check 'check-x86
                      (lambda* (#:key make-flags test-target #:allow-other-keys)
                        (apply invoke "make" "mrproper" make-flags)
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index 1b9003ce09dd..f85bc2f4b6c9 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -88,8 +88,7 @@
                                               (assoc-ref %build-inputs "libc")
                                               "/lib")
                                ,@(if (string-prefix? "armhf-linux"
-                                                     (or (%current-target-system)
-                                                         (%current-system)))
+                                                     (current-target-nix-system))
                                      `("--triplet=arm-linux-gnueabihf")
                                      '()))
        #:test-target "test"))
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 7de85d10c148..14367bde82b5 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -1379,8 +1379,7 @@ including field and record folding.")))
        #:test-target "check_some"
        ;; Many tests fail on 32-bit platforms. There are multiple reports about
        ;; this upstream, but it's not going to be supported any time soon.
-       #:tests? (let ((system ,(or (%current-target-system)
-                                   (%current-system))))
+       #:tests? (let ((system ,(current-target-nix-system)))
                   (or (string-prefix? "x86_64-linux" system)
                       (string-prefix? "aarch64-linux" system)))
        #:phases
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 3a29886b0e40..c5fad64692ae 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -172,8 +172,7 @@ tools that process C/C++ code.")
     (license license:ncsa)))
 
 (define-public american-fuzzy-lop
-  (let ((machine (match (or (%current-target-system)
-                            (%current-system))
+  (let ((machine (match (current-target-nix-system)
                    ("x86_64-linux"   "x86_64")
                    ("i686-linux"     "i386")
                    ("aarch64-linux"  "aarch64")
@@ -248,8 +247,7 @@ down the road.")
 (define-public qemu-for-american-fuzzy-lop
   ;; afl only supports using a single afl-qemu-trace executable, so
   ;; we only build qemu for the native target.
-  (let ((machine (match (or (%current-target-system)
-                            (%current-system))
+  (let ((machine (match (current-target-nix-system)
                    ("x86_64-linux"   "x86_64")
                    ("i686-linux"     "i386")
                    ("aarch64-linux"  "aarch64")
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 58688687bba3..939dbc83ce71 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -1046,8 +1046,7 @@ your Go binary to be later served from an http.FileSystem.")
                   (guix build utils)
                   (srfi srfi-1))
        #:tests? #f ; Tests are run by the all.bash script.
-       ,@(if (string-prefix? "aarch64-linux" (or (%current-target-system)
-                                                 (%current-system)))
+       ,@(if (string-prefix? "aarch64-linux" (current-target-nix-system))
              '(#:system "armhf-linux")
              '())
        #:phases
@@ -1199,8 +1198,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")
     (arguments
      (substitute-keyword-arguments (package-arguments go-1.4)
        ((#:system system)
-        (if (string-prefix? "aarch64-linux" (or (%current-target-system)
-                                                (%current-system)))
+        (if (string-prefix? "aarch64-linux" (current-target-nix-system))
           "aarch64-linux"
           system))
        ((#:phases phases)
diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index ee43226ff091..6fd1cd55e009 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -347,8 +347,7 @@ supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
               ("libsigsegv" ,libsigsegv)))
     (arguments
      `(#:configure-flags '(,@(if (string-prefix? "armhf-linux"
-                                                 (or (%current-target-system)
-                                                     (%current-system)))
+                                                 (current-target-nix-system))
                                  '("CFLAGS=-falign-functions=4")
                                  '())
                             "--with-dynamic-ffi"
diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index c66751bc7c74..d4a8278697ca 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -174,8 +174,7 @@ parsers to allow execution with Guile as extension languages.")))
        ("nyacc" ,nyacc-0.86)))
     (native-inputs
      `(("guile" ,guile-2.2)
-       ,@(let ((target-system (or (%current-target-system)
-                                  (%current-system))))
+       ,@(let ((target-system (current-target-nix-system)))
            (cond
             ((string-prefix? "x86_64-linux" target-system)
              ;; Use cross-compiler rather than #:system "i686-linux" to get