On Sun, Mar 07, 2021 at 01:57:24PM -0500, John Murphy wrote:
> This patch adds the `-E` flag to racket version 7.9. This change
> has been added upstream[1] as a restult of github issue 3717[2].
> 
> [1]: 
> https://github.com/racket/racket/commit/fac84630825fdb3780fcd7891fb50e637eb3f910
> [2]: https://github.com/racket/racket/issues/3717
> 
> ---
>  .../patches/patch-racket_exec_flag            | 193 ++++++++++++++++++
>  1 file changed, 193 insertions(+)
>  create mode 100644 lang/racket-minimal/patches/patch-racket_exec_flag

Hi, that's not how the ports patches work. When you want to patch a port
you need to follow these steps:

$ cd /usr/port/lang/racket

Increase by 1 REVISION in the Makefile.

$ make clean=all
$ make patch

Now you can patch the source in /usr/ports/pobj.

If you're going to use our patch(1), it will create the .orig files
(which are needed by the ports framework to generate the proper patches
in the ports directory). If you prefer to use gpatch, then you will need
to create manually the .orig files before of patching any file.

$ cd /usr/port/lang/racket
$ make update-patches

It will create the patches in the port directory. And that's all.

This is the patch which I'm going to commit in a few days. I need to run
more tests before commiting the change.


diff --git lang/racket-minimal/Makefile lang/racket-minimal/Makefile
index 3fa33db5ae7..43677d697c5 100644
--- lang/racket-minimal/Makefile
+++ lang/racket-minimal/Makefile
@@ -5,6 +5,7 @@ ONLY_FOR_ARCHS =        aarch64 amd64 arm i386 mips64el powerpc 
powerpc64 sparc64
 COMMENT =              multi-paradigm programming language
 
 V =                    7.9
+REVISION =             0
 PKGNAME =              racket-minimal-$V
 DISTFILES =            racket-minimal-$V-src-builtpkgs${EXTRACT_SUFX} \
                        racket-openbsd-1${EXTRACT_SUFX}
diff --git lang/racket-minimal/patches/patch-src_bc_cmdline_inc 
lang/racket-minimal/patches/patch-src_bc_cmdline_inc
new file mode 100644
index 00000000000..aa40812cf7c
--- /dev/null
+++ lang/racket-minimal/patches/patch-src_bc_cmdline_inc
@@ -0,0 +1,52 @@
+$OpenBSD$
+
+https://github.com/racket/racket/issues/3717
+"cs: fix raco exe for OpenBSD"
+
+Index: src/bc/cmdline.inc
+--- src/bc/cmdline.inc.orig
++++ src/bc/cmdline.inc
+@@ -766,6 +766,8 @@ static int run_from_cmd_line(int argc, char *_argv[], 
+       argv[0] = "-m";
+     else if (!strcmp("--name", argv[0]))
+       argv[0] = "-N";
++    else if (!strcmp("--exec", argv[0]))
++      argv[0] = "-E";
+     else if (!strcmp("--no-compiled", argv[0]))
+       argv[0] = "-c";
+     else if (!strcmp("--no-lib", argv[0]))
+@@ -1015,6 +1017,7 @@ static int run_from_cmd_line(int argc, char *_argv[], 
+         eval_kind[num_enl++] = mzcmd_EMBEDDED;
+         break;
+       case 'N':
++      case 'E':
+         if (argc < 2) {
+           PRINTF("%s: missing name after %s switch\n", 
+                  prog, 
+@@ -1023,13 +1026,16 @@ static int run_from_cmd_line(int argc, char *_argv[], 
+         }
+         argv++;
+         --argc;
+-        sprog = argv[0];
+-          if (!*sprog) {
++          if (!*(argv[0])) {
+             PRINTF("%s: empty path after %s switch\n", 
+                  prog, 
+                  real_switch);
+           goto show_need_help;
+           }
++          if (*str == 'N')
++            sprog = argv[0];
++          else
++            prog = argv[0];
+           was_config_flag = 1;
+         break;
+       case 'q':
+@@ -1438,6 +1444,7 @@ static int run_from_cmd_line(int argc, char *_argv[], 
+          "  -R <paths>, --compiled <paths> : Set compiled-file search roots 
to <paths>\n"
+        "  -C, --cross : Cross-build mode; save current collects and config as 
host\n"
+        "  -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to 
<file>\n"
++       "  -E <file>, --exec <file> : Sets `(find-system-path 'exec-file)' to 
<file>\n"
+ # ifdef CMDLINE_STDIO_FLAG
+          "  -J <name>, ---wm-class <name> : Set WM_CLASS class to <name> 
(Unix)\n"
+ # endif
diff --git lang/racket-minimal/patches/patch-src_cs_c_main_c 
lang/racket-minimal/patches/patch-src_cs_c_main_c
new file mode 100644
index 00000000000..0c08c3c1184
--- /dev/null
+++ lang/racket-minimal/patches/patch-src_cs_c_main_c
@@ -0,0 +1,33 @@
+$OpenBSD$
+
+https://github.com/racket/racket/issues/3717
+"cs: fix raco exe for OpenBSD"
+
+Index: src/cs/c/main.c
+--- src/cs/c/main.c.orig
++++ src/cs/c/main.c
+@@ -172,7 +172,7 @@ static char *get_self_path(char *exec_file)
+ # undef USE_GENERIC_GET_SELF_PATH
+ #endif
+ 
+-#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ # include <sys/sysctl.h>
+ # include <errno.h>
+ static char *get_self_path(char *exec_file)
+@@ -183,9 +183,15 @@ static char *get_self_path(char *exec_file)
+   int r;
+ 
+   mib[0] = CTL_KERN;
++#if defined(__NetBSD__)
++  mib[1] = KERN_PROC_ARGS;
++  mib[2] = getpid();
++  mib[3] = KERN_PROC_PATHNAME;
++#else
+   mib[1] = KERN_PROC;
+   mib[2] = KERN_PROC_PATHNAME;
+   mib[3] = -1;
++#endif
+ 
+   r = sysctl(mib, 4, NULL, &len, NULL, 0);
+   if (r < 0) {
diff --git lang/racket-minimal/patches/patch-src_cs_main_help_ss 
lang/racket-minimal/patches/patch-src_cs_main_help_ss
new file mode 100644
index 00000000000..ffb7b524550
--- /dev/null
+++ lang/racket-minimal/patches/patch-src_cs_main_help_ss
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+https://github.com/racket/racket/issues/3717
+"cs: fix raco exe for OpenBSD"
+
+Index: src/cs/main/help.ss
+--- src/cs/main/help.ss.orig
++++ src/cs/main/help.ss
+@@ -51,7 +51,8 @@
+     "  -U, --no-user-path : Ignore user-specific collects, etc.\n"
+     "  -R <paths>, --compiled <paths> : Set compiled-file search roots to 
<paths>\n"
+     "  -C, --cross : Cross-build mode; save current collects and config as 
host\n"
+-    "  -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to 
<file>\n"))
++    "  -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to 
<file>\n"
++    "  -E <file>, --exec <file> : Sets `(find-system-path 'exec-file)' to 
<file>\n"))
+   (when gracket?
+     (#%printf
+      "  -J <name>, ---wm-class <name> : Set WM_CLASS class to <name> 
(Unix)\n"))
diff --git lang/racket-minimal/patches/patch-src_cs_main_sps 
lang/racket-minimal/patches/patch-src_cs_main_sps
new file mode 100644
index 00000000000..ec03f4f40a6
--- /dev/null
+++ lang/racket-minimal/patches/patch-src_cs_main_sps
@@ -0,0 +1,72 @@
+$OpenBSD$
+
+https://github.com/racket/racket/issues/3717
+"cs: fix raco exe for OpenBSD"
+
+Index: src/cs/main.sps
+--- src/cs/main.sps.orig
++++ src/cs/main.sps
+@@ -270,8 +270,8 @@
+         [else
+          (values (car args) (append (reverse accum) (cdr args)))])))
+ 
+-   (define (check-path-arg what flag within-flag)
+-     (when (equal? what "")
++   (define (check-path-arg path what flag within-flag)                        
 
++     (when (equal? path "")
+        (error 'racket "empty ~a after ~a switch" what (or within-flag flag))))
+ 
+    (define (raise-bad-switch arg within-arg)
+@@ -357,6 +357,7 @@
+               (let-values ([(file-name rest-args) (next-arg "file name" arg 
within-arg args)])
+                 (add-namespace-require-load! `(file ,file-name) file-name)
+                 (no-init! saw)
++                (check-path-arg file-name "file name" arg within-arg)
+                 (set-run-file! (string->path file-name))
+                 (flags-loop (cons "--" rest-args) (see saw 'non-config 
'lib)))]
+              [("-f" "--load")
+@@ -368,6 +369,7 @@
+               (let-values ([(file-name rest-args) (next-arg "file name" arg 
within-arg args)])
+                 (set! loads (cons (lambda () (load file-name))
+                                   loads))
++                (check-path-arg file-name "file name" arg within-arg)
+                 (set-run-file! (string->path file-name))
+                 (flags-loop (cons "--" rest-args) (see saw 'non-config)))]
+              [("-e" "--eval")
+@@ -452,18 +454,18 @@
+                 (cond
+                  [(equal? collects-path "")
+                   (set! init-collects-dir 'disable)]
+-                 [else 
+-                  (check-path-arg "collects path" arg within-arg)
++                 [else
++                  (check-path-arg collects-path "collects path" arg 
within-arg)
+                   (set! init-collects-dir (path->complete-path (->path 
(find-original-bytes collects-path))))])
+                 (loop rest-args))]
+              [("-S" "--search")
+               (let-values ([(collects-path rest-args) (next-arg "path" arg 
within-arg args)])
+-                (check-path-arg "collects path" collects-path within-arg)
++                (check-path-arg collects-path "collects path" collects-path 
within-arg)
+                 (set! rev-collects-post-extra (cons (->path 
(find-original-bytes collects-path)) rev-collects-post-extra))
+                 (loop rest-args))]
+              [("-G" "--config")
+               (let-values ([(config-path rest-args) (next-arg "config path" 
arg within-arg args)])
+-                (check-path-arg "config path" config-path within-arg)
++                (check-path-arg config-path "config path" config-path 
within-arg)
+                 (set! init-config-dir (path->complete-path (->path 
(find-original-bytes config-path))))
+                 (loop rest-args))]
+              [("-C" "--cross")
+@@ -500,7 +502,13 @@
+                 (loop rest-args))]
+              [("-N" "--name")
+               (let-values ([(name rest-args) (next-arg "name" arg within-arg 
args)])
++                (check-path-arg name "name" arg within-arg)
+                 (set-run-file! (string->path name))
++                (loop rest-args))]
++             [("-E" "--exec")
++              (let-values ([(name rest-args) (next-arg "name" arg within-arg 
args)])
++                (check-path-arg name "name" arg within-arg)
++                (set-exec-file! (string->path name))
+                 (loop rest-args))]
+              [("-J")
+               (cond
diff --git lang/racket-minimal/patches/patch-src_start_ustart_c 
lang/racket-minimal/patches/patch-src_start_ustart_c
new file mode 100644
index 00000000000..646fd8d617e
--- /dev/null
+++ lang/racket-minimal/patches/patch-src_start_ustart_c
@@ -0,0 +1,36 @@
+$OpenBSD$
+
+https://github.com/racket/racket/issues/3717
+"cs: fix raco exe for OpenBSD"
+
+Index: src/start/ustart.c
+--- src/start/ustart.c.orig
++++ src/start/ustart.c
+@@ -456,7 +456,7 @@ int main(int argc, char **argv)
+   }
+ 
+   data = (char *)malloc(end - prog_end);
+-  new_argv = (char **)malloc((count + argc + (2 * collcount) + 10) * 
sizeof(char*));
++  new_argv = (char **)malloc((count + argc + (2 * collcount) + 12) * 
sizeof(char*));
+ 
+   fd = open(me, O_RDONLY, 0);
+   lseek(fd, prog_end, SEEK_SET);
+@@ -495,10 +495,17 @@ int main(int argc, char **argv)
+     putenv(dll_path);
+   }
+ 
+-  new_argv[0] = me;
++  new_argv[0] = exe_path;
+ 
+   argpos = 1;
+   inpos = 1;
++
++  /* Add -E flag; we can't just put `me` in `argv[0]`, because some
++     OSes (well, just OpenBSD) cannot find the executable path of a
++     process, and the actual executable may be needed to find embedded
++     boot images. */
++  new_argv[argpos++] = "-E";
++  new_argv[argpos++] = me;
+ 
+   /* Keep all X11 flags to the front: */
+   if (x11) {

Reply via email to