Subject: [PATCH v2 2/2] guix: chicken-build-system: Fix the build-system.

From: Nicolas Graves <[email-masked]>
Date: Sun, 20 Oct 2024 15:54:31 +0200

* guix/build/chicken-build-system.scm (stamp-egg-version): Modify
phase to create the new mandatory
$CHICKEN_EGG_CACHE/.cache-metadata/STATUS
and $CHICKEN_EGG_CACHE/.cache-metadata/VERSION.
---
 guix/build/chicken-build-system.scm | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm
index 8f9f59cc25..92bccae619 100644
--- a/guix/build/chicken-build-system.scm
+++ b/guix/build/chicken-build-system.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020 raingloom <[email-masked]>
+;;; Copyright © 2024 Nicolas Graves <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -88,8 +89,7 @@ (define (unpack-maybe-strip source dest)
     (mkdir-p dest)
     (if (file-is-directory? source)
         (copy-recursively source dest #:keep-mtime? #t)
-        (unpack-maybe-strip source dest)))
-  #t)
+        (unpack-maybe-strip source dest))))
 
 (define* (build #:key egg-name #:allow-other-keys)
   "Build the Chicken egg named by EGG-NAME"
@@ -111,15 +111,25 @@ (define* (check #:key egg-name tests? #:allow-other-keys)
   (when tests?
     (invoke "chicken-install" "-cached" "-test" "-no-install" egg-name)))
 
-(define* (stamp-egg-version #:key egg-name name #:allow-other-keys)
-  "Check if EGG-NAME.egg contains version information and add some if not."
-  (let* ((filename (string-append egg-name "/" egg-name ".egg"))
-         (egg-info (call-with-input-file filename read))
+(define* (stamp-egg-version #:key egg-name name inputs #:allow-other-keys)
+  "Check if EGG-NAME.egg contains version information and add some if not.
+Since [email-masked], also create the STATUS and VERSION files in
+$CHICKEN_EGG_CACHE/.cache-metadata."
+  (let* ((egg (string-append egg-name "/" egg-name ".egg"))
+         (metadatadir (string-append (getenv "CHICKEN_EGG_CACHE")
+                                     "/.cache-metadata/" egg-name))
+         (egg-info (call-with-input-file egg read))
          (ver? (find (lambda (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
+    (mkdir-p metadatadir)
+    (install-file (search-input-file inputs "/share/chicken/STATUS")
+                  metadatadir)
+    (call-with-output-file
+      (string-append metadatadir "/VERSION")
+      (lambda (p) (format p "~a" ver)))
+    (unless ver?
+      (make-file-writable egg)
+      (call-with-output-file egg
         (lambda (f) (write (cons `(version ,ver) egg-info) f))))))
 
 ;; It doesn't look like Chicken generates any unnecessary references.
-- 
2.46.0