busybox.scm 6.6 KB

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