[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: |
Maxim Cournoyer |
Subject: |
[bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names. |
Date: |
Thu, 24 Jun 2021 00:44:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Hello Maxime & Ludovic,
Maxime Devos <maximedevos@telenet.be> writes:
>> 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 [...]"
> [...])
Thanks a lot for persevering in your explanations, that made it clear
and with some ideas from the fine folks in #guile was able to come up
with this:
--8<---------------cut here---------------start------------->8---
(define-syntax-rule (define-with-source (variable args ...) body body* ...)
"Bind VARIABLE to a procedure accepting ARGS defined as BODY, also setting
its source property."
(begin
(define (variable args ...)
body)
(eval-when (load eval)
(set-procedure-property! variable 'source
'(define (variable args ...) body body* ...)))))
(define-with-source (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))))))
--8<---------------cut here---------------end--------------->8---
And then use it inside the build G-Exp via:
#$(procedure-source manifest->friendly-name)
The pack tests are still passing.
Maxim
- [bug#49149] [PATCH v2 3/7] pack: Fix typo., (continued)
- [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
- bug#49149: [PATCH 0/7] Add deb format for guix pack., Maxim Cournoyer, 2021/06/29
- [bug#49149] [PATCH 0/7] Add deb format for guix pack., Ludovic Courtès, 2021/06/30
- [bug#49149] [PATCH v2 5/7] pack: Prevent duplicate files in tar archives., Maxim Cournoyer, 2021/06/24
- [bug#49149] [PATCH 4/7] pack: Improve naming of the packs store file names.,
Maxim Cournoyer <=
- [bug#49149] [PATCH 0/7] Add deb format for guix pack., Ludovic Courtès, 2021/06/23
[bug#49149] [PATCH 5/7] pack: Prevent duplicate files in tar archives., Maxim Cournoyer, 2021/06/21
[bug#49149] Add deb format for guix pack., jgart, 2021/06/21
[bug#49149] [PATCH 0/7] Add deb format for guix pack., Ludovic Courtès, 2021/06/23