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