mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-31 23:06:59 +01:00
gnupg: Compile regexps only once.
This halves the run time on a large number of subsequent 'gnupg-verify' calls. * guix/gnupg.scm (sigid-rx, goodsig-rx, validsig-rx, expkeysig-rx) (errsig-rx): New variables, lifted from... (gnupg-verify)[status-line->sexp]: ... here.
This commit is contained in:
parent
6a0b9500f9
commit
d8169d05bb
1 changed files with 19 additions and 17 deletions
|
@ -59,19 +59,8 @@ (define %openpgp-key-server
|
|||
;; unreliable.
|
||||
(make-parameter "pool.sks-keyservers.net"))
|
||||
|
||||
(define* (gnupg-verify sig file
|
||||
#:optional (keyring (current-keyring)))
|
||||
"Verify signature SIG for FILE against the keys in KEYRING. All the keys in
|
||||
KEYRING as assumed to be \"trusted\", whether or not they expired or were
|
||||
revoked. Return a status s-exp if GnuPG failed."
|
||||
;; Regexps for status lines. See file `doc/DETAILS' in GnuPG.
|
||||
|
||||
(define (maybe-fingerprint str)
|
||||
(match (string-trim-both str)
|
||||
((or "-" "") #f)
|
||||
(fpr fpr)))
|
||||
|
||||
(define (status-line->sexp line)
|
||||
;; See file `doc/DETAILS' in GnuPG.
|
||||
(define sigid-rx
|
||||
(make-regexp
|
||||
"^\\[GNUPG:\\] SIG_ID ([A-Za-z0-9+/]+) ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}) ([[:digit:]]+)"))
|
||||
|
@ -88,6 +77,19 @@ (define errsig-rx
|
|||
(make-regexp
|
||||
"^\\[GNUPG:\\] ERRSIG ([[:xdigit:]]+) ([^ ]+) ([^ ]+) ([^ ]+) ([[:digit:]]+) ([[:digit:]]+)(.*)"))
|
||||
|
||||
|
||||
(define* (gnupg-verify sig file
|
||||
#:optional (keyring (current-keyring)))
|
||||
"Verify signature SIG for FILE against the keys in KEYRING. All the keys in
|
||||
KEYRING as assumed to be \"trusted\", whether or not they expired or were
|
||||
revoked. Return a status s-exp if GnuPG failed."
|
||||
|
||||
(define (maybe-fingerprint str)
|
||||
(match (string-trim-both str)
|
||||
((or "-" "") #f)
|
||||
(fpr fpr)))
|
||||
|
||||
(define (status-line->sexp line)
|
||||
(cond ((regexp-exec sigid-rx line)
|
||||
=>
|
||||
(lambda (match)
|
||||
|
|
Loading…
Reference in a new issue