diff options
author | Christopher Baines <mail@cbaines.net> | 2024-04-21 10:42:27 +0100 |
---|---|---|
committer | Guix Patches Tester <> | 2024-04-21 11:53:14 +0200 |
commit | 79f679f7a21cab3557a90794a4018416b19aeea4 (patch) | |
tree | 11b2749a4ae89eafda5871b181f8e39bad245e3b | |
parent | 70d14c3836d08aac5216918abc2897c8357e6b61 (diff) | |
download | guix-patches-79f679f7a21cab3557a90794a4018416b19aeea4.tar guix-patches-79f679f7a21cab3557a90794a4018416b19aeea4.tar.gz |
store: Add validate-store-name.
* guix/store.scm (validate-store-name): New procedure.
Change-Id: I507d070d1cfdbd433d93830ee2937b1a1dee315a
-rw-r--r-- | guix/store.scm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/guix/store.scm b/guix/store.scm index b83f205096..096efcd128 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -205,6 +205,7 @@ store-path-package-name store-path-hash-part direct-store-path + validate-store-name derivation-log-file log-file)) @@ -2303,6 +2304,16 @@ HASH-ALGO, of the derivation NAME. RECURSIVE? has the same meaning as for ;; `isStorePath' in Nix does something similar. (string-prefix? (%store-prefix) path)) +(define (validate-store-name name) + (string-for-each + (lambda (c) + (unless (or (char-alphabetic? c) + (char-numeric? c) + (member c '(#\+ #\- #\. #\_ #\? #\=))) + (error (simple-format #f "invalid character ~A" c)))) + name) + #t) + (define (direct-store-path? path) "Return #t if PATH is a store path, and not a sub-directory of a store path. This predicate is sometimes needed because files *under* a store path are not |