Commit Graph

24 Commits (f2d0a2cf5c905abf816bef5d69364d28af5144ed)

Author SHA1 Message Date
Ludovic Courtès e475211869
database: Reset timestamps to one second after the Epoch.
Previously, store items registered in the database by this code (for
instance, store items retrieved by 'guix offload' and passed to
'restore-file-set') would have an mtime of 0 instead of 1.

This would cause problems for things like .go files: Guile would
consider them to be older than the corresponding .scm file, and
consequently it would ignore them and possibly use another (incorrect)
.go file.

Reported by Ricardo Wurmus.

* guix/store/database.scm (reset-timestamps): Pass 1, not 0, to
'utime'.
* tests/store-database.scm ("register-path"): Check the mtime of FILE
and REF.
2018-07-20 15:01:33 +02:00
Ludovic Courtès 4f89a8eec6
deduplication: Work around Guile bug in 'seek'.
Fixes <https://bugs.gnu.org/32161>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

This mostly reverts 83099892e0.

* guix/store/deduplication.scm (counting-wrapper-port): New procedure.
(nar-sha256): Use it.
2018-07-20 15:01:33 +02:00
Ludovic Courtès 83099892e0
deduplication: Remove 'counting-wrapper-port'.
* guix/store/deduplication.scm (counting-wrapper-port): Remove.
(nar-sha256): Call 'port-position' directly on PORT.
2018-07-19 17:12:48 +02:00
Ludovic Courtès e5e5119855
database: 'reset-timestamps' now correctly handles symlinks.
* guix/store/database.scm (reset-timestamps): Use 'utime' with
AT_SYMLINK_NOFOLLOW for symlinks.
2018-07-03 17:50:04 +02:00
Ludovic Courtès a5b34d9d24
deduplication: Remove 'false-if-system-error', now unused.
* guix/store/deduplication.scm (false-if-system-error): Remove.
2018-07-03 17:50:04 +02:00
Ludovic Courtès 3dbf331942
deduplication: Place link files under /gnu/store/.links.
Previously they'd always be placed next to TO-REPLACE, which would lead
to EPERM in some cases.

* guix/store/deduplication.scm (replace-with-link): Add #:swap-directory
parameter and honor it.  Add call to 'make-file-writable'.  Catch
'system-error' around 'rename-file'.
(deduplicate): Pass #:swap-directory and remove uses of
'false-if-system-error'.
* tests/store-deduplication.scm ("deduplicate"): Add 'chmod' call.
2018-07-03 00:39:11 +02:00
Ludovic Courtès af2f8ae5f1
deduplication: Fix incorrect use of 'throw'.
* guix/store/deduplication.scm (get-temp-link): In handler, fix call to
'throw'.
2018-07-03 00:39:11 +02:00
Ludovic Courtès eb9fe97495
database: Allow for deterministic database construction.
Fixes <https://bugs.gnu.org/21073>.

* 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.
2018-06-14 11:17:00 +02:00
Ludovic Courtès 078c2329c0
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).
2018-06-14 11:17:00 +02:00
Ludovic Courtès 31a63be878
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'.
2018-06-14 11:17:00 +02:00
Ludovic Courtès ef1297e8c7
database: 'sqlite-register' takes a database, not a file name.
* guix/store/database.scm (sqlite-register): Remove #:db-file and add
'db' parameter.  Remove #:schema and 'parameterize'.
(register-path): Wrap 'sqlite-register' call in 'with-database' and in
'parameterize'.
* tests/store-database.scm ("new database")
("register-path with unregistered references"): Adjust accordingly.
2018-06-14 11:17:00 +02:00
Ludovic Courtès 49c393ccaa
database: 'reset-timestamps' sets file permissions as well.
* guix/store/database.scm (reset-timestamps): Add 'chmod' calls.
2018-06-14 11:16:59 +02:00
Ludovic Courtès 122a6cad7d
database: Replace existing entries in Refs.
* guix/store/database.scm (add-reference-sql): Add "OR REPLACE".
2018-06-14 11:16:59 +02:00
Ludovic Courtès 4bd86f0d62
database: Add #:reset-timestamps? to 'register-path'.
* guix/store/database.scm (register-path): Add #:reset-timestamps? and
honor it.
2018-06-14 11:16:59 +02:00
Ludovic Courtès b85e2ff484
database: Remove extra SQL parameter in 'update-or-insert'.
* guix/store/database.scm (update-or-insert): Remove extra #:path
parameter.
2018-06-14 11:16:59 +02:00
Ludovic Courtès 0d0438ed8c
deduplicate: Fix a couple of thinkos.
* guix/store/deduplication.scm (get-temp-link): Turn 'args' in the 'catch'
handler into a rest argument.
(deduplicate): Use 'lstat' instead of 'file-is-directory?' to properly
handle symlinks.  When iterating over the result of 'scandir', exclude
the ".links" sub-directory.
* tests/store-deduplication.scm ("deduplicate"): Create sub-directories
and call 'deduplicate' directly on STORE.
2018-06-14 11:16:59 +02:00
Ludovic Courtès 866ee8c66a
database: 'register-path' creates the database directory if needed.
* guix/store/database.scm (register-path): Call 'mkdir-p'.
2018-06-14 11:16:59 +02:00
Ludovic Courtès 33fddb763a
database: Provide a way to specify the schema location.
* guix/store/database.scm (sqlite-register): Add #:schema.  Parameterize
'sql-schema' based on this.
(register-path): Add #:schema and pass it to 'sqlite-register'.
2018-06-14 11:16:59 +02:00
Ludovic Courtès f8f9f7cabc
database: Fail registration when encountering unregistered references.
* guix/store/database.scm (add-reference-sql): Remove nested SELECT.
(add-references): Expect REFERENCES to be a list of ids.
(sqlite-register): Call 'path-id' for each of REFERENCES and pass it to
'add-references'.
* tests/store-database.scm ("register-path with unregistered references"):
New test.
2018-06-14 11:16:58 +02:00
Ludovic Courtès 3931c76154
database: 'with-database' can now initialize new databases.
* nix/libstore/schema.sql: Rename to...
* guix/store/schema.sql: ... this.
* Makefile.am (nobase_dist_guilemodule_DATA): Add it.
* nix/local.mk (%D%/libstore/schema.sql.hh): Adjust accordingly.
* guix/store/database.scm (sql-schema): New variable.
(sqlite-exec, initialize-database, call-with-database): New procedures.
(with-database): Rewrite in terms of 'call-with-database'.
* tests/store-database.scm ("new database"): New test.
* guix/self.scm (compiled-guix)[*core-modules*]: Add 'schema.sql' to
 #:extra-files.
2018-06-14 11:16:58 +02:00
Caleb Ristvedt bf5bf5778c
Add (guix store deduplication).
* guix/store/database.scm (register-path): Add #:deduplicate? and call
'deduplicate' when it's true.
(counting-wrapper-port, nar-sha256): Move to...
* guix/store/deduplication.scm: ... here.  New file.
* tests/store-deduplication.scm: New file.
* Makefile.am (STORE_MODULES): Add deduplication.scm.
(SCM_TESTS) [HAVE_GUILE_SQLITE3]: Add store-deduplication.scm.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2018-06-01 15:35:54 +02:00
Ludovic Courtès 285cc75c31
database: 'register-path' resets timestamps.
* guix/store/database.scm (reset-timestamps): New procedure.
(register-path): Use it.
2018-06-01 15:35:45 +02:00
Caleb Ristvedt 7f9d184d9b
Add (gnu store database).
* guix/config.scm.in (%store-database-directory): New variable.
* guix/store/database.scm: New file.
* tests/store-database.scm: New file.
* Makefile.am (STORE_MODULES): New variable.
(MODULES, MODULES_NOT_COMPILED): Adjust accordingly.
(SCM_TESTS) [HAVE_GUILE_SQLITE3]: Add tests/store-database.scm.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2018-06-01 15:35:32 +02:00
Ludovic Courtès 285f63e805
store: Support 'ssh://' URIs in 'GUIX_DAEMON_SOCKET'.
This allows 'guix' commands to talk to a remote store over SSH.

* guix/store.scm (connect-to-daemon)[connect]: Call 'resolve-interface'
for unknown URI schemes.
* guix/store/ssh.scm: New file.
* Makefile.am (MODULES): Add it.
* doc/guix.texi (The Store): Document it.  Mark remote access as
experimental.
2017-04-21 19:17:36 +02:00