diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-04-01 16:08:31 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-04-01 17:35:27 +0200 |
commit | 2c6ab6ccd430550dfbc95fbdd22ae017f39e5901 (patch) | |
tree | 4afc3d506da5624f3697b005c635720cd5b3d7bd /guix | |
parent | ef8c03407dce8d6ebdfcf53318ac9a09b5ee8461 (diff) | |
download | gnu-guix-2c6ab6ccd430550dfbc95fbdd22ae017f39e5901.tar gnu-guix-2c6ab6ccd430550dfbc95fbdd22ae017f39e5901.tar.gz |
store: Add `store-path-hash-part'.
* guix/store.scm (store-path-hash-part): New procedure.
* tests/store.scm ("store-path-hash-part", "store-path-hash-part #f"):
New tests.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/store.scm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/guix/store.scm b/guix/store.scm index 4d078c5899..3bb2656bb6 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -83,7 +83,8 @@ %store-prefix store-path? derivation-path? - store-path-package-name)) + store-path-package-name + store-path-hash-part)) (define %protocol-version #x10c) @@ -751,3 +752,12 @@ collected, and the number of bytes freed." (and=> (regexp-exec store-path-rx path) (cut match:substring <> 1))) + +(define (store-path-hash-part path) + "Return the hash part of PATH as a base32 string, or #f if PATH is not a +syntactically valid store path." + (let ((path-rx (make-regexp + (string-append"^" (regexp-quote (%store-prefix)) + "/([0-9a-df-np-sv-z]{32})-[^/]+$")))) + (and=> (regexp-exec path-rx path) + (cut match:substring <> 1)))) |