diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index fe9fbebcc..1026ee892 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -1026,7 +1026,10 @@ COREUTILS-FINAL vs. COREUTILS, etc." (union-build (assoc-ref %outputs "debug") (list (assoc-ref %build-inputs - "libc-debug"))))))) + "libc-debug"))) + (union-build (assoc-ref %outputs "static") + (list (assoc-ref %build-inputs + "libc-static"))))))) (native-search-paths (package-native-search-paths gcc)) (search-paths (package-search-paths gcc)) @@ -1038,7 +1041,7 @@ COREUTILS-FINAL vs. COREUTILS, etc." be installed in user profiles. This includes GCC, as well as libc (headers and binaries, plus debugging symbols in the 'debug' output), and Binutils.") (home-page "https://gcc.gnu.org/") - (outputs '("out" "debug")) + (outputs '("out" "debug" "static")) ;; The main raison d'être of this "meta-package" is (1) to conveniently ;; install everything that we need, and (2) to make sure ld-wrapper comes @@ -1047,7 +1050,8 @@ and binaries, plus debugging symbols in the 'debug' output), and Binutils.") ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper"))) ("binutils" ,binutils-final) ("libc" ,glibc-final) - ("libc-debug" ,glibc-final "debug"))))) + ("libc-debug" ,glibc-final "debug") + ("libc-static" ,glibc-final "static"))))) (define-public gcc-toolchain-4.8 (make-gcc-toolchain gcc-4.8)) diff --git a/guix/profiles.scm b/guix/profiles.scm index 95dc9746b..507a441f5 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -318,7 +318,7 @@ denoting a specific output of a package." (propagated-inputs #$(map entry->gexp deps)) (search-paths #$(map search-path-specification->sexp search-paths)))) - (($ name version output (? package? package) + (($ name version output package (deps ...) (search-paths ...)) #~(#$name #$version #$output (ungexp package (or output "out")) @@ -671,7 +671,9 @@ if not found." (return (find-among-inputs inputs))))) ((? string? item) (mlet %store-monad ((refs (references* item))) - (return (find-among-store-items refs))))))) + (return (find-among-store-items refs)))) + (item + (return #f))))) (anym %store-monad entry-lookup-package (manifest-entries manifest))) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 488638adc..f2c3d4729 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2017 Ludovic Courtès +;;; Copyright © 2015, 2017, 2018 Ludovic Courtès ;;; Copyright © 2017 Efraim Flashner ;;; Copyright © 2017 Ricardo Wurmus ;;; Copyright © 2018 Konrad Hinsen @@ -216,11 +216,13 @@ the image." (('gnu rest ...) #t) (rest #f))) + (define defmod 'define-module) ;trick Geiser + (define config ;; (guix config) module for consumption by (guix gcrypt). (scheme-file "gcrypt-config.scm" #~(begin - (define-module (guix config) + (#$defmod (guix config) #:export (%libgcrypt)) ;; XXX: Work around . @@ -265,6 +267,63 @@ the image." #:references-graphs `(("profile" ,profile)))) +;;; +;;; Wrapped package. +;;; + +(define (wrapped-package package) + (define runner + (local-file + (search-path %load-path "gnu/packages/aux-files/run-in-namespace.c"))) + + (define toolchain + (specification->package "gcc-toolchain")) + + (define build + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (ice-9 match)) + + (define (strip-store-prefix file) + ;; Given a file name like "/gnu/store/…-foo-1.2/bin/foo", return + ;; "/bin/foo". + (let* ((len (string-length (%store-directory))) + (base (string-drop file (+ 1 len)))) + (match (string-index base #\/) + (#f base) + (index (string-drop base index))))) + + (define (build-wrapper program) + ;; Build a user-namespace wrapper for PROGRAM. + (format #t "building wrapper for '~a'...~%" program) + (copy-file #$runner "run.c") + + (substitute* "run.c" + (("@WRAPPED_PROGRAM@") program) + (("@STORE_DIRECTORY@") (%store-directory))) + + (let* ((base (strip-store-prefix program)) + (result (string-append #$output "/" base))) + (mkdir-p (dirname result)) + (invoke "gcc" "-static" "-Os" "-g0" "run.c" + "-o" result) + (delete-file "run.c"))) + + (setvbuf (current-output-port) 'line) + (setenv "PATH" #+(file-append toolchain "/bin")) + (setenv "LIBRARY_PATH" + (string-append #+toolchain "/lib:" + #+toolchain:static "/lib")) + (setenv "CPATH" #+(file-append toolchain "/include")) + (for-each build-wrapper + (append (find-files #$(file-append package "/bin")) + (find-files #$(file-append package "/sbin")) + (find-files #$(file-append package "/libexec"))))))) + + (computed-file (package-full-name package) build)) + + ;;; ;;; Command-line options. ;;; @@ -408,9 +467,18 @@ Create a bundle of PACKAGE.\n")) (load* manifest-file user-module))) (else (packages->manifest packages))))) + (define (map-manifest-entries proc manifest) + (make-manifest + (map (lambda (entry) + (manifest-entry + (inherit entry) + (item (proc (manifest-entry-item entry))))) + (manifest-entries manifest)))) + (with-error-handling (let* ((dry-run? (assoc-ref opts 'dry-run?)) - (manifest (manifest-from-args opts)) + (manifest (map-manifest-entries wrapped-package + (manifest-from-args opts))) (pack-format (assoc-ref opts 'format)) (name (string-append (symbol->string pack-format) "-pack"))