projects/guix·blob javascript-team · refs

181 lines · 8.0 KiB

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