mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
database: Honor 'SOURCE_DATE_EPOCH'.
* guix/store/database.scm (timestamp): New procedure. (sqlite-register): Use it as the default for #:time. (register-items): Likewise for #:registeration-time.
This commit is contained in:
parent
3169c93903
commit
9e6fe0e08f
1 changed files with 14 additions and 5 deletions
|
@ -323,8 +323,19 @@ ids of items referred to."
|
||||||
(sqlite-fold cons '() stmt))
|
(sqlite-fold cons '() stmt))
|
||||||
references)))
|
references)))
|
||||||
|
|
||||||
|
(define (timestamp)
|
||||||
|
"Return a timestamp, either the current time of SOURCE_DATE_EPOCH."
|
||||||
|
(match (getenv "SOURCE_DATE_EPOCH")
|
||||||
|
(#f
|
||||||
|
(current-time time-utc))
|
||||||
|
((= string->number seconds)
|
||||||
|
(if seconds
|
||||||
|
(make-time time-utc 0 seconds)
|
||||||
|
(current-time time-utc)))))
|
||||||
|
|
||||||
(define* (sqlite-register db #:key path (references '())
|
(define* (sqlite-register db #:key path (references '())
|
||||||
deriver hash nar-size time)
|
deriver hash nar-size
|
||||||
|
(time (timestamp)))
|
||||||
"Registers this stuff in DB. PATH is the store item to register and
|
"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'
|
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
|
that produced PATH, HASH is the base16-encoded Nix sha256 hash of
|
||||||
|
@ -337,9 +348,7 @@ Every store item in REFERENCES must already be registered."
|
||||||
#:deriver deriver
|
#:deriver deriver
|
||||||
#:hash hash
|
#:hash hash
|
||||||
#:nar-size nar-size
|
#:nar-size nar-size
|
||||||
#:time (time-second
|
#:time (time-second time))))
|
||||||
(or time
|
|
||||||
(current-time time-utc))))))
|
|
||||||
;; Call 'path-id' on each of REFERENCES. This ensures we get a
|
;; Call 'path-id' on each of REFERENCES. This ensures we get a
|
||||||
;; "non-NULL constraint" failure if one of REFERENCES is unregistered.
|
;; "non-NULL constraint" failure if one of REFERENCES is unregistered.
|
||||||
(add-references db id
|
(add-references db id
|
||||||
|
@ -388,7 +397,7 @@ is true."
|
||||||
|
|
||||||
(define* (register-items db items
|
(define* (register-items db items
|
||||||
#:key prefix
|
#:key prefix
|
||||||
registration-time
|
(registration-time (timestamp))
|
||||||
(log-port (current-error-port)))
|
(log-port (current-error-port)))
|
||||||
"Register all of ITEMS, a list of <store-info> records as returned by
|
"Register all of ITEMS, a list of <store-info> records as returned by
|
||||||
'read-reference-graph', in DB. ITEMS must be in topological order (with
|
'read-reference-graph', in DB. ITEMS must be in topological order (with
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue