diff mbox series

[bug#61255,1/5] pack: Extract keyword-ref procedure from debian-archive.

Message ID 20230203221409.15886-2-maxim.cournoyer@gmail.com
State New
Headers show
Series Add support for the RPM format to "guix pack" | expand

Commit Message

Maxim Cournoyer Feb. 3, 2023, 10:14 p.m. UTC
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

Ludovic Courtès Feb. 12, 2023, 6:57 p.m. UTC | #1
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’.
Maxim Cournoyer Feb. 16, 2023, 3:25 p.m. UTC | #2
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.
diff mbox series

Patch

diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index f65642fb85..7e466a2be7 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -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"