heads.scm 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (gnu packages heads)
  19. #:use-module ((guix licenses) #:prefix license:)
  20. #:use-module (guix build-system gnu)
  21. #:use-module (guix build-system trivial)
  22. #:use-module (guix packages)
  23. #:use-module (guix download)
  24. #:use-module (guix git-download)
  25. #:use-module (guix utils)
  26. #:use-module (gnu packages)
  27. #:use-module (gnu packages admin)
  28. #:use-module (gnu packages algebra)
  29. #:use-module (gnu packages assembly)
  30. #:use-module (gnu packages autotools)
  31. #:use-module (gnu packages base)
  32. #:use-module (gnu packages bash)
  33. #:use-module (gnu packages compression)
  34. #:use-module (gnu packages flex)
  35. #:use-module (gnu packages bison)
  36. #:use-module (gnu packages elf)
  37. #:use-module (gnu packages m4)
  38. #:use-module (gnu packages curl)
  39. #:use-module (gnu packages linux)
  40. #:use-module (gnu packages multiprecision)
  41. #:use-module (gnu packages python)
  42. #:use-module (gnu packages cpio)
  43. #:use-module (gnu packages file)
  44. #:use-module (gnu packages perl)
  45. #:use-module (gnu packages version-control)
  46. #:use-module (gnu packages virtualization)
  47. #:use-module ((guix build utils) #:select (alist-replace)))
  48. (define-public musl-cross
  49. (let ((revision "3")
  50. (commit "a8a66490dae7f23a2cf5e256f3a596d1ccfe1a03"))
  51. (package
  52. (name "musl-cross")
  53. (version (git-version "0.1" revision commit))
  54. (source
  55. (origin
  56. (method git-fetch)
  57. (uri (git-reference
  58. (url "https://github.com/GregorR/musl-cross")
  59. (commit commit)))
  60. (file-name "musl-cross-checkout")
  61. (sha256
  62. (base32
  63. "1xvl9y017wb2qaphy9zqh3vrhm8hklr8acvzzcjc35d1jjhyl58y"))
  64. (patches (search-patches "musl-cross-locale.patch"))))
  65. (build-system gnu-build-system)
  66. (arguments
  67. `(#:tests? #f ; No tests in main project.
  68. #:modules
  69. ((guix build utils)
  70. (guix build gnu-build-system)
  71. (srfi srfi-1)) ; drop
  72. #:phases
  73. (modify-phases %standard-phases
  74. (replace 'configure
  75. (lambda _
  76. (setenv "SHELL" "bash")
  77. (setenv "CONFIG_SHELL" "bash")
  78. #t))
  79. (add-after 'unpack 'unpack-dependencies
  80. (lambda* (#:key inputs outputs #:allow-other-keys)
  81. (define (install-file* source-key destination-directory
  82. destination-suffix)
  83. (let* ((source-file (assoc-ref inputs source-key))
  84. (source-basename (basename source-file))
  85. (source-parts (string-split source-basename #\-))
  86. (destination-file
  87. (string-join (drop source-parts 1) "-")))
  88. (copy-file source-file
  89. (string-append destination-directory "/"
  90. destination-file destination-suffix))))
  91. (for-each (lambda (name)
  92. (install-file* name "tarballs" ""))
  93. '("binutils" "target-gcc-5" "linux-headers" "musl"))
  94. (copy-file (string-append (assoc-ref inputs "config.sub")
  95. "/share/automake-1.16/config.sub")
  96. "tarballs/config.sub;hb=3d5db9ebe860")
  97. (copy-file (string-append (assoc-ref inputs "config.sub")
  98. "/share/automake-1.16/config.guess")
  99. "tarballs/config.guess;hb=3d5db9ebe860")
  100. (substitute* "config.sh"
  101. (("^CC_BASE_PREFIX=.*")
  102. (string-append "CC_BASE_PREFIX=" (assoc-ref outputs "out")
  103. "/crossgcc\n")))
  104. ;; Note: Important: source/gcc-5.3.0/gcc/exec-tool.in
  105. ;; Note: Important: source/kernel-headers-3.12.6-5/tools/install.sh
  106. ;; Note: Important: move-if-change (twice)
  107. ;; Make sure that shebangs are patched after new extractions.
  108. (substitute* "defs.sh"
  109. (("touch \"[$]2/extracted\"")
  110. (string-append "touch \"$2/extracted\"
  111. for s in mkinstalldirs move-if-change compile depcomp callprocs configure \\
  112. mkdep compile libtool-ldflags config.guess install-sh missing config.sub \\
  113. config.rpath progtest.m4 lib-ld.m4 acx.m4 gen-fixed.sh mkheader.sh ylwrap \\
  114. merge.sh godeps.sh lock-and-run.sh print-sysroot-suffix.sh mkconfig.sh \\
  115. genmultilib exec-tool.in install.sh
  116. do
  117. find . -name $s -exec sed -i -e 's;!/bin/sh;!" (assoc-ref inputs "bash")
  118. "/bin/sh;' '{}' ';'
  119. find . -name $s -exec sed -i -e 's; /bin/sh; " (assoc-ref inputs "bash")
  120. "/bin/sh;' '{}' ';'
  121. done
  122. " )))
  123. #t))
  124. (replace 'build
  125. (lambda* (#:key outputs #:allow-other-keys)
  126. (invoke "./build.sh")))
  127. (delete 'install))))
  128. (native-inputs
  129. `(("config.sub" ,automake)
  130. ("bash" ,bash)
  131. ("flex" ,flex)
  132. ("gmp" ,gmp)
  133. ("mpfr" ,mpfr)
  134. ("mpc" ,mpc)
  135. ("binutils"
  136. ,(origin
  137. (method url-fetch)
  138. (uri "https://ftpmirror.gnu.org/gnu/binutils/binutils-2.27.tar.bz2")
  139. (sha256
  140. (base32 "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"))))
  141. ("target-gcc-5"
  142. ,(origin
  143. (method url-fetch)
  144. (uri "https://ftpmirror.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2")
  145. (sha256
  146. (base32 "1ny4smkp5bzs3cp8ss7pl6lk8yss0d9m4av1mvdp72r1x695akxq"))))
  147. ("linux-headers"
  148. ,(origin
  149. (method url-fetch)
  150. (uri "http://ftp.barfooze.de/pub/sabotage/tarballs/linux-headers-4.19.88.tar.xz")
  151. (sha256
  152. (base32 "1srgi2nqw892jb6yd4kzacf2xzwfvzhsv2957xfh1nvbs7varwyk"))))
  153. ("musl"
  154. ,(origin
  155. (method url-fetch)
  156. (uri "http://www.musl-libc.org/releases/musl-1.1.24.tar.gz")
  157. (sha256
  158. (base32 "18r2a00k82hz0mqdvgm7crzc7305l36109c0j9yjmkxj2alcjw0k"))))))
  159. (home-page "https://github.com/osresearch/heads")
  160. (synopsis "Musl-cross gcc 5 toolchain")
  161. (description "Musl-cross toolchain: binutils, gcc 5 and musl.")
  162. (license license:isc))))
  163. ;; This package provides a "dev.cpio" file usable as a base for booting Heads.
  164. (define-public heads-dev-cpio
  165. (package
  166. (name "heads-dev-cpio")
  167. (version "0.1")
  168. (source #f)
  169. (build-system trivial-build-system)
  170. (arguments
  171. `(#:modules ((guix build utils)
  172. (guix cpio))
  173. #:builder (begin
  174. (use-modules (guix build utils)
  175. (guix cpio)
  176. (srfi srfi-26))
  177. (mkdir-p "dev") ; input directory.
  178. (let* ((out (assoc-ref %outputs "out"))
  179. (libexec (string-append out "/libexec")))
  180. (mkdir-p libexec)
  181. (call-with-output-file (string-append libexec "/dev.cpio")
  182. (lambda (port)
  183. (write-cpio-archive '("dev" "dev/console") port
  184. #:file->header
  185. (lambda (name)
  186. (if (string=? "dev/console" name)
  187. (special-file->cpio-header* name 'char-special 5 1 #o600)
  188. (file->cpio-header* name))))))
  189. #t))))
  190. (synopsis "@file{dev.cpio} for Heads")
  191. (description "This package provides a @file{dev.cpio} file usable as a
  192. base for heads' initrd.")
  193. (home-page "https://osresearch.net/")
  194. (license license:bsd-2)))