gnu: busybox: Fix cross-compilation.

* gnu/packages/busybox.scm (busybox)[arguments]: Switch to gexps.
Honor #:tests? in 'check' phase.  Add #:make-flags.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Lu Hui 2022-09-16 18:34:59 +08:00 committed by Ludovic Courtès
parent 75e7c09461
commit e5fc55493d
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -2,6 +2,7 @@
;;; Copyright © 2014 John Darrington <jmd@gnu.org> ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 20182022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 20182022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2022 LuHui <luhux76@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -45,66 +46,74 @@
"0jfm9fik7nv4w21zqdg830pddgkdjmplmna9yjn9ck1lwn4vsps1")))) "0jfm9fik7nv4w21zqdg830pddgkdjmplmna9yjn9ck1lwn4vsps1"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
'(#:phases (list #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-before 'configure 'disable-timestamps (add-before 'configure 'disable-timestamps
(lambda _ (lambda _
(setenv "KCONFIG_NOTIMESTAMP" "1"))) (setenv "KCONFIG_NOTIMESTAMP" "1")))
(add-before 'configure 'disable-taskset (add-before 'configure 'disable-taskset
;; This feature fails its tests in the build environment, ;; This feature fails its tests in the build environment,
;; was default 'n' until after 1.26.2. ;; was default 'n' until after 1.26.2.
(lambda _ (lambda _
(substitute* "util-linux/taskset.c" (substitute* "util-linux/taskset.c"
(("default y") "default n")))) (("default y") "default n"))))
(replace 'configure (replace 'configure
(lambda* (#:key make-flags #:allow-other-keys) (lambda* (#:key make-flags #:allow-other-keys)
(apply invoke "make" "defconfig" make-flags))) (apply invoke "make" "defconfig" make-flags)))
(add-after 'configure 'dont-install-to-usr (add-after 'configure 'dont-install-to-usr
(lambda _ (lambda _
(substitute* ".config" (substitute* ".config"
(("# CONFIG_INSTALL_NO_USR is not set") (("# CONFIG_INSTALL_NO_USR is not set")
"CONFIG_INSTALL_NO_USR=y")))) "CONFIG_INSTALL_NO_USR=y"))))
(replace 'check (replace 'check
(lambda* (#:key make-flags #:allow-other-keys) (lambda* (#:key tests? make-flags #:allow-other-keys)
(substitute* '("testsuite/du/du-s-works" (substitute* '("testsuite/du/du-s-works"
"testsuite/du/du-works") "testsuite/du/du-works")
(("/bin") "/etc")) ; there is no /bin but there is a /etc (("/bin") "/etc")) ; there is no /bin but there is a /etc
;; There is no /usr/bin or /bin - replace it with /gnu/store ;; There is no /usr/bin or /bin - replace it with
(substitute* "testsuite/cpio.tests" ;; /gnu/store.
(("/usr/bin") (%store-directory)) (substitute* "testsuite/cpio.tests"
(("usr") (car (filter (negate string-null?) (("/usr/bin") (%store-directory))
(string-split (%store-directory) #\/))))) (("usr") (car (filter (negate string-null?)
(string-split (%store-directory) #\/)))))
(substitute* "testsuite/date/date-works-1" (substitute* "testsuite/date/date-works-1"
(("/bin/date") (which "date"))) (("/bin/date") (which "date")))
(substitute* "testsuite/start-stop-daemon.tests" (substitute* "testsuite/start-stop-daemon.tests"
(("/bin/false") (which "false"))) (("/bin/false") (which "false")))
;; The pidof tests assume that pid 1 is called "init" but that is not ;; The pidof tests assume that pid 1 is called "init" but
;; true in guix build environment ;; that is not true in guix build environment
(substitute* "testsuite/pidof.tests" (substitute* "testsuite/pidof.tests"
(("-s init") "-s $(cat /proc/1/comm)")) (("-s init") "-s $(cat /proc/1/comm)"))
;; This test cannot possibly pass. ;; This test cannot possibly pass. It is trying to test
;; It is trying to test that "which ls" returns "/bin/ls" when PATH is not set. ;; that "which ls" returns "/bin/ls" when PATH is not set.
;; However, this relies on /bin/ls existing. Which it does not in guix. ;; However, this relies on /bin/ls existing. Which it does
(delete-file "testsuite/which/which-uses-default-path") ;; not in guix.
(rmdir "testsuite/which") (delete-file "testsuite/which/which-uses-default-path")
(rmdir "testsuite/which")
(apply invoke "make" (when tests?
;; "V=1" (apply invoke "make"
"SKIP_KNOWN_BUGS=1" ;; "V=1"
"SKIP_INTERNET_TESTS=1" "SKIP_KNOWN_BUGS=1"
"check" make-flags))) "SKIP_INTERNET_TESTS=1"
(replace 'install "check" make-flags))))
(lambda* (#:key outputs make-flags #:allow-other-keys) (replace 'install
(let ((out (assoc-ref outputs "out"))) (lambda* (#:key outputs make-flags #:allow-other-keys)
(apply invoke "make" (let ((out (assoc-ref outputs "out")))
(string-append "CONFIG_PREFIX=" out) (apply invoke "make"
"install" make-flags))))))) (string-append "CONFIG_PREFIX=" out)
(native-inputs (list perl ; needed to generate the man pages (pod2man) "install" make-flags)))))
#:make-flags
#~(let ((target #$(%current-target-system)))
(if target
(list (string-append "CROSS_COMPILE=" target "-"))
'()))))
(native-inputs (list perl ; needed to generate the man pages (pod2man)
;; The following are needed by the tests. ;; The following are needed by the tests.
inetutils inetutils
(@ (gnu packages base) which) (@ (gnu packages base) which)