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