Subject: [bug#70065] [PATCH v2 1/8] gnu: zuo: Update to 1.9.

From: Philip McGrath <[email-masked]>
Date: Mon, 1 Apr 2024 02:51:06 -0400

Zuo now has tagged releases independent of the Racket release cycle.

* gnu/packages/patches/racket-zuo-bin-sh.patch: Move to ...
* gnu/packages/patches/zuo-bin-sh.patch: ... this file, and refresh it.
* gnu/local.mk (dist_patch_DATA): Update accordingly.
* gnu/packages/racket/scm (%racket-origin)[patches]: Likewise.
* gnu/packages/patches/racket-chez-scheme-bin-sh.patch: Refresh patch.
* gnu/packages/patches/racket-rktio-bin-sh.patch: Likewise.
* gnu/packages/racket/scm (%zuo-version): Move to ...
(zuo)[version]: ... this field, and update to 1.9.
[source]: Change to the repository where Zuo releases are tagged.
[arguments]: Stop supplying '#:phases'.

Change-Id: Ia82c0f7a8e4696ae08e30965e3f4ec85673b86e5
---
 gnu/local.mk                                  |  4 +-
 .../patches/racket-chez-scheme-bin-sh.patch   | 21 +++++---
 .../patches/racket-rktio-bin-sh.patch         | 17 +++---
 ...cket-zuo-bin-sh.patch => zuo-bin-sh.patch} | 33 +++++++-----
 gnu/packages/racket.scm                       | 54 +++++++++----------
 5 files changed, 70 insertions(+), 59 deletions(-)
 rename gnu/packages/patches/{racket-zuo-bin-sh.patch => zuo-bin-sh.patch} (72%)

diff --git a/gnu/local.mk b/gnu/local.mk
index 5429dc498c..a025276390 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1984,7 +1984,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/racket-chez-scheme-bin-sh.patch		\
   %D%/packages/patches/racket-backport-8.11-layered-docs.patch	\
   %D%/packages/patches/racket-rktio-bin-sh.patch		\
-  %D%/packages/patches/racket-zuo-bin-sh.patch			\
   %D%/packages/patches/remake-impure-dirs.patch			\
   %D%/packages/patches/restartd-update-robust.patch             \
   %D%/packages/patches/restic-0.9.6-fix-tests-for-go1.15.patch	\
@@ -2225,7 +2224,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/zig-do-not-link-against-librt.patch	\
   %D%/packages/patches/zig-use-baseline-cpu-by-default.patch	\
   %D%/packages/patches/zig-use-system-paths.patch		\
-  %D%/packages/patches/zsh-egrep-failing-test.patch
+  %D%/packages/patches/zsh-egrep-failing-test.patch		\
+  %D%/packages/patches/zuo-bin-sh.patch
 
 MISC_DISTRO_FILES =				\
   %D%/packages/ld-wrapper.in
diff --git a/gnu/packages/patches/racket-chez-scheme-bin-sh.patch b/gnu/packages/patches/racket-chez-scheme-bin-sh.patch
index 331b4f244b..e77c26f303 100644
--- a/gnu/packages/patches/racket-chez-scheme-bin-sh.patch
+++ b/gnu/packages/patches/racket-chez-scheme-bin-sh.patch
@@ -1,4 +1,4 @@
-From f86370295c5bb14d4bb93d0ccfa37a2b79f19f25 Mon Sep 17 00:00:00 2001
+From 5398e6d3305def343a009aba7c5f8915851c4115 Mon Sep 17 00:00:00 2001
 From: Philip McGrath <[email-masked]>
 Date: Wed, 24 Aug 2022 19:55:14 -0400
 Subject: [PATCH] Chez Scheme: patch s_process for "/bin/sh" on Guix
@@ -14,17 +14,22 @@ then `s_process` will call `execl` with the file specified by
 `_PATH_BSHELL` instead of "/bin/sh".
 
 Checking that the path specified by `_PATH_BSHELL` exists safeguards
-against obscure errors if attempting to use stand-alone executables
-built by the patched Racket in non-Guix envoronments.
+against obscure errors if attempting to use the patched Chez Scheme
+or executables it builds in non-Guix envoronments.
 
 This patch does not change the behavior of `s_system`, which relies
 on `system` from the C library.
 ---
+
+Notes:
+    See also chez-scheme-bin-sh.patch, racket-rktio-bin-sh.patch,
+    and zuo-bin-sh.patch.
+
  racket/src/ChezScheme/c/prim5.c | 21 ++++++++++++++++++++-
  1 file changed, 20 insertions(+), 1 deletion(-)
 
 diff --git a/racket/src/ChezScheme/c/prim5.c b/racket/src/ChezScheme/c/prim5.c
-index 82bbf8d687..be8f603447 100644
+index 90b087f125..284f063f8b 100644
 --- a/racket/src/ChezScheme/c/prim5.c
 +++ b/racket/src/ChezScheme/c/prim5.c
 @@ -27,6 +27,12 @@
@@ -40,7 +45,7 @@ index 82bbf8d687..be8f603447 100644
  /* locally defined functions */
  static INT s_errno(void);
  static IBOOL s_addr_in_heap(uptr x);
-@@ -861,6 +867,17 @@ static ptr s_process(char *s, IBOOL stderrp) {
+@@ -875,6 +881,17 @@ static ptr s_process(char *s, IBOOL stderrp) {
  
      INT tofds[2], fromfds[2], errfds[2];
      struct sigaction act, oint_act;
@@ -58,7 +63,7 @@ index 82bbf8d687..be8f603447 100644
  
      if (pipe(tofds)) S_error("process","cannot open pipes");
      if (pipe(fromfds)) {
-@@ -897,7 +914,9 @@ static ptr s_process(char *s, IBOOL stderrp) {
+@@ -911,7 +928,9 @@ static ptr s_process(char *s, IBOOL stderrp) {
            }
          }
  #endif /* __GNU__ Hurd */
@@ -70,7 +75,7 @@ index 82bbf8d687..be8f603447 100644
          /*NOTREACHED*/
      } else {
 
-base-commit: 87eee6e2adb8c6bc11e60619c706fa6295096085
+base-commit: 78fef00d4d16a79fdf6ab31924b3a80cadf4b368
 -- 
-2.32.0
+2.41.0
 
diff --git a/gnu/packages/patches/racket-rktio-bin-sh.patch b/gnu/packages/patches/racket-rktio-bin-sh.patch
index ec6f0d9c56..d777c0979a 100644
--- a/gnu/packages/patches/racket-rktio-bin-sh.patch
+++ b/gnu/packages/patches/racket-rktio-bin-sh.patch
@@ -1,4 +1,4 @@
-From 6a553f24439fe64fd3a2f0b5902f00590ca4241f Mon Sep 17 00:00:00 2001
+From 5e546a30789e5c9b3c94674b94cb63e16ee2e951 Mon Sep 17 00:00:00 2001
 From: Philip McGrath <[email-masked]>
 Date: Thu, 4 Mar 2021 04:11:50 -0500
 Subject: [PATCH] rktio: patch rktio_process for "/bin/sh" on Guix
@@ -28,11 +28,16 @@ Checking that the path specified by `_PATH_BSHELL` exists safeguards
 against obscure errors if attempting to use stand-alone executables
 built by the patched Racket in non-Guix envoronments.
 ---
+
+Notes:
+    See also chez-scheme-bin-sh.patch, racket-chez-scheme-bin-sh.patch,
+    and zuo-bin-sh.patch.
+
  racket/src/rktio/rktio_process.c | 17 ++++++++++++++++-
  1 file changed, 16 insertions(+), 1 deletion(-)
 
 diff --git a/racket/src/rktio/rktio_process.c b/racket/src/rktio/rktio_process.c
-index fafaf728c1..796ebc59ce 100644
+index 862850d93a..87daafef76 100644
 --- a/racket/src/rktio/rktio_process.c
 +++ b/racket/src/rktio/rktio_process.c
 @@ -9,6 +9,7 @@
@@ -43,7 +48,7 @@ index fafaf728c1..796ebc59ce 100644
  # ifdef USE_ULIMIT
  #  include <ulimit.h>
  # endif
-@@ -1301,12 +1302,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
+@@ -1358,12 +1359,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
  /*========================================================================*/
  
  rktio_process_result_t *rktio_process(rktio_t *rktio,
@@ -59,7 +64,7 @@ index fafaf728c1..796ebc59ce 100644
    rktio_process_result_t *result;
    intptr_t to_subprocess[2], from_subprocess[2], err_subprocess[2];
    int pid;
-@@ -1333,6 +1336,18 @@ rktio_process_result_t *rktio_process(rktio_t *rktio,
+@@ -1390,6 +1393,18 @@ rktio_process_result_t *rktio_process(rktio_t *rktio,
    int i;
  #endif
  
@@ -79,7 +84,7 @@ index fafaf728c1..796ebc59ce 100644
    to_subprocess[0] = -1;
    to_subprocess[1] = -1;
 
-base-commit: 9d228d16fb99c274c964e5bef93e97333888769f
+base-commit: 78fef00d4d16a79fdf6ab31924b3a80cadf4b368
 -- 
-2.32.0
+2.41.0
 
diff --git a/gnu/packages/patches/racket-zuo-bin-sh.patch b/gnu/packages/patches/zuo-bin-sh.patch
similarity index 72%
rename from gnu/packages/patches/racket-zuo-bin-sh.patch
rename to gnu/packages/patches/zuo-bin-sh.patch
index bcdcb8e963..92e3774424 100644
--- a/gnu/packages/patches/racket-zuo-bin-sh.patch
+++ b/gnu/packages/patches/zuo-bin-sh.patch
@@ -1,7 +1,7 @@
-From 73d9b77a11b4516905caf579abb559736f715ea6 Mon Sep 17 00:00:00 2001
+From cd6bed5d22ea9cb7bae2be134d5d04433fc8e313 Mon Sep 17 00:00:00 2001
 From: Philip McGrath <[email-masked]>
 Date: Mon, 11 Apr 2022 20:43:18 -0400
-Subject: [PATCH] Zuo: patch zuo_process for "/bin/sh" on Guix
+Subject: [PATCH] patch zuo_process for "/bin/sh" on Guix
 
 If:
 
@@ -16,17 +16,22 @@ then `zuo_process` will execute the file specified by `_PATH_BSHELL`
 instead of "/bin/sh".
 
 Checking that the path specified by `_PATH_BSHELL` exists safeguards
-against obscure errors if attempting to use stand-alone executables
-built by the patched Racket in non-Guix envoronments.
+against obscure errors if attempting to use the patched Zuo
+or derived executables in non-Guix envoronments.
 ---
- racket/src/zuo/zuo.c | 20 ++++++++++++++++++--
+
+Notes:
+    See also chez-scheme-bin-sh.patch, racket-chez-scheme-bin-sh.patch,
+    racket-rktio-bin-sh.patch.
+
+ zuo.c | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
 
-diff --git a/racket/src/zuo/zuo.c b/racket/src/zuo/zuo.c
-index 17f161826d..c4fb3929bb 100644
---- a/racket/src/zuo/zuo.c
-+++ b/racket/src/zuo/zuo.c
-@@ -15,6 +15,7 @@
+diff --git a/zuo.c b/zuo.c
+index d4163eb..bfc5484 100644
+--- a/zuo.c
++++ b/zuo.c
+@@ -16,6 +16,7 @@
  #include <string.h>
  #include <ctype.h>
  #ifdef ZUO_UNIX
@@ -34,7 +39,7 @@ index 17f161826d..c4fb3929bb 100644
  # include <fcntl.h>
  # include <unistd.h>
  # include <errno.h>
-@@ -5730,7 +5731,10 @@ static void zuo_pipe(zuo_raw_handle_t *_r, zuo_raw_handle_t *_w)
+@@ -5949,7 +5950,10 @@ static void zuo_pipe(zuo_raw_handle_t *_r, zuo_raw_handle_t *_w)
  zuo_t *zuo_process(zuo_t *command_and_args)
  {
    const char *who = "process";
@@ -46,7 +51,7 @@ index 17f161826d..c4fb3929bb 100644
    zuo_t *args = _zuo_cdr(command_and_args), *rev_args = z.o_null;
    zuo_t *options = z.o_empty_hash, *opt;
    zuo_t *dir, *l, *p_handle, *result;
-@@ -5741,7 +5745,19 @@ zuo_t *zuo_process(zuo_t *command_and_args)
+@@ -5960,7 +5964,19 @@ zuo_t *zuo_process(zuo_t *command_and_args)
    void *env;
    int as_child, exact_cmdline;
  
@@ -68,7 +73,7 @@ index 17f161826d..c4fb3929bb 100644
      zuo_t *a = _zuo_car(l);
      if (a == z.o_null) {
 
-base-commit: 87eee6e2adb8c6bc11e60619c706fa6295096085
+base-commit: a0faa82c8383d206aa38d21462ca4ae699851a0b
 -- 
-2.32.0
+2.41.0
 
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index 5c863f1afd..6e19be1da3 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2013-2016, 2018, 2020-2022 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2020 Pierre Neidhardt <[email-masked]>
-;;; Copyright © 2021, 2022, 2023 Philip McGrath <[email-masked]>
+;;; Copyright © 2021-2024 Philip McGrath <[email-masked]>
 ;;; Copyright © 2021 jgart <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -192,7 +192,6 @@ (define-module (gnu packages racket)
 ;; CODE:
 
 (define %racket-version "8.11.1") ; Remember to update chez-scheme-for-racket!
-(define %zuo-version "1.7") ; defined in racket/src/zuo/zuo.c
 (define %racket-commit
   (string-append "v" %racket-version))
 (define %racket-origin
@@ -206,8 +205,7 @@ (define %racket-origin
     (file-name (git-file-name "racket" %racket-version))
     (patches (search-patches "racket-chez-scheme-bin-sh.patch"
                              "racket-backport-8.11-layered-docs.patch"
-                             "racket-rktio-bin-sh.patch"
-                             "racket-zuo-bin-sh.patch"))
+                             "racket-rktio-bin-sh.patch"))
     (modules '((guix build utils)))
     (snippet
      #~(begin
@@ -229,30 +227,28 @@ (define %racket-origin

 (define-public zuo
-  (let ((revision #f))
-    (package
-      (name "zuo")
-      (version (string-append %zuo-version
-                              "-racket"
-                              %racket-version
-                              (if revision "-guix" "")
-                              (or revision "")))
-      (source %racket-origin)
-      (outputs '("out" "debug"))
-      (build-system gnu-build-system)
-      (arguments
-       (list
-        #:out-of-source? #t
-        #:phases
-        #~(modify-phases %standard-phases
-            (add-after 'unpack 'chdir
-              (lambda args
-                (chdir "racket/src/zuo"))))))
-      (home-page "https://github.com/racket/zuo")
-      ;; ^ This is downstream of https://github.com/racket/racket,
-      ;; but it's designed to be a friendly landing place
-      (synopsis "Tiny Racket for build scripts")
-      (description "Zuo is a tiny Racket with primitives for dealing
+  (package
+    (name "zuo")
+    (version "1.9") ; defined in racket/src/zuo/zuo.c or the following
+    #;(displayln (~a (hash-ref (runtime-env) 'version) "."
+                     (hash-ref (runtime-env) 'minor-version)))
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/racket/zuo")
+                    (commit (string-append "v" version))))
+              (sha256
+               (base32 "0zasir33nx1qi1ciz9dn6h8k39i443lr6apw5d1i6mjmhpzxmdhp"))
+              (file-name (git-file-name name version))
+              (patches (search-patches "zuo-bin-sh.patch"))))
+    (outputs '("out" "debug"))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:out-of-source? #t))
+    (home-page "https://github.com/racket/zuo")
+    (synopsis "Tiny Racket for build scripts")
+    (description "Zuo is a tiny Racket with primitives for dealing
 with files and running processes.  It comes with a @command{make}-like
 embedded DSL, which is used to build Racket itself.
 
@@ -261,7 +257,7 @@ (define-public zuo
 and expansion of the file content.  That's how the @command{make}-like DSL is
 defined, and even the base Zuo language is defined by layers of @code{#lang}s.
 One of the early layers implements macros.")
-      (license (list license:asl2.0 license:expat)))))
+    (license (list license:asl2.0 license:expat))))

 (define racket-vm-common-configure-flags
-- 
2.41.0