@@ -205,6 +205,7 @@ (define-module (guix store)
store-path-package-name
store-path-hash-part
direct-store-path
+ validate-store-name
derivation-log-file
log-file))
@@ -2303,6 +2304,16 @@ (define (store-path? path)
;; `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