mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
daemon: Run 'guix substitute --substitute' as an agent.
This avoids spawning one substitute process per substitution. * nix/libstore/build.cc (class Worker)[substituter]: New field. [outPipe, logPipe, pid]: Remove. (class SubstitutionGoal)[expectedHashStr, status, substituter]: New fields. (SubstitutionGoal::timedOut): Adjust to check 'substituter'. (SubstitutionGoal::tryToRun): Remove references to 'outPipe' and 'logPipe'. Run "guix substitute --substitute" as an 'Agent'. Send the request with 'writeLine'. (SubstitutionGoal::finished): Likewise. (SubstitutionGoal::handleChildOutput): Change to fill in 'expectedHashStr' and 'status'. (SubstitutionGoal::handleEOF): Call 'wakeUp' unconditionally. (SubstitutionGoal::~SubstitutionGoal): Adjust to check 'substituter'. * guix/scripts/substitute.scm (process-substitution): Write "success\n" to stdout upon success. (%error-to-file-descriptor-4?): New variable. (guix-substitute): Set 'current-error-port' to file descriptor 4 unless (%error-to-file-descriptor-4?) is false. Remove "--substitute" arguments. Loop reading line from stdin. * tests/substitute.scm <top level>: Call '%error-to-file-descriptor-4?'. (request-substitution): New procedure. ("substitute, no signature") ("substitute, invalid hash") ("substitute, unauthorized key") ("substitute, authorized key") ("substitute, unauthorized narinfo comes first") ("substitute, unsigned narinfo comes first") ("substitute, first narinfo is unsigned and has wrong hash") ("substitute, first narinfo is unsigned and has wrong refs") ("substitute, two invalid narinfos") ("substitute, narinfo with several URLs"): Adjust to new "guix substitute --substitute" calling convention.
This commit is contained in:
parent
a618a8c620
commit
711df9ef3c
3 changed files with 145 additions and 113 deletions
|
@ -58,6 +58,14 @@ it writes to GUIX-WARNING-PORT a messages that matches ERROR-RX."
|
|||
(let ((message (get-output-string error-output)))
|
||||
(->bool (string-match error-rx message))))))))))
|
||||
|
||||
(define (request-substitution item destination)
|
||||
"Run 'guix substitute --substitute' to fetch ITEM to DESTINATION."
|
||||
(parameterize ((guix-warning-port (current-error-port)))
|
||||
(with-input-from-string (string-append "substitute " item " "
|
||||
destination "\n")
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute")))))
|
||||
|
||||
(define %public-key
|
||||
;; This key is known to be in the ACL by default.
|
||||
(call-with-input-file (string-append %config-directory "/signing-key.pub")
|
||||
|
@ -184,6 +192,11 @@ a file for NARINFO."
|
|||
;; Transmit these options to 'guix substitute'.
|
||||
(substitute-urls (list (getenv "GUIX_BINARY_SUBSTITUTE_URL")))
|
||||
|
||||
;; Never use file descriptor 4, unlike what happens when invoked by the
|
||||
;; daemon.
|
||||
(%error-to-file-descriptor-4? #f)
|
||||
|
||||
|
||||
(test-equal "query narinfo without signature"
|
||||
"" ; not substitutable
|
||||
|
||||
|
@ -284,10 +297,12 @@ System: mips64el-linux\n")
|
|||
(test-quit "substitute, no signature"
|
||||
"no valid substitute"
|
||||
(with-narinfo %narinfo
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"foo")))
|
||||
(with-input-from-string (string-append "substitute "
|
||||
(%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo"
|
||||
" foo\n")
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute")))))
|
||||
|
||||
(test-quit "substitute, invalid hash"
|
||||
"no valid substitute"
|
||||
|
@ -295,10 +310,12 @@ System: mips64el-linux\n")
|
|||
(with-narinfo (string-append %narinfo "Signature: "
|
||||
(signature-field "different body")
|
||||
"\n")
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"foo")))
|
||||
(with-input-from-string (string-append "substitute "
|
||||
(%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo"
|
||||
" foo\n")
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute")))))
|
||||
|
||||
(test-quit "substitute, unauthorized key"
|
||||
"no valid substitute"
|
||||
|
@ -307,10 +324,12 @@ System: mips64el-linux\n")
|
|||
%narinfo
|
||||
#:public-key %wrong-public-key)
|
||||
"\n")
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"foo")))
|
||||
(with-input-from-string (string-append "substitute "
|
||||
(%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo"
|
||||
" foo\n")
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute")))))
|
||||
|
||||
(test-equal "substitute, authorized key"
|
||||
"Substitutable data."
|
||||
|
@ -319,10 +338,9 @@ System: mips64el-linux\n")
|
|||
(dynamic-wind
|
||||
(const #t)
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved")
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved")
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved"))))))
|
||||
|
@ -352,10 +370,9 @@ System: mips64el-linux\n")
|
|||
(map (cut string-append "file://" <>)
|
||||
(list %alternate-substitute-directory
|
||||
%main-substitute-directory))))
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved")))))))
|
||||
|
@ -381,10 +398,9 @@ System: mips64el-linux\n")
|
|||
(map (cut string-append "file://" <>)
|
||||
(list %alternate-substitute-directory
|
||||
%main-substitute-directory))))
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved")))))))
|
||||
|
@ -417,10 +433,9 @@ System: mips64el-linux\n")
|
|||
(map (cut string-append "file://" <>)
|
||||
(list %alternate-substitute-directory
|
||||
%main-substitute-directory))))
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved")))))))
|
||||
|
@ -451,10 +466,9 @@ System: mips64el-linux\n")
|
|||
(map (cut string-append "file://" <>)
|
||||
(list %alternate-substitute-directory
|
||||
%main-substitute-directory))))
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved")))))))
|
||||
|
@ -470,10 +484,12 @@ System: mips64el-linux\n")
|
|||
#:public-key %wrong-public-key))
|
||||
%main-substitute-directory
|
||||
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))))
|
||||
(with-input-from-string (string-append "substitute "
|
||||
(%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo"
|
||||
" substitute-retrieved\n")
|
||||
(lambda ()
|
||||
(guix-substitute "--substitute"))))))
|
||||
|
||||
(test-equal "substitute, narinfo with several URLs"
|
||||
"Substitutable data."
|
||||
|
@ -513,10 +529,9 @@ System: mips64el-linux\n")))
|
|||
(parameterize ((substitute-urls
|
||||
(list (string-append "file://"
|
||||
%main-substitute-directory))))
|
||||
(guix-substitute "--substitute"
|
||||
(string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(request-substitution (string-append (%store-prefix)
|
||||
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
|
||||
"substitute-retrieved"))
|
||||
(call-with-input-file "substitute-retrieved" get-string-all))
|
||||
(lambda ()
|
||||
(false-if-exception (delete-file "substitute-retrieved")))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue