summaryrefslogtreecommitdiff
path: root/guix/build/pull.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-11-09 22:32:21 +0100
committerLudovic Courtès <ludo@gnu.org>2014-11-09 22:33:45 +0100
commitf81ac34dd9ab0f2ebaabf2cf382bd52d0d78396a (patch)
treef66eec8952dcbd4e09b346ea8132b75af011bd3d /guix/build/pull.scm
parent4684f301d5a7ff39a913c8f06507f67ec9b4a1cd (diff)
pull: Use the build procedure provided by the newly-downloaded Guix.
Fixes <http://bugs.gnu.org/18534>. * guix/scripts/pull.scm (with-environment-variable, with-PATH): New macros. (temporary-directory, first-directory, interned-then-deleted): New procedures. (unpack): Rewrite to do the unpacking in the current process rather than as a separate derivation. (%self-build-file): New variable. (build-from-source): New procedure. (build-and-install): Use it. * guix/build/pull.scm (build-guix): Rename 'tarball' argument to 'source'. Remove #:tar and #:gzip parameters, as well as 'tar' invocation. Remove 'scandir' invocation. Wrap body in 'with-directory-excursion'. * build-aux/build-self.scm: New file. * Makefile.am (EXTRA_DIST): Add it.
Diffstat (limited to 'guix/build/pull.scm')
-rw-r--r--guix/build/pull.scm120
1 files changed, 54 insertions, 66 deletions
diff --git a/guix/build/pull.scm b/guix/build/pull.scm
index 841787f0bb..281be23aa8 100644
--- a/guix/build/pull.scm
+++ b/guix/build/pull.scm
@@ -99,76 +99,64 @@ the continuation. Raise an error if one of the processes exit with non-zero."
(lambda ()
(loop lst running completed)))))))))
-(define* (build-guix out tarball
- #:key tar gzip gcrypt
+(define* (build-guix out source
+ #:key gcrypt
(debug-port (%make-void-port "w")))
- "Build and install Guix in directory OUT using source from TARBALL. Write
-any debugging output to DEBUG-PORT."
+ "Build and install Guix in directory OUT using SOURCE, a directory
+containing the source code. Write any debugging output to DEBUG-PORT."
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
- (setenv "PATH" (string-append tar "/bin:" gzip "/bin"))
-
- (format debug-port "extracting '~a'...~%" tarball)
- (system* "tar" "xf" tarball)
-
- (match (scandir "." (lambda (name)
- (and (not (member name '("." "..")))
- (file-is-directory? name))))
- ((dir)
- (chdir dir))
- (x
- (error "tarball did not produce a single source directory" x)))
-
- (format #t "copying and compiling to '~a'...~%" out)
-
- ;; Copy everything under guix/ and gnu/ plus {guix,gnu}.scm.
- (copy-recursively "guix" (string-append out "/guix")
- #:log debug-port)
- (copy-recursively "gnu" (string-append out "/gnu")
- #:log debug-port)
- (copy-file "guix.scm" (string-append out "/guix.scm"))
- (copy-file "gnu.scm" (string-append out "/gnu.scm"))
-
- ;; Add a fake (guix config) module to allow the other modules to be
- ;; compiled. The user's (guix config) is the one that will be used.
- (copy-file "guix/config.scm.in"
- (string-append out "/guix/config.scm"))
- (substitute* (string-append out "/guix/config.scm")
- (("@LIBGCRYPT@")
- (string-append gcrypt "/lib/libgcrypt")))
-
- ;; Augment the search path so Scheme code can be compiled.
- (set! %load-path (cons out %load-path))
- (set! %load-compiled-path (cons out %load-compiled-path))
-
- ;; Compile the .scm files. Do that in independent processes, à la
- ;; 'make -j', to work around <http://bugs.gnu.org/15602> (FIXME).
- ;; This ensures correctness, but is overly conservative and slow.
- ;; The solution initially implemented (and described in the bug
- ;; above) was slightly faster but consumed memory proportional to the
- ;; number of modules, which quickly became unacceptable.
- (p-for-each (lambda (file)
- (let ((go (string-append (string-drop-right file 4)
- ".go")))
- (format debug-port "~%compiling '~a'...~%" file)
- (parameterize ((current-warning-port debug-port))
- (compile-file file
- #:output-file go
- #:opts
- %auto-compilation-options))))
-
- (filter (cut string-suffix? ".scm" <>)
-
- ;; Build guix/*.scm before gnu/*.scm to speed
- ;; things up.
- (sort (find-files out "\\.scm")
- (let ((guix (string-append out "/guix"))
- (gnu (string-append out "/gnu")))
- (lambda (a b)
- (or (and (string-prefix? guix a)
- (string-prefix? gnu b))
- (string<? a b)))))))
+ (with-directory-excursion source
+ (format #t "copying and compiling to '~a'...~%" out)
+
+ ;; Copy everything under guix/ and gnu/ plus {guix,gnu}.scm.
+ (copy-recursively "guix" (string-append out "/guix")
+ #:log debug-port)
+ (copy-recursively "gnu" (string-append out "/gnu")
+ #:log debug-port)
+ (copy-file "guix.scm" (string-append out "/guix.scm"))
+ (copy-file "gnu.scm" (string-append out "/gnu.scm"))
+
+ ;; Add a fake (guix config) module to allow the other modules to be
+ ;; compiled. The user's (guix config) is the one that will be used.
+ (copy-file "guix/config.scm.in"
+ (string-append out "/guix/config.scm"))
+ (substitute* (string-append out "/guix/config.scm")
+ (("@LIBGCRYPT@")
+ (string-append gcrypt "/lib/libgcrypt")))
+
+ ;; Augment the search path so Scheme code can be compiled.
+ (set! %load-path (cons out %load-path))
+ (set! %load-compiled-path (cons out %load-compiled-path))
+
+ ;; Compile the .scm files. Do that in independent processes, à la
+ ;; 'make -j', to work around <http://bugs.gnu.org/15602> (FIXME).
+ ;; This ensures correctness, but is overly conservative and slow.
+ ;; The solution initially implemented (and described in the bug
+ ;; above) was slightly faster but consumed memory proportional to the
+ ;; number of modules, which quickly became unacceptable.
+ (p-for-each (lambda (file)
+ (let ((go (string-append (string-drop-right file 4)
+ ".go")))
+ (format debug-port "~%compiling '~a'...~%" file)
+ (parameterize ((current-warning-port debug-port))
+ (compile-file file
+ #:output-file go
+ #:opts
+ %auto-compilation-options))))
+
+ (filter (cut string-suffix? ".scm" <>)
+
+ ;; Build guix/*.scm before gnu/*.scm to speed
+ ;; things up.
+ (sort (find-files out "\\.scm")
+ (let ((guix (string-append out "/guix"))
+ (gnu (string-append out "/gnu")))
+ (lambda (a b)
+ (or (and (string-prefix? guix a)
+ (string-prefix? gnu b))
+ (string<? a b))))))))
;; Remove the "fake" (guix config).
(delete-file (string-append out "/guix/config.scm"))