[bug#61255,1/5] pack: Extract keyword-ref procedure from debian-archive.
Commit Message
Rationale: the upcoming rpm-archive builder will also use it.
* guix/scripts/pack.scm:
(keyword-ref): New top-level procedure, extracted from...
(debian-archive): ... here. Adjust usages accordingly.
---
guix/scripts/pack.scm | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
Comments
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> Rationale: the upcoming rpm-archive builder will also use it.
>
> * guix/scripts/pack.scm:
> (keyword-ref): New top-level procedure, extracted from...
> (debian-archive): ... here. Adjust usages accordingly.
Commit aeded14b8342c1e72afd014a1bc121770f8c3a1c added #:extra-options,
which is why we need ‘keyword-ref’ now.
I’m thinking a different option would be to use #:allow-other-keys in
all the image build procedures. That way the deb and rpm build
procedures would get their extra arguments, which would be automatically
bound without requiring manual ‘keyword-ref’ calls. Sounds a bit nicer
maybe?
If we skip to the current approach, we should consider using
‘let-keywords’ from (ice-9 optargs) instead of adding ‘keyword-ref’.
Anyway, not a blocker IMO, but something to keep in mind.
Ludo’.
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Rationale: the upcoming rpm-archive builder will also use it.
>>
>> * guix/scripts/pack.scm:
>> (keyword-ref): New top-level procedure, extracted from...
>> (debian-archive): ... here. Adjust usages accordingly.
>
> Commit aeded14b8342c1e72afd014a1bc121770f8c3a1c added #:extra-options,
> which is why we need ‘keyword-ref’ now.
>
> I’m thinking a different option would be to use #:allow-other-keys in
> all the image build procedures. That way the deb and rpm build
> procedures would get their extra arguments, which would be automatically
> bound without requiring manual ‘keyword-ref’ calls. Sounds a bit nicer
> maybe?
I'm not sure; it sounds convenient, but at the same time, it makes the
"contract" of the pack builders even fuzzier that it currently is.
> If we skip to the current approach, we should consider using
> ‘let-keywords’ from (ice-9 optargs) instead of adding ‘keyword-ref’.
>
> Anyway, not a blocker IMO, but something to keep in mind.
OK! I'll try adapting to use (ice-9 optargs) for the next revision.
@@ -194,6 +194,12 @@ (define (symlink-spec-option-parser opt name arg result)
(leave (G_ "~a: invalid symlink specification~%")
arg))))
+(define (keyword-ref lst keyword)
+ "Return the value of KEYWORD in LST, else #f."
+ (match (memq keyword lst)
+ ((_ value . _) value)
+ (#f #f)))
+
;;;
;;; Tarball format.
@@ -762,20 +768,15 @@ (define data-tarball-file-name (strip-store-file-name
(copy-file #+data-tarball data-tarball-file-name)
- (define (keyword-ref lst keyword)
- (match (memq keyword lst)
- ((_ value . _) value)
- (#f #f)))
-
;; Generate the control archive.
(define control-file
- (keyword-ref '#$extra-options #:control-file))
+ #$(keyword-ref `(,@extra-options) #:control-file))
(define postinst-file
- (keyword-ref '#$extra-options #:postinst-file))
+ #$(keyword-ref `(,@extra-options) #:postinst-file))
(define triggers-file
- (keyword-ref '#$extra-options #:triggers-file))
+ #$(keyword-ref `(,@extra-options) #:triggers-file))
(define control-tarball-file-name
(string-append "control.tar"