From c45477d2a1a651485feede20fe0f3d15aec48b39 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 6 Jun 2018 23:58:18 +0200 Subject: install: Use (guix store database) instead of 'guix-register'. * gnu/build/install.scm (register-closure): Add #:reset-timestamps? and and #:schema; honor them. Rewrite in terms of 'register-path'. (populate-single-profile-directory): Add #:schema and honor it. Make /var/guix/profiles and /var/guix/gcroots. * gnu/build/vm.scm (root-partition-initializer): Pass #:reset-timestamps? to 'register-closure'. * gnu/system/vm.scm (not-config?): New procedure. (guile-sqlite3&co): New variable. (expression->derivation-in-linux-vm)[config]: New variable. [builder]: Use 'with-extensions'. (iso9660-image)[schema, config]: New variables. Wrap build expression in 'with-extensions'; add 'sql-schema' call. Remove GUIX from INPUTS. (qemu-image)[schema, config]: New variables. Wrap body in 'with-extensions'. (system-docker-image)[not-config?]: Remove. [config]: Use 'make-config.scm'. [schema]: New variable. [build]: Use 'with-extensions'. Add call to 'sql-schema'. Remove GUIX from INPUTS. * gnu/system/file-systems.scm (%store-prefix): Check whether '%store-prefix' is defined. * guix/scripts/pack.scm (self-contained-tarball)[not-config?] [libgcrypt, schema]: New variables. [build]: Wrap in 'with-extensions'. Adjust imported module list to use 'make-config.scm' for (guix config). --- gnu/build/install.scm | 45 +++++++++++++++++++++++++++------------------ gnu/build/vm.scm | 1 + 2 files changed, 28 insertions(+), 18 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 9e30c0d23e..6cc678b44b 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich ;;; ;;; This file is part of GNU Guix. @@ -18,6 +18,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu build install) + #:use-module (guix store database) #:use-module (guix build utils) #:use-module (guix build store-copy) #:use-module (srfi srfi-26) @@ -158,23 +159,31 @@ (define (reset-timestamps directory) (utime file 0 0 0 0)))) (find-files directory #:directories? #t))) -(define* (register-closure store closure - #:key (deduplicate? #t)) - "Register CLOSURE in STORE, where STORE is the directory name of the target -store and CLOSURE is the name of a file containing a reference graph as used -by 'guix-register'. As a side effect, this resets timestamps on store files -and, if DEDUPLICATE? is true, deduplicates files common to CLOSURE and the -rest of STORE." - (let ((status (apply system* "guix-register" "--prefix" store - (append (if deduplicate? '() '("--no-deduplication")) - (list closure))))) - (unless (zero? status) - (error "failed to register store items" closure)))) +(define* (register-closure prefix closure + #:key + (deduplicate? #t) (reset-timestamps? #t) + (schema (sql-schema))) + "Register CLOSURE in PREFIX, where PREFIX is the directory name of the +target store and CLOSURE is the name of a file containing a reference graph as +produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is +true, reset timestamps on store files and, if DEDUPLICATE? is true, +deduplicates files common to CLOSURE and the rest of PREFIX." + (let ((items (call-with-input-file closure read-reference-graph))) + ;; TODO: Add a procedure to register all of ITEMS at once. + (for-each (lambda (item) + (register-path (store-info-item item) + #:references (store-info-references item) + #:deriver (store-info-deriver item) + #:prefix prefix + #:deduplicate? deduplicate? + #:reset-timestamps? reset-timestamps? + #:schema schema)) + items))) (define* (populate-single-profile-directory directory #:key profile closure deduplicate? - register?) + register? schema) "Populate DIRECTORY with a store containing PROFILE, whose closure is given in the file called CLOSURE (as generated by #:references-graphs.) DIRECTORY is initialized to contain a single profile under /root pointing to PROFILE. @@ -200,11 +209,11 @@ (define (symlink* old new) (when register? (register-closure (canonicalize-path directory) closure - #:deduplicate? deduplicate?) + #:deduplicate? deduplicate? + #:schema schema) - ;; XXX: 'guix-register' registers profiles as GC roots but the symlink - ;; target uses $TMPDIR. Fix that. - (delete-file (scope "/var/guix/gcroots/profiles")) + (mkdir-p* "/var/guix/profiles") + (mkdir-p* "/var/guix/gcroots") (symlink* "/var/guix/profiles" "/var/guix/gcroots/profiles")) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index fa3ce7790d..37639f723a 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -354,6 +354,7 @@ (define target-store (for-each (lambda (closure) (register-closure target (string-append "/xchg/" closure) + #:reset-timestamps? copy-closures? #:deduplicate? deduplicate?)) closures) (unless copy-closures? -- cgit v1.2.3 From 31a63be8784b2769c2db21388f788a8b975fd4e1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 7 Jun 2018 22:23:57 +0200 Subject: database: Add 'register-items'. * guix/build/store-copy.scm (store-info): Export. * guix/store/database.scm (register-items): New procedure. (register-path): Implement in terms of 'register-items'. * gnu/build/install.scm (register-closure): Use 'register-items' instead of 'for-each' and 'register-path'. --- gnu/build/install.scm | 15 ++---- guix/build/store-copy.scm | 1 + guix/store/database.scm | 113 +++++++++++++++++++++++++++------------------- 3 files changed, 72 insertions(+), 57 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 6cc678b44b..82eb63d726 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -169,16 +169,11 @@ (define* (register-closure prefix closure true, reset timestamps on store files and, if DEDUPLICATE? is true, deduplicates files common to CLOSURE and the rest of PREFIX." (let ((items (call-with-input-file closure read-reference-graph))) - ;; TODO: Add a procedure to register all of ITEMS at once. - (for-each (lambda (item) - (register-path (store-info-item item) - #:references (store-info-references item) - #:deriver (store-info-deriver item) - #:prefix prefix - #:deduplicate? deduplicate? - #:reset-timestamps? reset-timestamps? - #:schema schema)) - items))) + (register-items items + #:prefix prefix + #:deduplicate? deduplicate? + #:reset-timestamps? reset-timestamps? + #:schema schema))) (define* (populate-single-profile-directory directory #:key profile closure diff --git a/guix/build/store-copy.scm b/guix/build/store-copy.scm index bad1c09cba..2d9590d16f 100644 --- a/guix/build/store-copy.scm +++ b/guix/build/store-copy.scm @@ -27,6 +27,7 @@ (define-module (guix build store-copy) #:use-module (ice-9 ftw) #:use-module (ice-9 vlist) #:export (store-info? + store-info store-info-item store-info-deriver store-info-references diff --git a/guix/store/database.scm b/guix/store/database.scm index 1e5e3bcc71..3dbe5270a3 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -26,6 +26,7 @@ (define-module (guix store database) #:use-module (guix build syscalls) #:use-module ((guix build utils) #:select (mkdir-p executable-file?)) + #:use-module (guix build store-copy) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-19) @@ -37,6 +38,7 @@ (define-module (guix store database) with-database sqlite-register register-path + register-items reset-timestamps)) ;;; Code for working with the store database directly. @@ -216,11 +218,6 @@ (define* (register-path path state-directory (deduplicate? #t) (reset-timestamps? #t) (schema (sql-schema))) - ;; Priority for options: first what is given, then environment variables, - ;; then defaults. %state-directory, %store-directory, and - ;; %store-database-directory already handle the "environment variables / - ;; defaults" question, so we only need to choose between what is given and - ;; those. "Register PATH as a valid store file, with REFERENCES as its list of references, and DERIVER as its deriver (.drv that led to it.) If PREFIX is given, it must be the name of the directory containing the new store to @@ -230,47 +227,69 @@ (define* (register-path path Use with care as it directly modifies the store! This is primarily meant to be used internally by the daemon's build hook." - (let* ((db-dir (cond - (state-directory - (string-append state-directory "/db")) - (prefix - ;; If prefix is specified, the value of NIX_STATE_DIR - ;; (which affects %state-directory) isn't supposed to - ;; affect db-dir, only the compile-time-customized - ;; default should. - (string-append prefix %localstatedir "/guix/db")) - (else - %store-database-directory))) - (store-dir (if prefix - ;; same situation as above - (string-append prefix %storedir) - %store-directory)) - (to-register (if prefix - (string-append %storedir "/" (basename path)) - ;; note: we assume here that if path is, for - ;; example, /foo/bar/gnu/store/thing.txt and prefix - ;; isn't given, then an environment variable has - ;; been used to change the store directory to - ;; /foo/bar/gnu/store, since otherwise real-path - ;; would end up being /gnu/store/thing.txt, which is - ;; probably not the right file in this case. - path)) - (real-path (string-append store-dir "/" (basename path)))) - (let-values (((hash nar-size) - (nar-sha256 real-path))) - (when reset-timestamps? - (reset-timestamps real-path)) - (mkdir-p db-dir) - (parameterize ((sql-schema schema)) - (with-database (string-append db-dir "/db.sqlite") db - (sqlite-register - db - #:path to-register - #:references references - #:deriver deriver - #:hash (string-append "sha256:" - (bytevector->base16-string hash)) - #:nar-size nar-size))) + (register-items (list (store-info path deriver references)) + #:prefix prefix #:state-directory state-directory + #:deduplicate? deduplicate? + #:reset-timestamps? reset-timestamps? + #:schema schema)) + +(define* (register-items items + #:key prefix state-directory + (deduplicate? #t) + (reset-timestamps? #t) + (schema (sql-schema))) + "Register all of ITEMS, a list of records as returned by +'read-reference-graph', in the database under PREFIX/STATE-DIRECTORY. ITEMS +must be in topological order (with leaves first.) If the database is +initially empty, apply SCHEMA to initialize it." + ;; Priority for options: first what is given, then environment variables, + ;; then defaults. %state-directory, %store-directory, and + ;; %store-database-directory already handle the "environment variables / + ;; defaults" question, so we only need to choose between what is given and + ;; those. + + (define db-dir + (cond (state-directory + (string-append state-directory "/db")) + (prefix + (string-append prefix %localstatedir "/guix/db")) + (else + %store-database-directory))) + + (define store-dir + (if prefix + (string-append prefix %storedir) + %store-directory)) + + (define (register db item) + (define to-register + (if prefix + (string-append %storedir "/" (basename (store-info-item item))) + ;; note: we assume here that if path is, for example, + ;; /foo/bar/gnu/store/thing.txt and prefix isn't given, then an + ;; environment variable has been used to change the store directory + ;; to /foo/bar/gnu/store, since otherwise real-path would end up + ;; being /gnu/store/thing.txt, which is probably not the right file + ;; in this case. + (store-info-item item))) + + (define real-file-name + (string-append store-dir "/" (basename (store-info-item item)))) + + (let-values (((hash nar-size) (nar-sha256 real-file-name))) + (when reset-timestamps? + (reset-timestamps real-file-name)) + (sqlite-register db #:path to-register + #:references (store-info-references item) + #:deriver (store-info-deriver item) + #:hash (string-append "sha256:" + (bytevector->base16-string hash)) + #:nar-size nar-size) (when deduplicate? - (deduplicate real-path hash #:store store-dir))))) + (deduplicate real-file-name hash #:store store-dir)))) + + (mkdir-p db-dir) + (parameterize ((sql-schema schema)) + (with-database (string-append db-dir "/db.sqlite") db + (for-each (cut register db <>) items)))) -- cgit v1.2.3 From 078c2329c0ffc88ac8e334fcea5e025ee6410e62 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 7 Jun 2018 22:35:36 +0200 Subject: install: Use 'reset-timestamps' from (guix store database). * gnu/build/install.scm (reset-timestamps): Remove. * gnu/build/vm.scm: Use 'reset-timestamps' from (guix store database). --- gnu/build/install.scm | 15 --------------- gnu/build/vm.scm | 1 + guix/store/database.scm | 1 - 3 files changed, 1 insertion(+), 16 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 82eb63d726..5e84cd6f69 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -26,7 +26,6 @@ (define-module (gnu build install) #:export (install-boot-config evaluate-populate-directive populate-root-file-system - reset-timestamps register-closure populate-single-profile-directory)) @@ -145,20 +144,6 @@ (define (populate-root-file-system system target) (try)) (apply throw args))))))) -(define (reset-timestamps directory) - "Reset the timestamps of all the files under DIRECTORY, so that they appear -as created and modified at the Epoch." - (display "clearing file timestamps...\n") - (for-each (lambda (file) - (let ((s (lstat file))) - ;; XXX: Guile uses libc's 'utime' function (not 'futime'), so - ;; the timestamp of symlinks cannot be changed, and there are - ;; symlinks here pointing to /gnu/store, which is the host, - ;; read-only store. - (unless (eq? (stat:type s) 'symlink) - (utime file 0 0 0 0)))) - (find-files directory #:directories? #t))) - (define* (register-closure prefix closure #:key (deduplicate? #t) (reset-timestamps? #t) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 37639f723a..803cd5996a 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -25,6 +25,7 @@ (define-module (gnu build vm) #:use-module (guix build utils) #:use-module (guix build store-copy) #:use-module (guix build syscalls) + #:use-module ((guix store database) #:select (reset-timestamps)) #:use-module (gnu build linux-boot) #:use-module (gnu build install) #:use-module (gnu system uuid) diff --git a/guix/store/database.scm b/guix/store/database.scm index 3dbe5270a3..82938455ba 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -183,7 +183,6 @@ (define* (sqlite-register db #:key path (references '()) ;;; High-level interface. ;;; -;; TODO: Factorize with that in (gnu build install). (define (reset-timestamps file) "Reset the modification time on FILE and on all the files it contains, if it's a directory. While at it, canonicalize file permissions." -- cgit v1.2.3 From eb9fe97495c012c989f76cb42a14cd78f9d94629 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 8 Jun 2018 00:00:47 +0200 Subject: database: Allow for deterministic database construction. Fixes . * guix/store/database.scm (sqlite-register): Add #:time. (%epoch): New variable. (register-items): Add #:registration-time. Pass #:time to 'sqlite-register'. * gnu/build/install.scm (register-closure): Pass #:registration-time. --- gnu/build/install.scm | 1 + guix/store/database.scm | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 5e84cd6f69..06ecb39952 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -158,6 +158,7 @@ (define* (register-closure prefix closure #:prefix prefix #:deduplicate? deduplicate? #:reset-timestamps? reset-timestamps? + #:registration-time %epoch #:schema schema))) (define* (populate-single-profile-directory directory diff --git a/guix/store/database.scm b/guix/store/database.scm index 82938455ba..05b2ba6c3f 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -39,6 +39,7 @@ (define-module (guix store database) sqlite-register register-path register-items + %epoch reset-timestamps)) ;;; Code for working with the store database directly. @@ -160,19 +161,22 @@ (define (add-references db referrer references) references))) (define* (sqlite-register db #:key path (references '()) - deriver hash nar-size) + deriver hash nar-size time) "Registers this stuff in DB. PATH is the store item to register and REFERENCES is the list of store items PATH refers to; DERIVER is the '.drv' that produced PATH, HASH is the base16-encoded Nix sha256 hash of PATH (prefixed with \"sha256:\"), and NAR-SIZE is the size in bytes PATH after -being converted to nar form. +being converted to nar form. TIME is the registration time to be recorded in +the database or #f, meaning \"right now\". Every store item in REFERENCES must already be registered." (let ((id (update-or-insert db #:path path #:deriver deriver #:hash hash #:nar-size nar-size - #:time (time-second (current-time time-utc))))) + #:time (time-second + (or time + (current-time time-utc)))))) ;; Call 'path-id' on each of REFERENCES. This ensures we get a ;; "non-NULL constraint" failure if one of REFERENCES is unregistered. (add-references db id @@ -232,15 +236,21 @@ (define* (register-path path #:reset-timestamps? reset-timestamps? #:schema schema)) +(define %epoch + ;; When it all began. + (make-time time-utc 0 1)) + (define* (register-items items #:key prefix state-directory (deduplicate? #t) (reset-timestamps? #t) + registration-time (schema (sql-schema))) "Register all of ITEMS, a list of records as returned by 'read-reference-graph', in the database under PREFIX/STATE-DIRECTORY. ITEMS must be in topological order (with leaves first.) If the database is -initially empty, apply SCHEMA to initialize it." +initially empty, apply SCHEMA to initialize it. REGISTRATION-TIME must be the +registration time to be recorded in the database; #f means \"now\"." ;; Priority for options: first what is given, then environment variables, ;; then defaults. %state-directory, %store-directory, and @@ -284,7 +294,8 @@ (define real-file-name #:deriver (store-info-deriver item) #:hash (string-append "sha256:" (bytevector->base16-string hash)) - #:nar-size nar-size) + #:nar-size nar-size + #:time registration-time) (when deduplicate? (deduplicate real-file-name hash #:store store-dir)))) -- cgit v1.2.3 From ea0a06cee2ba05451f94714a4f913db02efbe92c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 8 Jun 2018 11:03:31 +0200 Subject: Remove 'guix-register' and its traces. * Makefile.am (SH_TESTS): Remove tests/guix-register.sh. * build-aux/pre-inst-env.in (GUIX_REGISTER): Remove. * gnu/build/install.scm (directives): Remove outdated comment. * gnu/build/vm.scm (root-partition-initializer): Update comment. * gnu/packages/package-management.scm (guix-register): Remove. * guix/config.scm.in (%sbindir, %guix-register-program): Remove. * guix/scripts/system.scm (install): Adjust docstring. * guix/self.scm (make-config.scm): Remove #:guix. Do not generate %sbindir and %guix-register-program. (specification->package): Remove "guix". * nix/guix-register/guix-register.cc: Remove. * nix/libstore/store-api.cc (decodeValidPathInfo): Remove. * nix/libstore/store-api.hh (decodeValidPathInfo): Remove declaration. * nix/local.mk (sbin_PROGRAMS, guix_register_SOURCES) (guix_register_CPPFLAGS, guix_register_LDFLAGS): Remove. * tests/guix-register.sh: Remove. --- .gitignore | 1 - Makefile.am | 7 - build-aux/pre-inst-env.in | 6 +- gnu/build/install.scm | 3 - gnu/build/vm.scm | 4 +- gnu/packages/package-management.scm | 36 ----- guix/config.scm.in | 12 +- guix/scripts/system.scm | 2 +- guix/self.scm | 21 +-- nix/guix-register/guix-register.cc | 254 ------------------------------------ nix/libstore/store-api.cc | 26 ---- nix/libstore/store-api.hh | 4 - nix/local.mk | 16 --- tests/guix-register.sh | 191 --------------------------- 14 files changed, 7 insertions(+), 576 deletions(-) delete mode 100644 nix/guix-register/guix-register.cc delete mode 100644 tests/guix-register.sh (limited to 'gnu/build') diff --git a/.gitignore b/.gitignore index e2568ed5fe..35d50b35af 100644 --- a/.gitignore +++ b/.gitignore @@ -69,7 +69,6 @@ /etc/guix-publish.conf /etc/guix-publish.service /guix-daemon -/guix-register /guix/config.scm /libformat.a /libstore.a diff --git a/Makefile.am b/Makefile.am index f4cdba94a2..61a19b6b9e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -405,13 +405,6 @@ SH_TESTS = \ tests/guix-graph.sh \ tests/guix-lint.sh -if BUILD_DAEMON - -SH_TESTS += tests/guix-register.sh - -endif BUILD_DAEMON - - TESTS = $(SCM_TESTS) $(SH_TESTS) AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" GUILE_AUTO_COMPILE=0 diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index 14315d40d4..286a81591c 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -1,7 +1,7 @@ #!/bin/sh # GNU Guix --- Functional package management for GNU -# Copyright © 2012, 2013, 2014, 2015, 2017 Ludovic Courtès +# Copyright © 2012, 2013, 2014, 2015, 2017, 2018 Ludovic Courtès # Copyright © 2017 Eric Bavier # # This file is part of GNU Guix. @@ -55,10 +55,6 @@ NIX_BUILD_HOOK="$abs_top_builddir/nix/scripts/offload" @BUILD_DAEMON_OFFLOAD_FALSE@# No offloading support. @BUILD_DAEMON_OFFLOAD_FALSE@unset NIX_BUILD_HOOK -# The 'guix-register' program. -GUIX_REGISTER="$abs_top_builddir/guix-register" -export GUIX_REGISTER - # The following variables need only be defined when compiling Guix # modules, but we define them to be on the safe side in case of # auto-compilation. diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 06ecb39952..5a5e703872 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -110,9 +110,6 @@ (define (directives store) ("/var/guix/gcroots/booted-system" -> "/run/booted-system") ("/var/guix/gcroots/current-system" -> "/run/current-system") - - ;; XXX: 'guix-register' creates this symlink with a wrong target, so - ;; create it upfront to be sure. ("/var/guix/gcroots/profiles" -> "/var/guix/profiles") (directory "/bin") diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 803cd5996a..73d0191de7 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -346,7 +346,7 @@ (define target-store ;; Optionally, register the inputs in the image's store. (when register-closures? (unless copy-closures? - ;; XXX: 'guix-register' wants to palpate the things it registers, so + ;; XXX: 'register-closure' wants to palpate the things it registers, so ;; bind-mount the store on the target. (mkdir-p target-store) (mount (%store-directory) target-store "" MS_BIND)) @@ -365,7 +365,7 @@ (define target-store (display "populating...\n") (populate-root-file-system system-directory target) - ;; 'guix-register' resets timestamps and everything, so no need to do it + ;; 'register-closure' resets timestamps and everything, so no need to do it ;; once more in that case. (unless register-closures? (reset-timestamps target)))) diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index 786d2a53e9..24cf3ad015 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -294,42 +294,6 @@ (define (intern tarball) ;; Alias for backward compatibility. (define-public guix-devel guix) -(define-public guix-register - ;; This package is for internal consumption: it allows us to quickly build - ;; the 'guix-register' program, which is referred to by (guix config). - ;; TODO: Remove this hack when 'guix-register' has been superseded by Scheme - ;; code. - (package - (inherit guix) - (properties `((hidden? . #t))) - (name "guix-register") - - ;; Use a minimum set of dependencies. - (native-inputs - (fold alist-delete (package-native-inputs guix) - '("po4a" "graphviz" "help2man"))) - (propagated-inputs - `(("gnutls" ,gnutls) - ("guile-git" ,guile-git))) - - (arguments - (substitute-keyword-arguments (package-arguments guix) - ((#:tests? #f #f) - #f) - ((#:phases phases '%standard-phases) - `(modify-phases ,phases - (replace 'build - (lambda _ - (invoke "make" "nix/libstore/schema.sql.hh") - (invoke "make" "-j" (number->string - (parallel-job-count)) - "guix-register"))) - (delete 'copy-bootstrap-guile) - (replace 'install - (lambda _ - (invoke "make" "install-sbinPROGRAMS"))) - (delete 'wrap-program))))))) - (define-public guile2.0-guix (package (inherit guix) diff --git a/guix/config.scm.in b/guix/config.scm.in index aeea81bd3f..4490112e07 100644 --- a/guix/config.scm.in +++ b/guix/config.scm.in @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2018 Ludovic Courtès ;;; Copyright © 2017 Caleb Ristvedt ;;; ;;; This file is part of GNU Guix. @@ -26,13 +26,11 @@ (define-module (guix config) %storedir %localstatedir %sysconfdir - %sbindir %store-directory %state-directory %store-database-directory %config-directory - %guix-register-program %system %libgcrypt @@ -70,9 +68,6 @@ (define %localstatedir (define %sysconfdir "@guix_sysconfdir@") -(define %sbindir - "@guix_sbindir@") - (define %store-directory (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path) %storedir)) @@ -91,11 +86,6 @@ (define %config-directory (or (getenv "GUIX_CONFIGURATION_DIRECTORY") (string-append %sysconfdir "/guix"))) -(define %guix-register-program - ;; The 'guix-register' program. - (or (getenv "GUIX_REGISTER") - (string-append %sbindir "/guix-register"))) - (define %system "@guix_system@") diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 9112177bfb..727f1ac55f 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -198,7 +198,7 @@ (define* (install os-drv target bootcfg bootcfg-file) "Copy the closure of BOOTCFG, which includes the output of OS-DRV, to directory TARGET. TARGET must be an absolute directory name since that's what -'guix-register' expects. +'register-path' expects. When INSTALL-BOOTLOADER? is true, install bootloader using BOOTCFG." (define (maybe-copy to-copy) diff --git a/guix/self.scm b/guix/self.scm index ed3f31cdbc..3023ae379b 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -89,8 +89,6 @@ (define specification->package ("gzip" (ref '(gnu packages compression) 'gzip)) ("bzip2" (ref '(gnu packages compression) 'bzip2)) ("xz" (ref '(gnu packages compression) 'xz)) - ("guix" (ref '(gnu packages package-management) - 'guix-register)) ("guile2.0-json" (ref '(gnu packages guile) 'guile2.0-json)) ("guile2.0-ssh" (ref '(gnu packages ssh) 'guile2.0-ssh)) ("guile2.0-git" (ref '(gnu packages guile) 'guile2.0-git)) @@ -565,7 +563,6 @@ (define *config* #:gzip gzip #:bzip2 bzip2 #:xz xz - #:guix guix #:package-name %guix-package-name #:package-version @@ -630,8 +627,7 @@ (define built-modules (define %dependency-variables ;; (guix config) variables corresponding to dependencies. - '(%libgcrypt %libz %xz %gzip %bzip2 %nix-instantiate - %sbindir %guix-register-program)) + '(%libgcrypt %libz %xz %gzip %bzip2 %nix-instantiate)) (define %persona-variables ;; (guix config) variables that define Guix's persona. @@ -653,7 +649,7 @@ (define %config-variables (stringstring (car name+value1)) (symbol->string (car name+value2)))))) -(define* (make-config.scm #:key libgcrypt zlib gzip xz bzip2 guix +(define* (make-config.scm #:key libgcrypt zlib gzip xz bzip2 (package-name "GNU Guix") (package-version "0") (bug-report-address "bug-guix@gnu.org") @@ -669,8 +665,6 @@ (define defmod 'define-module) %guix-version %guix-bug-report-address %guix-home-page-url - %sbindir - %guix-register-program %libgcrypt %libz %gzip @@ -688,17 +682,6 @@ (define %guix-version #$package-version) (define %guix-bug-report-address #$bug-report-address) (define %guix-home-page-url #$home-page-url) - (define %sbindir - ;; This is used to define '%guix-register-program'. - ;; TODO: Use a derivation that builds nothing but the - ;; C++ part. - #+(and guix (file-append guix "/sbin"))) - - (define %guix-register-program - (or (getenv "GUIX_REGISTER") - (and %sbindir - (string-append %sbindir "/guix-register")))) - (define %gzip #+(and gzip (file-append gzip "/bin/gzip"))) (define %bzip2 diff --git a/nix/guix-register/guix-register.cc b/nix/guix-register/guix-register.cc deleted file mode 100644 index 16dae62b3d..0000000000 --- a/nix/guix-register/guix-register.cc +++ /dev/null @@ -1,254 +0,0 @@ -/* GNU Guix --- Functional package management for GNU - Copyright (C) 2013, 2014, 2015 Ludovic Courtès - Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, - 2013 Eelco Dolstra - - This file is part of GNU Guix. - - GNU Guix is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or (at - your option) any later version. - - GNU Guix is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Guix. If not, see . */ - -/* This file derives from the implementation of 'nix-store - --register-validity', by Eelco Dolstra, as found in the Nix package - manager's src/nix-store/nix-store.cc. */ - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -using namespace nix; - -/* Input stream where we read closure descriptions. */ -static std::istream *input = &std::cin; - - - -/* Command-line options. */ - -const char *argp_program_version = - "guix-register (" PACKAGE_NAME ") " PACKAGE_VERSION; -const char *argp_program_bug_address = PACKAGE_BUGREPORT; - -static char doc[] = -"guix-register -- register a closure as valid in a store\ -\v\ -This program is used internally when populating a store with data \ -from an existing store. It updates the new store's database with \ -information about which store files are valid, and what their \ -references are."; - -#define GUIX_OPT_STATE_DIRECTORY 1 -#define GUIX_OPT_DEDUPLICATE 2 - -static const struct argp_option options[] = - { - { "prefix", 'p', "DIRECTORY", 0, - "Open the store that lies under DIRECTORY" }, - { "state-directory", GUIX_OPT_STATE_DIRECTORY, "DIRECTORY", 0, - "Use DIRECTORY as the state directory of the target store" }, - { "no-deduplication", GUIX_OPT_DEDUPLICATE, 0, 0, - "Disable automatic deduplication of registered store items" }, - { 0, 0, 0, 0, 0 } - }; - - -/* Prefix of the store being populated. */ -static std::string prefix; - -/* Whether to deduplicate the registered store items. */ -static bool deduplication = true; - -/* Parse a single option. */ -static error_t -parse_opt (int key, char *arg, struct argp_state *state) -{ - switch (key) - { - case 'p': - { - prefix = canonPath (arg); - settings.nixStore = prefix + NIX_STORE_DIR; - settings.nixDataDir = prefix + NIX_DATA_DIR; - settings.nixLogDir = prefix + NIX_LOG_DIR; - settings.nixStateDir = prefix + NIX_STATE_DIR; - settings.nixDBPath = settings.nixStateDir + "/db"; - break; - } - - case GUIX_OPT_STATE_DIRECTORY: - { - string state_dir = canonPath (arg); - - settings.nixStateDir = state_dir; - settings.nixDBPath = state_dir + "/db"; - break; - } - - case GUIX_OPT_DEDUPLICATE: - deduplication = false; - break; - - case ARGP_KEY_ARG: - { - std::ifstream *file; - - if (state->arg_num >= 2) - /* Too many arguments. */ - argp_usage (state); - - file = new std::ifstream (); - file->open (arg); - - input = file; - } - break; - - default: - return (error_t) ARGP_ERR_UNKNOWN; - } - - return (error_t) 0; -} - -/* Argument parsing. */ -static struct argp argp = { options, parse_opt, 0, doc }; - - -/* Read from INPUT the description of a closure, and register it as valid in - STORE. The expected format on INPUT is that used by #:references-graphs: - - FILE - DERIVER - NUMBER-OF-REFERENCES - REF1 - ... - REFN - - This is really meant as an internal format. */ -static void -register_validity (LocalStore *store, std::istream &input, - bool optimize = true, - bool reregister = true, bool hashGiven = false, - bool canonicalise = true) -{ - ValidPathInfos infos; - - while (1) - { - ValidPathInfo info = decodeValidPathInfo (input, hashGiven); - if (info.path == "") - break; - - if (!prefix.empty ()) - { - /* Rewrite the input to refer to the final name, as if we were in a - chroot under PREFIX. */ - std::string final_prefix (NIX_STORE_DIR "/"); - info.path = final_prefix + baseNameOf (info.path); - } - - /* Keep its real path to canonicalize it and compute its hash. */ - std::string real_path; - real_path = prefix + "/" + settings.nixStore + "/" + baseNameOf (info.path); - - if (!store->isValidPath (info.path) || reregister) - { - /* !!! races */ - if (canonicalise) - canonicalisePathMetaData (real_path, -1); - - if (!hashGiven) - { - HashResult hash = hashPath (htSHA256, real_path); - info.hash = hash.first; - info.narSize = hash.second; - } - infos.push_back (info); - } - } - - store->registerValidPaths (infos); - - /* XXX: When PREFIX is non-empty, store->linksDir points to the original - store's '.links' directory, which means 'optimisePath' would try to link - to that instead of linking to the target store. Thus, disable - deduplication in this case. */ - if (optimize) - { - /* Make sure deduplication is enabled. */ - settings.autoOptimiseStore = true; - - std::string store_dir = settings.nixStore; - - /* 'optimisePath' creates temporary links under 'settings.nixStore' and - this must be the real target store, under PREFIX, to avoid - cross-device links. Thus, temporarily switch the value of - 'settings.nixStore'. */ - settings.nixStore = prefix + store_dir; - for (auto&& i: infos) - store->optimisePath (prefix + i.path); - settings.nixStore = store_dir; - } -} - - -int -main (int argc, char *argv[]) -{ - /* Initialize libgcrypt, which is indirectly used. */ - if (!gcry_check_version (GCRYPT_VERSION)) - { - fprintf (stderr, "error: libgcrypt version mismatch\n"); - exit (EXIT_FAILURE); - } - - /* Tell Libgcrypt that initialization has completed, as per the Libgcrypt - 1.6.0 manual (although this does not appear to be strictly needed.) */ - gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); - - /* Honor the environment variables, and initialize the settings. */ - settings.processEnvironment (); - - try - { - argp_parse (&argp, argc, argv, 0, 0, 0); - - /* Instantiate the store. This creates any missing directories among - 'settings.nixStore', 'settings.nixDBPath', etc. */ - LocalStore store; - - if (!prefix.empty ()) - /* Under the --prefix tree, the final name of the store will be - NIX_STORE_DIR. Set it here so that the database uses file names - prefixed by NIX_STORE_DIR and not PREFIX + NIX_STORE_DIR. */ - settings.nixStore = NIX_STORE_DIR; - - register_validity (&store, *input, deduplication); - } - catch (std::exception &e) - { - fprintf (stderr, "error: %s\n", e.what ()); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/nix/libstore/store-api.cc b/nix/libstore/store-api.cc index 6742d2ed49..9e07c67e97 100644 --- a/nix/libstore/store-api.cc +++ b/nix/libstore/store-api.cc @@ -226,32 +226,6 @@ string StoreAPI::makeValidityRegistration(const PathSet & paths, return s; } - -ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) -{ - ValidPathInfo info; - getline(str, info.path); - if (str.eof()) { info.path = ""; return info; } - if (hashGiven) { - string s; - getline(str, s); - info.hash = parseHash(htSHA256, s); - getline(str, s); - if (!string2Int(s, info.narSize)) throw Error("number expected"); - } - getline(str, info.deriver); - string s; int n; - getline(str, s); - if (!string2Int(s, n)) throw Error("number expected"); - while (n--) { - getline(str, s); - info.references.insert(s); - } - if (!str || str.eof()) throw Error("missing input"); - return info; -} - - string showPaths(const PathSet & paths) { string s; diff --git a/nix/libstore/store-api.hh b/nix/libstore/store-api.hh index e957cedebc..2d9dcbd573 100644 --- a/nix/libstore/store-api.hh +++ b/nix/libstore/store-api.hh @@ -371,10 +371,6 @@ std::shared_ptr openStore(bool reserveSpace = true); string showPaths(const PathSet & paths); -ValidPathInfo decodeValidPathInfo(std::istream & str, - bool hashGiven = false); - - /* Export multiple paths in the format expected by ‘nix-store --import’. */ void exportPaths(StoreAPI & store, const Paths & paths, diff --git a/nix/local.mk b/nix/local.mk index b4c6ba61a4..140c78df37 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -120,7 +120,6 @@ libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \ $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS) bin_PROGRAMS = guix-daemon -sbin_PROGRAMS = guix-register guix_daemon_SOURCES = \ %D%/nix-daemon/nix-daemon.cc \ @@ -138,24 +137,9 @@ guix_daemon_LDADD = \ guix_daemon_headers = \ %D%/nix-daemon/shared.hh - -guix_register_SOURCES = \ - %D%/guix-register/guix-register.cc - -guix_register_CPPFLAGS = \ - $(libutil_a_CPPFLAGS) \ - $(libstore_a_CPPFLAGS) \ - -I$(top_srcdir)/%D%/libstore - -# XXX: Should we start using shared libs? -guix_register_LDADD = \ - libstore.a libutil.a libformat.a -lz \ - $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS) - if HAVE_LIBBZ2 guix_daemon_LDADD += -lbz2 -guix_register_LDADD += -lbz2 endif HAVE_LIBBZ2 diff --git a/tests/guix-register.sh b/tests/guix-register.sh deleted file mode 100644 index 521735b8a4..0000000000 --- a/tests/guix-register.sh +++ /dev/null @@ -1,191 +0,0 @@ -# GNU Guix --- Functional package management for GNU -# Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès -# -# This file is part of GNU Guix. -# -# GNU Guix is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or (at -# your option) any later version. -# -# GNU Guix is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Guix. If not, see . - -# -# Test the 'guix-register' command-line utility. -# - -guix-register --version - -new_store="t-register-$$" -closure="t-register-closure-$$" -rm -rf "$new_store" - -exit_hook=":" -trap "chmod -R +w $new_store ; rm -rf $new_store $closure ; \$exit_hook" EXIT - -# -# Registering items in the current store---i.e., without '--prefix'. -# - -new_file="$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-guix-register-$$" -echo "Fake store file to test registration." > "$new_file" - -# Register the file with zero references and no deriver. -guix-register < "$new_file2" -guix-register <> "$closure" < Date: Thu, 14 Jun 2018 23:30:59 +0200 Subject: linux-initrd: Module check correctly handles hyphen vs. underscore. Fixes . Reported by Vagrant Cascadian and Florian Pelz . * gnu/system/mapped-devices.scm (check-device-initrd-modules): Pass LINUX-MODULES through 'normalize-module-name'. * gnu/build/linux-modules.scm (normalize-module-name): Export. --- gnu/build/linux-modules.scm | 1 + gnu/system/mapped-devices.scm | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 87d2e98edf..2ee2f1771f 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -32,6 +32,7 @@ (define-module (gnu build linux-modules) ensure-dot-ko module-aliases module-dependencies + normalize-module-name recursive-module-dependencies modules-loaded module-loaded? diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index a2cca0a93b..c452bdd894 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -32,7 +32,8 @@ (define-module (gnu system mapped-devices) #:use-module (gnu system uuid) #:autoload (gnu build file-systems) (find-partition-by-luks-uuid) #:autoload (gnu build linux-modules) - (device-module-aliases matching-modules known-module-aliases) + (device-module-aliases matching-modules known-module-aliases + normalize-module-name) #:autoload (gnu packages cryptsetup) (cryptsetup-static) #:autoload (gnu packages linux) (mdadm-static) #:use-module (srfi srfi-1) @@ -127,10 +128,15 @@ (define aliases (const #f))) (when aliases - (let ((modules (delete-duplicates - (append-map (cut matching-modules <> aliases) - (device-module-aliases device))))) - (unless (every (cute member <> linux-modules) modules) + (let ((modules (delete-duplicates + (append-map (cut matching-modules <> aliases) + (device-module-aliases device)))) + + ;; Module names (not file names) are supposed to use underscores + ;; instead of hyphens. MODULES is a list of module names, whereas + ;; LINUX-MODULES is file names without '.ko', so normalize them. + (provided (map normalize-module-name linux-modules))) + (unless (every (cut member <> provided) modules) (raise (condition (&message (message (format #f (G_ "you may need these modules \ -- cgit v1.2.3