gnu: commencement: bash-mesboot0: Break store file-name in comment.
[jackhill/guix/guix.git] / gnu / packages / busybox.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages busybox)
22 #:use-module (guix licenses)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages admin)
28 #:use-module (gnu packages algebra)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages perl))
31
32 (define-public busybox
33 (package
34 (name "busybox")
35 (version "1.31.1")
36 (source (origin
37 (method url-fetch)
38 (uri (string-append
39 "https://www.busybox.net/downloads/" name "-"
40 version ".tar.bz2"))
41 (sha256
42 (base32
43 "1659aabzp8w4hayr4z8kcpbk2z1q2wqhw7i1yb0l72b45ykl1yfh"))
44 (patches
45 (search-patches
46 "busybox-1.31.1-fix-build-with-glibc-2.31.patch"))))
47 (build-system gnu-build-system)
48 (arguments
49 '(#:phases
50 (modify-phases %standard-phases
51 (add-before 'configure 'disable-timestamps
52 (lambda _
53 (setenv "KCONFIG_NOTIMESTAMP" "1")
54 #t))
55 (add-before 'configure 'disable-taskset
56 ;; This feature fails its tests in the build environment,
57 ;; was default 'n' until after 1.26.2.
58 (lambda _
59 (substitute* "util-linux/taskset.c"
60 (("default y") "default n"))
61 #t))
62 (replace 'configure
63 (lambda* (#:key make-flags #:allow-other-keys)
64 (apply invoke "make" "defconfig" make-flags)))
65 (add-after 'configure 'dont-install-to-usr
66 (lambda _
67 (substitute* ".config"
68 (("# CONFIG_INSTALL_NO_USR is not set")
69 "CONFIG_INSTALL_NO_USR=y"))
70 #t))
71 (replace 'check
72 (lambda* (#:key make-flags #:allow-other-keys)
73 (substitute* '("testsuite/du/du-s-works"
74 "testsuite/du/du-works")
75 (("/bin") "/etc")) ; there is no /bin but there is a /etc
76
77 ;; There is no /usr/bin or /bin - replace it with /gnu/store
78 (substitute* "testsuite/cpio.tests"
79 (("/usr/bin") (%store-directory))
80 (("usr") (car (filter (negate string-null?)
81 (string-split (%store-directory) #\/)))))
82
83 (substitute* "testsuite/date/date-works-1"
84 (("/bin/date") (which "date")))
85
86 (substitute* "testsuite/start-stop-daemon.tests"
87 (("/bin/false") (which "false")))
88
89 ;; The pidof tests assume that pid 1 is called "init" but that is not
90 ;; true in guix build environment
91 (substitute* "testsuite/pidof.tests"
92 (("-s init") "-s $(cat /proc/1/comm)"))
93
94 ;; This test cannot possibly pass.
95 ;; It is trying to test that "which ls" returns "/bin/ls" when PATH is not set.
96 ;; However, this relies on /bin/ls existing. Which it does not in guix.
97 (delete-file "testsuite/which/which-uses-default-path")
98 (rmdir "testsuite/which")
99
100 (apply invoke "make"
101 ;; "V=1"
102 "SKIP_KNOWN_BUGS=1"
103 "SKIP_INTERNET_TESTS=1"
104 "check" make-flags)))
105 (replace 'install
106 (lambda* (#:key outputs make-flags #:allow-other-keys)
107 (let ((out (assoc-ref outputs "out")))
108 (apply invoke "make"
109 (string-append "CONFIG_PREFIX=" out)
110 "install" make-flags)))))))
111 (native-inputs `(("perl" ,perl) ; needed to generate the man pages (pod2man)
112 ;; The following are needed by the tests.
113 ("inetutils" ,inetutils)
114 ("which" ,(@ (gnu packages base) which))
115 ("zip" ,zip)))
116 (synopsis "Many common UNIX utilities in a single executable")
117 (description "BusyBox combines tiny versions of many common UNIX utilities
118 into a single small executable. It provides a fairly complete environment for
119 any small or embedded system.")
120 (home-page "https://www.busybox.net")
121 ;; Some files are gplv2+
122 (license gpl2)))
123
124 (define-public toybox
125 (package
126 (name "toybox")
127 (version "0.8.3")
128 (source (origin
129 (method url-fetch)
130 (uri (string-append
131 "https://landley.net/toybox/downloads/toybox-"
132 version ".tar.gz"))
133 (sha256
134 (base32
135 "00aw9d809wj1bqlb2fsssdgz7rj0363ya14py0gfdm0rkp98zcpa"))))
136 (build-system gnu-build-system)
137 (arguments
138 '(#:phases
139 (modify-phases %standard-phases
140 (add-before 'configure 'set-environment-variables
141 (lambda _
142 (setenv "CC" (which "gcc"))
143 (setenv "HOSTCC" (which "gcc"))
144 #t))
145 (replace 'configure
146 (lambda _ (invoke "make" "defconfig")))
147 (replace 'install
148 (lambda* (#:key outputs #:allow-other-keys)
149 (let ((out (assoc-ref outputs "out")))
150 (invoke "make"
151 (string-append "PREFIX=" out)
152 "install"))))
153 (add-after 'install 'remove-usr-directory
154 (lambda* (#:key outputs #:allow-other-keys)
155 (let ((out (assoc-ref outputs "out")))
156 (delete-file-recursively (string-append out "/usr"))
157 #t))))
158 #:test-target "tests"))
159 (native-inputs `(("bc" ,bc)))
160 (synopsis "Many common UNIX utilities in a single executable")
161 (description "ToyBox combines tiny versions of many common UNIX utilities
162 into a single small executable. It provides a fairly complete environment for
163 any small or embedded system.")
164 (home-page "https://landley.net/toybox/")
165 (license bsd-2)))