diff mbox series

[bug#55920] build-system: chicken: Added insert-missing-version phase

Message ID 20220612004520.6107-1-michal_atlas@posteo.net
State Accepted
Headers show
Series [bug#55920] build-system: chicken: Added insert-missing-version phase | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Michal Atlas June 12, 2022, 12:45 a.m. UTC
Many .egg files don't contain version information,
this causes `chicken-install` to label them {unknown},
which makes it fail compilations whenever a
dependency is tagged with a minimum-version.

I am unaware of a way to force this check to not-happen
and the version information should be included anyway,
so this patch should fix the problem.
---
 guix/build/chicken-build-system.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)


base-commit: 1643402950b2d2384ec74fb69e059cc6a4c4ebed

Comments

Liliana Marie Prikler June 15, 2022, 11:26 a.m. UTC | #1
Am Sonntag, dem 12.06.2022 um 00:45 +0000 schrieb Michal Atlas:
> Many .egg files don't contain version information,
> this causes `chicken-install` to label them {unknown},
> which makes it fail compilations whenever a
> dependency is tagged with a minimum-version.
> 
> I am unaware of a way to force this check to not-happen
> and the version information should be included anyway,
> so this patch should fix the problem.
> ---
Put the blurb below this line, add a ChangeLog above.

>  guix/build/chicken-build-system.scm | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/guix/build/chicken-build-system.scm
> b/guix/build/chicken-build-system.scm
> index 5db9906acf..341ab64a0f 100644
> --- a/guix/build/chicken-build-system.scm
> +++ b/guix/build/chicken-build-system.scm
> @@ -112,6 +112,17 @@ (define* (check #:key egg-name tests? #:allow-
> other-keys)
>    (when tests?
>      (invoke "chicken-install" "-cached" "-test" "-no-install" egg-
> name)))
>  
> +(define* (insert-missing-version #:key egg-name name #:allow-other-
> keys)
I find "stamp-egg-version" funnier.
> +  "Inserts version information into the .egg file if it isn't
> contained already"
> +  (let* ([filename (string-append egg-name "/" egg-name ".egg")]
> +         [egg-info (call-with-input-file filename read)]
> +         [ver? (find (λ (i) (eqv? (car i) 'version)) egg-info)]
> +         [ver (substring name (1+ (string-rindex name #\-)))])
We don't do square brackets in Guile.  Also, using λ rather than
spelling out "lambda" results in a syntax error.
> +    (when (not ver?)
> +      (make-file-writable filename)
> +      (call-with-output-file filename
> +       (λ (f) (write (cons `(version ,ver) egg-info) f))))))
"lambda".
>  ;; It doesn't look like Chicken generates any unnecessary
> references.
>  ;; So we don't have to remove them either. Nice.
>  
> @@ -122,6 +133,7 @@ (define %standard-phases
>      (delete 'configure)
>      (delete 'patch-generated-file-shebangs)
>      (add-before 'unpack 'setup-chicken-environment setup-chicken-
> environment)
> +    (add-before 'build 'insert-missing-version insert-missing-
> version)
Note that 'insert-missing-version will always be logged even if the
version is not actually missing.
>      (replace 'build build)
>      (delete 'check)
>      (replace 'install install)

Cheers
M June 15, 2022, 11:29 a.m. UTC | #2
Liliana Marie Prikler schreef op wo 15-06-2022 om 13:26 [+0200]:
> We don't do square brackets in Guile.  Also, using λ rather than
> spelling out "lambda" results in a syntax error.

This construct seems to work fine for me:

> (let ((id (λ (x) x))) (id 0))
$2 = 0

Greetings,
Maxime.
Liliana Marie Prikler June 15, 2022, 11:32 a.m. UTC | #3
Am Mittwoch, dem 15.06.2022 um 13:29 +0200 schrieb Maxime Devos:
> Liliana Marie Prikler schreef op wo 15-06-2022 om 13:26 [+0200]:
> > We don't do square brackets in Guile.  Also, using λ rather than
> > spelling out "lambda" results in a syntax error.
> 
> This construct seems to work fine for me:
> 
> > (let ((id (λ (x) x))) (id 0))
> $2 = 0
> 
> Greetings,
> Maxime.
My bad, I only typed the letter λ into a repl and brain-grepped for
syntax error.  Still, the long form ought to be used in my opinion,
because that's the one that editors are more likely to look out for.
Tobias Geerinckx-Rice June 15, 2022, 11:40 a.m. UTC | #4
Liliana Marie Prikler 写道:
>Also, using λ rather than spelling out "lambda" results in a 
>syntax error.

Not true, but we conventionally don't use λ in Guix code.  There 
are a good few counterexamples that snuck in over the years, 
though.

Kind regards,

T G-R
diff mbox series

Patch

diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm
index 5db9906acf..341ab64a0f 100644
--- a/guix/build/chicken-build-system.scm
+++ b/guix/build/chicken-build-system.scm
@@ -112,6 +112,17 @@  (define* (check #:key egg-name tests? #:allow-other-keys)
   (when tests?
     (invoke "chicken-install" "-cached" "-test" "-no-install" egg-name)))
 
+(define* (insert-missing-version #:key egg-name name #:allow-other-keys)
+  "Inserts version information into the .egg file if it isn't contained already"
+  (let* ([filename (string-append egg-name "/" egg-name ".egg")]
+         [egg-info (call-with-input-file filename read)]
+         [ver? (find (λ (i) (eqv? (car i) 'version)) egg-info)]
+         [ver (substring name (1+ (string-rindex name #\-)))])
+    (when (not ver?)
+      (make-file-writable filename)
+      (call-with-output-file filename
+	(λ (f) (write (cons `(version ,ver) egg-info) f))))))
+
 ;; It doesn't look like Chicken generates any unnecessary references.
 ;; So we don't have to remove them either. Nice.
 
@@ -122,6 +133,7 @@  (define %standard-phases
     (delete 'configure)
     (delete 'patch-generated-file-shebangs)
     (add-before 'unpack 'setup-chicken-environment setup-chicken-environment)
+    (add-before 'build 'insert-missing-version insert-missing-version)
     (replace 'build build)
     (delete 'check)
     (replace 'install install)