[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file nam
From: |
Maxime Devos |
Subject: |
[bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names. |
Date: |
Wed, 23 Jun 2021 12:22:14 +0200 |
User-agent: |
Evolution 3.34.2 |
> I'm not sure how the expansion would be usable in the module it is
> defined? It seems I could manage to get 'manifest->friendly-name' to be
> a procedure returning a gexp, but that gexp wouldn't be readily usable
> in that module (it could only be used when gexp-unquote from inside
> another G-Exp), and the expansion in the macro above doesn't bind any
> identifier, unless I'm missing something?
The macro does two things: define a procedure manifest->friendly-name
that returns a string.
(define (manifest->friendly-name manifest)
"Return a friendly name computed from the entries in MANIFEST, a
<manifest> object."
(let loop ((names (map manifest-entry-name
(manifest-entries manifest))))
(define str (string-join names "-"))
(if (< (string-length str) 40)
str
(match names
((_) str)
((names ... _) (loop names))))))) ;drop one entry
and also define a G-exp define-manifest->friendly-name
(define define-manifest->friendly-nam
#~(define (manifest->friendly-name manifes)
"Return a friendly name [...]"
[...])
Testing from a REPL:
$ guix repl
(use-modules (guix gexp) (ice-9 match) (guix profiles))
(define-syntax define-gexp-and-expand
(syntax-rules ()
((_ variable code) ; code* ... turned out to be unnecessary
(begin (define variable #~code)
code))))
(define-gexp-and-expand define-manifest->friendly-name
(define (manifest->friendly-name manifest)
"Return a friendly name computed from the entries in MANIFEST, a
<manifest> object."
(let loop ((names (map manifest-entry-name
(manifest-entries manifest))))
(define str (string-join names "-"))
(if (< (string-length str) 40)
str
(match names
((_) str)
((names ... _) (loop names))))))) ;drop one entry
$ define-manifest->friendly-name
$3 = #<gexp (define (manifest->friendly-name manifest) "Return a friendly name
computed from the entries in MANIFEST, a\n <manifest> object." (let loop
((names (map manifest-entry-name (manifest-
entries manifest)))) (define str (string-join names "-")) (if (< (string-length
str) 40) str (match names ((_) str) ((names ... _) (loop names))))))
7f4b3c5ee5a0>
$ (manifest->friendly-name (specifications->manifest '("guile")))
$8 = "guile"
Seems to work.
Greetings,
Maxime.
signature.asc
Description: This is a digitally signed message part
- [bug#49149] [PATCH 1/7] pack: Extract builder code from self-contained-tarball., (continued)
- [bug#49149] [PATCH 1/7] pack: Extract builder code from self-contained-tarball., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH] tentatively reuse rlib for cargo-build-system, Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 2/7] pack: Factorize base tar options., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 6/7] tests: pack: Fix compressor extension., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 7/7] pack: Add support for the deb format., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 3/7] pack: Fix typo., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names., Maxim Cournoyer, 2021/06/21
- [bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names., Maxime Devos, 2021/06/21
- [bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names., Maxim Cournoyer, 2021/06/22
- [bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names.,
Maxime Devos <=
- [bug#49149] [PATCH v2 1/7] pack: Extract builder code from self-contained-tarball., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH v2 2/7] pack: Factorize base tar options., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH v2 3/7] pack: Fix typo., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH v2 4/7] pack: Improve naming of the packs store file names., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH 0/7] Add deb format for guix pack., Maxim Cournoyer, 2021/06/26
- [bug#49149] [PATCH 0/7] Add deb format for guix pack., Ludovic Courtès, 2021/06/30
- [bug#49149] [PATCH 0/7] Add deb format for guix pack., Maxim Cournoyer, 2021/06/30
- [bug#49149] [PATCH v2 6/7] tests: pack: Fix compressor extension., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH v2 7/7] pack: Add support for the deb format., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH v2 7/7] pack: Add support for the deb format., Maxime Devos, 2021/06/26