gnu: icecat: Update to 78.10.0-guix0-preview1 [security fixes].
[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, 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018–2021 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 utils)
26 #:use-module (guix build-system gnu)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages admin)
29 #:use-module (gnu packages algebra)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages perl))
32
33 (define-public busybox
34 (package
35 (name "busybox")
36 (version "1.33.0")
37 (source (origin
38 (method url-fetch)
39 (uri (string-append
40 "https://www.busybox.net/downloads/" name "-"
41 version ".tar.bz2"))
42 (sha256
43 (base32
44 "1gcg7ggg79apdlp5qnrh9pbjl10fx30yn33p21kxqpm8j4f6hs6m"))
45 (patches (search-patches "busybox-CVE-2021-28831.patch"))))
46 (build-system gnu-build-system)
47 (arguments
48 '(#:phases
49 (modify-phases %standard-phases
50 (add-before 'configure 'disable-timestamps
51 (lambda _
52 (setenv "KCONFIG_NOTIMESTAMP" "1")
53 #t))
54 (add-before 'configure 'disable-taskset
55 ;; This feature fails its tests in the build environment,
56 ;; was default 'n' until after 1.26.2.
57 (lambda _
58 (substitute* "util-linux/taskset.c"
59 (("default y") "default n"))
60 #t))
61 (replace 'configure
62 (lambda* (#:key make-flags #:allow-other-keys)
63 (apply invoke "make" "defconfig" make-flags)))
64 (add-after 'configure 'dont-install-to-usr
65 (lambda _
66 (substitute* ".config"
67 (("# CONFIG_INSTALL_NO_USR is not set")
68 "CONFIG_INSTALL_NO_USR=y"))
69 #t))
70 (replace 'check
71 (lambda* (#:key make-flags #:allow-other-keys)
72 (substitute* '("testsuite/du/du-s-works"
73 "testsuite/du/du-works")
74 (("/bin") "/etc")) ; there is no /bin but there is a /etc
75
76 ;; There is no /usr/bin or /bin - replace it with /gnu/store
77 (substitute* "testsuite/cpio.tests"
78 (("/usr/bin") (%store-directory))
79 (("usr") (car (filter (negate string-null?)
80 (string-split (%store-directory) #\/)))))
81
82 (substitute* "testsuite/date/date-works-1"
83 (("/bin/date") (which "date")))
84
85 (substitute* "testsuite/start-stop-daemon.tests"
86 (("/bin/false") (which "false")))
87
88 ;; The pidof tests assume that pid 1 is called "init" but that is not
89 ;; true in guix build environment
90 (substitute* "testsuite/pidof.tests"
91 (("-s init") "-s $(cat /proc/1/comm)"))
92
93 ;; This test cannot possibly pass.
94 ;; It is trying to test that "which ls" returns "/bin/ls" when PATH is not set.
95 ;; However, this relies on /bin/ls existing. Which it does not in guix.
96 (delete-file "testsuite/which/which-uses-default-path")
97 (rmdir "testsuite/which")
98
99 (apply invoke "make"
100 ;; "V=1"
101 "SKIP_KNOWN_BUGS=1"
102 "SKIP_INTERNET_TESTS=1"
103 "check" make-flags)))
104 (replace 'install
105 (lambda* (#:key outputs make-flags #:allow-other-keys)
106 (let ((out (assoc-ref outputs "out")))
107 (apply invoke "make"
108 (string-append "CONFIG_PREFIX=" out)
109 "install" make-flags)))))))
110 (native-inputs `(("perl" ,perl) ; needed to generate the man pages (pod2man)
111 ;; The following are needed by the tests.
112 ("inetutils" ,inetutils)
113 ("which" ,(@ (gnu packages base) which))
114 ("zip" ,zip)))
115 (synopsis "Many common UNIX utilities in a single executable")
116 (description "BusyBox combines tiny versions of many common UNIX utilities
117 into a single small executable. It provides a fairly complete environment for
118 any small or embedded system.")
119 (home-page "https://www.busybox.net")
120 ;; Some files are gplv2+
121 (license gpl2)))
122
123 (define-public toybox
124 (package
125 (name "toybox")
126 (version "0.8.3")
127 (source (origin
128 (method url-fetch)
129 (uri (string-append
130 "https://landley.net/toybox/downloads/toybox-"
131 version ".tar.gz"))
132 (sha256
133 (base32
134 "00aw9d809wj1bqlb2fsssdgz7rj0363ya14py0gfdm0rkp98zcpa"))))
135 (build-system gnu-build-system)
136 (arguments
137 `(#:phases
138 (modify-phases %standard-phases
139 (add-before 'configure 'set-environment-variables
140 (lambda _
141 (setenv "CC" ,(cc-for-target))
142 (setenv "HOSTCC" (which "gcc"))
143 #t))
144 (replace 'configure
145 (lambda _ (invoke "make" "defconfig")))
146 (replace 'install
147 (lambda* (#:key outputs #:allow-other-keys)
148 (let ((out (assoc-ref outputs "out")))
149 (invoke "make"
150 (string-append "PREFIX=" out)
151 "install"))))
152 (add-after 'install 'remove-usr-directory
153 (lambda* (#:key outputs #:allow-other-keys)
154 (let ((out (assoc-ref outputs "out")))
155 (delete-file-recursively (string-append out "/usr"))
156 #t))))
157 #:test-target "tests"))
158 (native-inputs `(("bc" ,bc)))
159 (synopsis "Many common UNIX utilities in a single executable")
160 (description "ToyBox combines tiny versions of many common UNIX utilities
161 into a single small executable. It provides a fairly complete environment for
162 any small or embedded system.")
163 (home-page "https://landley.net/toybox/")
164 (license bsd-2)))