diff options
| -rw-r--r-- | Makefile.am | 7 | ||||
| -rw-r--r-- | gnu/build/install.scm | 43 | ||||
| -rw-r--r-- | gnu/system/install.scm | 39 |
3 files changed, 87 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 05ce9aa7b4d..7bd689f6e11 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -342,6 +342,13 @@ dist_emacsui_DATA = emacs/guix-main.scm | |||
| 342 | nodist_emacsui_DATA = emacs/guix-helper.scm | 342 | nodist_emacsui_DATA = emacs/guix-helper.scm |
| 343 | include emacs.am | 343 | include emacs.am |
| 344 | 344 | ||
| 345 | # The self-contained tarball. | ||
| 346 | guix-binary.%.tar.xz: | ||
| 347 | -GUIX_PACKAGE_PATH= \ | ||
| 348 | $(top_builddir)/pre-inst-env "$(GUILE)" \ | ||
| 349 | "$(top_srcdir)/build-aux/make-binary-tarball.scm" "$*" "$@" | ||
| 350 | |||
| 351 | |||
| 345 | dist-hook: sync-descriptions gen-ChangeLog assert-no-store-file-names | 352 | dist-hook: sync-descriptions gen-ChangeLog assert-no-store-file-names |
| 346 | distcheck-hook: assert-binaries-available assert-final-inputs-self-contained | 353 | distcheck-hook: assert-binaries-available assert-final-inputs-self-contained |
| 347 | 354 | ||
diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 51895d58ecc..f019fcb4172 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm | |||
| @@ -18,12 +18,14 @@ | |||
| 18 | 18 | ||
| 19 | (define-module (gnu build install) | 19 | (define-module (gnu build install) |
| 20 | #:use-module (guix build utils) | 20 | #:use-module (guix build utils) |
| 21 | #:use-module (guix build store-copy) | ||
| 21 | #:use-module (srfi srfi-26) | 22 | #:use-module (srfi srfi-26) |
| 22 | #:use-module (ice-9 match) | 23 | #:use-module (ice-9 match) |
| 23 | #:export (install-grub | 24 | #:export (install-grub |
| 24 | populate-root-file-system | 25 | populate-root-file-system |
| 25 | reset-timestamps | 26 | reset-timestamps |
| 26 | register-closure)) | 27 | register-closure |
| 28 | populate-single-profile-directory)) | ||
| 27 | 29 | ||
| 28 | ;;; Commentary: | 30 | ;;; Commentary: |
| 29 | ;;; | 31 | ;;; |
| @@ -157,4 +159,43 @@ by 'guix-register'. As a side effect, this resets timestamps on store files." | |||
| 157 | (unless (zero? status) | 159 | (unless (zero? status) |
| 158 | (error "failed to register store items" closure)))) | 160 | (error "failed to register store items" closure)))) |
| 159 | 161 | ||
| 162 | (define* (populate-single-profile-directory directory | ||
| 163 | #:key profile closure) | ||
| 164 | "Populate DIRECTORY with a store containing PROFILE, whose closure is given | ||
| 165 | in the file called CLOSURE (as generated by #:references-graphs.) DIRECTORY | ||
| 166 | is initialized to contain a single profile under /root pointing to PROFILE. | ||
| 167 | This is used to create the self-contained Guix tarball." | ||
| 168 | (define (scope file) | ||
| 169 | (string-append directory "/" file)) | ||
| 170 | |||
| 171 | (define %root-profile | ||
| 172 | "/var/guix/profiles/per-user/root") | ||
| 173 | |||
| 174 | (define (mkdir-p* dir) | ||
| 175 | (mkdir-p (scope dir))) | ||
| 176 | |||
| 177 | (define (symlink* old new) | ||
| 178 | (symlink old (scope new))) | ||
| 179 | |||
| 180 | ;; Populate the store. | ||
| 181 | (populate-store (list closure) directory) | ||
| 182 | (register-closure (canonicalize-path directory) closure) | ||
| 183 | |||
| 184 | ;; XXX: 'guix-register' registers profiles as GC roots but the symlink | ||
| 185 | ;; target uses $TMPDIR. Fix that. | ||
| 186 | (delete-file (scope "/var/guix/gcroots/profiles")) | ||
| 187 | (symlink* "/var/guix/profiles" | ||
| 188 | "/var/guix/gcroots/profiles") | ||
| 189 | |||
| 190 | ;; Make root's profile, which makes it a GC root. | ||
| 191 | (mkdir-p* %root-profile) | ||
| 192 | (symlink* profile | ||
| 193 | (string-append %root-profile "/guix-profile-1-link")) | ||
| 194 | (symlink* (string-append %root-profile "/guix-profile-1-link") | ||
| 195 | (string-append %root-profile "/guix-profile")) | ||
| 196 | |||
| 197 | (mkdir-p* "/root") | ||
| 198 | (symlink* (string-append %root-profile "/guix-profile") | ||
| 199 | "/root/.guix-profile")) | ||
| 200 | |||
| 160 | ;;; install.scm ends here | 201 | ;;; install.scm ends here |
diff --git a/gnu/system/install.scm b/gnu/system/install.scm index 2e7e4eafad0..2fd35e8c48d 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #:use-module (guix store) | 22 | #:use-module (guix store) |
| 23 | #:use-module (guix monads) | 23 | #:use-module (guix monads) |
| 24 | #:use-module ((guix store) #:select (%store-prefix)) | 24 | #:use-module ((guix store) #:select (%store-prefix)) |
| 25 | #:use-module (guix profiles) | ||
| 25 | #:use-module (gnu packages admin) | 26 | #:use-module (gnu packages admin) |
| 26 | #:use-module (gnu packages linux) | 27 | #:use-module (gnu packages linux) |
| 27 | #:use-module (gnu packages cryptsetup) | 28 | #:use-module (gnu packages cryptsetup) |
| @@ -30,7 +31,8 @@ | |||
| 30 | #:use-module (gnu packages grub) | 31 | #:use-module (gnu packages grub) |
| 31 | #:use-module (gnu packages texinfo) | 32 | #:use-module (gnu packages texinfo) |
| 32 | #:use-module (gnu packages compression) | 33 | #:use-module (gnu packages compression) |
| 33 | #:export (installation-os)) | 34 | #:export (self-contained-tarball |
| 35 | installation-os)) | ||
| 34 | 36 | ||
| 35 | ;;; Commentary: | 37 | ;;; Commentary: |
| 36 | ;;; | 38 | ;;; |
| @@ -39,6 +41,41 @@ | |||
| 39 | ;;; | 41 | ;;; |
| 40 | ;;; Code: | 42 | ;;; Code: |
| 41 | 43 | ||
| 44 | |||
| 45 | (define* (self-contained-tarball #:key (guix guix)) | ||
| 46 | "Return a self-contained tarball containing a store initialized with the | ||
| 47 | closure of GUIX. The tarball contains /gnu/store, /var/guix, and a profile | ||
| 48 | under /root/.guix-profile where GUIX is installed." | ||
| 49 | (mlet %store-monad ((profile (profile-derivation | ||
| 50 | (manifest | ||
| 51 | (list (package->manifest-entry guix)))))) | ||
| 52 | (define build | ||
| 53 | #~(begin | ||
| 54 | (use-modules (guix build utils) | ||
| 55 | (gnu build install)) | ||
| 56 | |||
| 57 | (define %root "root") | ||
| 58 | |||
| 59 | (setenv "PATH" | ||
| 60 | (string-append #$guix "/sbin:" #$tar "/bin:" #$xz "/bin")) | ||
| 61 | |||
| 62 | (populate-single-profile-directory %root | ||
| 63 | #:profile #$profile | ||
| 64 | #:closure "profile") | ||
| 65 | |||
| 66 | ;; Create the tarball. Use GNU format so there's no file name | ||
| 67 | ;; length limitation. | ||
| 68 | (with-directory-excursion %root | ||
| 69 | (zero? (system* "tar" "--xz" "--format=gnu" | ||
| 70 | "-cvf" #$output "."))))) | ||
| 71 | |||
| 72 | (gexp->derivation "guix-tarball.tar.xz" build | ||
| 73 | #:references-graphs `(("profile" ,profile)) | ||
| 74 | #:modules '((guix build utils) | ||
| 75 | (guix build store-copy) | ||
| 76 | (gnu build install))))) | ||
| 77 | |||
| 78 | |||
| 42 | (define (log-to-info) | 79 | (define (log-to-info) |
| 43 | "Return a script that spawns the Info reader on the right section of the | 80 | "Return a script that spawns the Info reader on the right section of the |
| 44 | manual." | 81 | manual." |
