unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob ec6f0d9c561d1cbba25dc869ecf3d0731c914d5b 3111 bytes (raw)
name: gnu/packages/patches/racket-rktio-bin-sh.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
From 6a553f24439fe64fd3a2f0b5902f00590ca4241f Mon Sep 17 00:00:00 2001
From: Philip McGrath <philip@philipmcgrath.com>
Date: Thu, 4 Mar 2021 04:11:50 -0500
Subject: [PATCH] rktio: patch rktio_process for "/bin/sh" on Guix

Racket provides the functions `system` and `process`,
which execute shell commands using `sh` (or `cmd` on Windows).
Racket assumes that `sh` can be found at "/bin/sh",
which is not necessarily true on Guix.

This patch adds a special case for "/bin/sh" to `rktio_process`,
the C function that implements the core of `system`, `process`,
and related Racket functions.

If:

    1. The nonstandard but ubiquitous macro `_PATH_BSHELL` from
       <paths.h> is defined; and

    2. `rktio_process` is called with the exact path "/bin/sh"; and

    3. The file specified by `_PATH_BSHELL` exists;

then `rktio_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.
---
 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
--- a/racket/src/rktio/rktio_process.c
+++ b/racket/src/rktio/rktio_process.c
@@ -9,6 +9,7 @@
 # include <sys/wait.h>
 # include <errno.h>
 # include <unistd.h>
+# include <paths.h> /* PATCHED for Guix */
 # ifdef USE_ULIMIT
 #  include <ulimit.h>
 # endif
@@ -1301,12 +1302,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
 /*========================================================================*/
 
 rktio_process_result_t *rktio_process(rktio_t *rktio,
-                                      const char *command, int argc, rktio_const_string_t *argv,
+                                      /* PATCHED for Guix (next line) */
+                                      const char *_guix_orig_command, int argc, rktio_const_string_t *argv,
                                       rktio_fd_t *stdout_fd, rktio_fd_t *stdin_fd, rktio_fd_t *stderr_fd,
                                       rktio_process_t *group_proc,
                                       const char *current_directory, rktio_envvars_t *envvars,
                                       int flags)
 {
+  const char *command; /* PATCHED for Guix */
   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,
   int i;
 #endif
 
+/* BEGIN PATCH for Guix */
+#if defined(_PATH_BSHELL)
+  command =
+      ((0 == strcmp(_guix_orig_command, "/bin/sh"))
+       && rktio_file_exists(rktio, _PATH_BSHELL))
+      ? _PATH_BSHELL
+      : _guix_orig_command;
+#else
+  command = _guix_orig_command;
+#endif
+/* END PATCH for Guix */
+
   /* avoid compiler warnings: */
   to_subprocess[0] = -1;
   to_subprocess[1] = -1;

base-commit: 9d228d16fb99c274c964e5bef93e97333888769f
-- 
2.32.0


debug log:

solving ec6f0d9c56 ...
found ec6f0d9c56 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).