Subject: [bug#57857] [PATCH] gnu: busybox: fix the cross build.

From: 路辉 <[email-masked]>
Date: Fri, 16 Sep 2022 12:35:04 +0000

From 17b77a70781dc5f0e2f54516748081e51da36a14 Mon Sep 17 00:00:00 2001
From: Lu Hui <[email-masked]>
Date: Fri, 16 Sep 2022 18:34:59 +0800
Subject: [PATCH] gnu: busybox: fix the cross build.

* gnu/packages/busybox.scm (busybox): fix cross build
---
 gnu/packages/busybox.scm | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/busybox.scm b/gnu/packages/busybox.scm
index 4468d71088..600e94f5b4 100644
--- a/gnu/packages/busybox.scm
+++ b/gnu/packages/busybox.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 John Darrington <[email-masked]>
 ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <[email-masked]>
+;;; Copyright © 2022 LuHui <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -45,8 +46,14 @@ (define-public busybox
                 "0jfm9fik7nv4w21zqdg830pddgkdjmplmna9yjn9ck1lwn4vsps1"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:phases
-       (modify-phases %standard-phases
+     `(#:tests? (if ,(%current-target-system) #f #t)
+       #:make-flags
+       (let ((target ,(%current-target-system)))
+         (if target
+             (list (string-append "CROSS_COMPILE=" target "-"))
+             (list)))
+      #:phases
+      (modify-phases %standard-phases
          (add-before 'configure 'disable-timestamps
            (lambda _
              (setenv "KCONFIG_NOTIMESTAMP" "1")))
@@ -65,7 +72,7 @@ (define-public busybox
                (("# CONFIG_INSTALL_NO_USR is not set")
                 "CONFIG_INSTALL_NO_USR=y"))))
          (replace 'check
-           (lambda* (#:key make-flags #:allow-other-keys)
+           (lambda* (#:key tests? make-flags #:allow-other-keys)
              (substitute* '("testsuite/du/du-s-works"
                             "testsuite/du/du-works")
                (("/bin") "/etc"))  ; there is no /bin but there is a /etc
@@ -93,11 +100,13 @@ (define-public busybox
              (delete-file "testsuite/which/which-uses-default-path")
              (rmdir "testsuite/which")
 
-             (apply invoke "make"
-                     ;; "V=1"
-                     "SKIP_KNOWN_BUGS=1"
-                     "SKIP_INTERNET_TESTS=1"
-                     "check" make-flags)))
+             (if tests?
+                 (apply invoke "make"
+                        ;; "V=1"
+                        "SKIP_KNOWN_BUGS=1"
+                        "SKIP_INTERNET_TESTS=1"
+                        "check" make-flags)
+                 #t)))
          (replace 'install
            (lambda* (#:key outputs make-flags #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
-- 
2.37.3