gnu: Add itpp.
[jackhill/guix/guix.git] / gnu / packages / make-bootstrap.scm
index 85dfaa6..e5c614c 100644 (file)
@@ -23,7 +23,6 @@
   #:use-module (guix build-system trivial)
   #:use-module (guix build-system gnu)
   #:use-module ((gnu packages) #:select (search-patch))
-  #:use-module ((gnu packages commencement) #:select (%final-inputs))
   #:use-module (gnu packages base)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages bash)
@@ -33,6 +32,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -101,22 +101,19 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                                           (cross-binutils target)
                                           (cross-bootstrap-libc)))
             ("cross-binutils" ,(cross-binutils target))
-            ,@%final-inputs))
+            ,@(%final-inputs)))
         `(("libc" ,(glibc-for-bootstrap))
           ("gcc" ,(package (inherit gcc)
                     (outputs '("out")) ; all in one so libgcc_s is easily found
                     (inputs
                      `(("libc",(glibc-for-bootstrap))
                        ,@(package-inputs gcc)))))
-          ,@(fold alist-delete %final-inputs '("libc" "gcc")))))
+          ,@(fold alist-delete (%final-inputs) '("libc" "gcc")))))
 
   (package-with-explicit-inputs p inputs
                                 (current-source-location)
                                 #:native-inputs native-inputs))
 
-(define %bash-static
-  (static-package bash-minimal))
-
 (define %static-inputs
   ;; Packages that are to be used as %BOOTSTRAP-INPUTS.
   (let ((coreutils (package (inherit coreutils)
@@ -184,8 +181,19 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                               (("-Wl,-export-dynamic") "")))
                           ,phases)))))
                 (inputs (if (%current-target-system)
-                            `(("bash" ,%bash-static))
+                            `(("bash" ,static-bash))
                             '()))))
+       (tar (package (inherit tar)
+              (arguments
+               '(#:phases (modify-phases %standard-phases
+                            (add-before 'build 'set-shell-file-name
+                              (lambda _
+                                ;; Do not use "/bin/sh" to run programs; see
+                                 ;; <http://lists.gnu.org/archive/html/guix-devel/2016-09/msg02272.html>.
+                                (substitute* "src/system.c"
+                                  (("/bin/sh") "sh")
+                                  (("execv ") "execvp "))
+                                #t)))))))
         (finalize (compose static-package
                            package-with-relocatable-glibc)))
     `(,@(map (match-lambda
@@ -200,7 +208,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                ("sed" ,sed)
                ("grep" ,grep)
                ("gawk" ,gawk)))
-      ("bash" ,%bash-static))))
+      ("bash" ,static-bash))))
 
 (define %static-binaries
   (package
@@ -325,7 +333,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
@@ -334,52 +342,26 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "linux-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("linux-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -515,6 +497,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                     (patches patches)))
          (guile (package (inherit guile-2.0)
                   (name (string-append (package-name guile-2.0) "-static"))
+                  (replacement #f)
                   (source source)
                   (synopsis "Statically-linked and relocatable Guile")
 
@@ -639,9 +622,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -681,7 +664,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis "Tarballs containing all the bootstrap binaries")
     (description synopsis)