gnu: make-bootstrap: Abstract things with `package-with-relocatable-glibc'.

* gnu/packages/make-bootstrap.scm (%glibc-for-bootstrap): Replace with...
  (glibc-for-bootstrap): ... this.  New procedure.
  (%standard-inputs-with-relocatable-glibc): Replace with...
  (package-with-relocatable-glibc): ... this.  New procedure.
  (%static-inputs, %gcc-static, %guile-static): Use it.
master
Ludovic Courtès 2013-06-14 15:29:08 +02:00
parent af5cb60fec
commit 62751a5ddd
1 changed files with 83 additions and 83 deletions

View File

@ -49,33 +49,39 @@
;;; ;;;
;;; Code: ;;; Code:
(define %glibc-for-bootstrap (define* (glibc-for-bootstrap #:optional (base glibc-final))
;; A libc whose `system' and `popen' functions looks for `sh' in $PATH, "Return a libc deriving from BASE whose `system' and `popen' functions looks
;; without nscd, and with static NSS modules. for `sh' in $PATH, and without nscd, and with static NSS modules."
(package (inherit glibc-final) (package (inherit base)
(arguments (arguments
(substitute-keyword-arguments (package-arguments glibc-final) (substitute-keyword-arguments (package-arguments base)
((#:patches patches) ((#:patches patches)
`(cons (assoc-ref %build-inputs "patch/system") ,patches)) `(cons (assoc-ref %build-inputs "patch/system") ,patches))
((#:configure-flags flags) ((#:configure-flags flags)
;; Arrange so that getaddrinfo & co. do not contact the nscd, ;; Arrange so that getaddrinfo & co. do not contact the nscd,
;; and can use statically-linked NSS modules. ;; and can use statically-linked NSS modules.
`(cons* "--disable-nscd" "--disable-build-nscd" `(cons* "--disable-nscd" "--disable-build-nscd"
"--enable-static-nss" "--enable-static-nss"
,flags)))) ,flags))))
(inputs (inputs
`(("patch/system" ,(search-patch "glibc-bootstrap-system.patch")) `(("patch/system" ,(search-patch "glibc-bootstrap-system.patch"))
,@(package-inputs glibc-final))))) ,@(package-inputs base)))))
(define %standard-inputs-with-relocatable-glibc (define (package-with-relocatable-glibc p)
;; Standard inputs with the above libc and corresponding GCC. "Return a variant of P that uses the libc as defined by
`(("libc", %glibc-for-bootstrap) `glibc-for-bootstrap'."
("gcc" ,(package-with-explicit-inputs
gcc-4.7 (define inputs
`(("libc",%glibc-for-bootstrap) `(("libc", (glibc-for-bootstrap))
,@(alist-delete "libc" %final-inputs)) ("gcc" ,(package-with-explicit-inputs
(current-source-location))) gcc-4.7
,@(fold alist-delete %final-inputs '("libc" "gcc")))) `(("libc",(glibc-for-bootstrap))
,@(alist-delete "libc" %final-inputs))
(current-source-location)))
,@(fold alist-delete %final-inputs '("libc" "gcc"))))
(package-with-explicit-inputs p inputs
(current-source-location)))
(define %bash-static (define %bash-static
(static-package bash-light)) (static-package bash-light))
@ -135,11 +141,8 @@
(("-export-dynamic") ""))) (("-export-dynamic") "")))
,phases))))) ,phases)))))
(inputs `(("patch/sh" ,(search-patch "gawk-shell.patch")))))) (inputs `(("patch/sh" ,(search-patch "gawk-shell.patch"))))))
(finalize (lambda (p) (finalize (compose static-package
(static-package (package-with-explicit-inputs package-with-relocatable-glibc)))
p
%standard-inputs-with-relocatable-glibc)
(current-source-location)))))
`(,@(map (match-lambda `(,@(map (match-lambda
((name package) ((name package)
(list name (finalize package)))) (list name (finalize package))))
@ -284,7 +287,7 @@
;; GNU libc's essential shared libraries, dynamic linker, and headers, ;; GNU libc's essential shared libraries, dynamic linker, and headers,
;; with all references to store directories stripped. As a result, ;; with all references to store directories stripped. As a result,
;; libc.so is unusable and need to be patched for proper relocation. ;; libc.so is unusable and need to be patched for proper relocation.
(let ((glibc %glibc-for-bootstrap)) (let ((glibc (glibc-for-bootstrap)))
(package (inherit glibc) (package (inherit glibc)
(name "glibc-stripped") (name "glibc-stripped")
(build-system trivial-build-system) (build-system trivial-build-system)
@ -335,7 +338,7 @@
(define %gcc-static (define %gcc-static
;; A statically-linked GCC, with stripped-down functionality. ;; A statically-linked GCC, with stripped-down functionality.
(package-with-explicit-inputs (package-with-relocatable-glibc
(package (inherit gcc-final) (package (inherit gcc-final)
(name "gcc-static") (name "gcc-static")
(arguments (arguments
@ -362,11 +365,10 @@
((#:make-flags flags) ((#:make-flags flags)
`(cons "BOOT_LDFLAGS=-static" ,flags))))) `(cons "BOOT_LDFLAGS=-static" ,flags)))))
(inputs `(("gmp-source" ,(package-source gmp)) (inputs `(("gmp-source" ,(package-source gmp))
("mpfr-source" ,(package-source mpfr)) ("mpfr-source" ,(package-source mpfr))
("mpc-source" ,(package-source mpc)) ("mpc-source" ,(package-source mpc))
("binutils" ,binutils-final) ("binutils" ,binutils-final)
,@(package-inputs gcc-4.7)))) ,@(package-inputs gcc-4.7))))))
%standard-inputs-with-relocatable-glibc))
(define %gcc-stripped (define %gcc-stripped
;; The subset of GCC files needed for bootstrap. ;; The subset of GCC files needed for bootstrap.
@ -409,60 +411,58 @@
;; .scm and .go files relative to its installation directory, rather ;; .scm and .go files relative to its installation directory, rather
;; than in hard-coded configure-time paths. ;; than in hard-coded configure-time paths.
(let* ((libgc (package (inherit libgc) (let* ((libgc (package (inherit libgc)
(arguments (arguments
;; Make it so that we don't rely on /proc. This is ;; Make it so that we don't rely on /proc. This is
;; especially useful in an initrd run before /proc is ;; especially useful in an initrd run before /proc is
;; mounted. ;; mounted.
'(#:configure-flags '("CPPFLAGS=-DUSE_LIBC_PRIVATES"))))) '(#:configure-flags '("CPPFLAGS=-DUSE_LIBC_PRIVATES")))))
(guile (package (inherit guile-2.0) (guile (package (inherit guile-2.0)
(name (string-append (package-name guile-2.0) "-static")) (name (string-append (package-name guile-2.0) "-static"))
(inputs (inputs
`(("patch/relocatable" `(("patch/relocatable"
,(search-patch "guile-relocatable.patch")) ,(search-patch "guile-relocatable.patch"))
("patch/utf8" ("patch/utf8"
,(search-patch "guile-default-utf8.patch")) ,(search-patch "guile-default-utf8.patch"))
("patch/syscalls" ("patch/syscalls"
,(search-patch "guile-linux-syscalls.patch")) ,(search-patch "guile-linux-syscalls.patch"))
,@(package-inputs guile-2.0))) ,@(package-inputs guile-2.0)))
(propagated-inputs (propagated-inputs
`(("bdw-gc" ,libgc) `(("bdw-gc" ,libgc)
,@(alist-delete "bdw-gc" ,@(alist-delete "bdw-gc"
(package-propagated-inputs guile-2.0)))) (package-propagated-inputs guile-2.0))))
(arguments (arguments
`(;; When `configure' checks for ltdl availability, it `(;; When `configure' checks for ltdl availability, it
;; doesn't try to link using libtool, and thus fails ;; doesn't try to link using libtool, and thus fails
;; because of a missing -ldl. Work around that. ;; because of a missing -ldl. Work around that.
#:configure-flags '("LDFLAGS=-ldl") #:configure-flags '("LDFLAGS=-ldl")
#:phases (alist-cons-before #:phases (alist-cons-before
'configure 'static-guile 'configure 'static-guile
(lambda _ (lambda _
(substitute* "libguile/Makefile.in" (substitute* "libguile/Makefile.in"
;; Create a statically-linked `guile' ;; Create a statically-linked `guile'
;; executable. ;; executable.
(("^guile_LDFLAGS =") (("^guile_LDFLAGS =")
"guile_LDFLAGS = -all-static") "guile_LDFLAGS = -all-static")
;; Add `-ldl' *after* libguile-2.0.la. ;; Add `-ldl' *after* libguile-2.0.la.
(("^guile_LDADD =(.*)$" _ ldadd) (("^guile_LDADD =(.*)$" _ ldadd)
(string-append "guile_LDADD = " (string-append "guile_LDADD = "
(string-trim-right ldadd) (string-trim-right ldadd)
" -ldl\n")))) " -ldl\n"))))
%standard-phases) %standard-phases)
;; Allow Guile to be relocated, as is needed during ;; Allow Guile to be relocated, as is needed during
;; bootstrap. ;; bootstrap.
#:patches #:patches
(list (assoc-ref %build-inputs "patch/relocatable") (list (assoc-ref %build-inputs "patch/relocatable")
(assoc-ref %build-inputs "patch/utf8") (assoc-ref %build-inputs "patch/utf8")
(assoc-ref %build-inputs "patch/syscalls")) (assoc-ref %build-inputs "patch/syscalls"))
;; There are uses of `dynamic-link' in ;; There are uses of `dynamic-link' in
;; {foreign,coverage}.test that don't fly here. ;; {foreign,coverage}.test that don't fly here.
#:tests? #f))))) #:tests? #f)))))
(package-with-explicit-inputs (static-package guile) (package-with-relocatable-glibc (static-package guile))))
%standard-inputs-with-relocatable-glibc
(current-source-location))))
(define %guile-static-stripped (define %guile-static-stripped
;; A stripped static Guile binary, for use during bootstrap. ;; A stripped static Guile binary, for use during bootstrap.