Ports/mrsh: Fix workdir, remove or upgrade patches
Also removes mrsh from the list of ports missing descriptions. I tried to be descriptive about the patches, but as I picked this port up from someone else, I'm not 100% sure how to best explain the patches.
This commit is contained in:
parent
020235a841
commit
a07e12609e
Notes:
sideshowbarker
2024-07-17 11:13:43 +09:00
Author: https://github.com/EWouters Commit: https://github.com/SerenityOS/serenity/commit/a07e12609e Pull-request: https://github.com/SerenityOS/serenity/pull/13639 Reviewed-by: https://github.com/timschumi ✅
13 changed files with 184 additions and 263 deletions
|
@ -82,7 +82,6 @@ PORTS_MISSING_DESCRIPTIONS = {
|
|||
'mandoc',
|
||||
'mbedtls',
|
||||
'milkytracker',
|
||||
'mrsh',
|
||||
'mruby',
|
||||
'nano',
|
||||
'ncurses',
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env -S bash ../.port_include.sh
|
||||
port=mrsh
|
||||
version=cd3c3a48055ab4085d83f149ff4b4feba40b40cb
|
||||
files="https://codeload.github.com/emersion/mrsh/legacy.tar.gz/${version} emersion-mrsh-d9763a3.tar.gz 6896493a1020774715ccca28e8d8f4ec722af63a93543fb6dd2762f7b1de9c8a"
|
||||
files="https://github.com/emersion/mrsh/archive/${version}.tar.gz ${port}-${version}.tar.gz d26e3fdee71ef168cf3f8ad2912c148b20aab524048e4ea899d6b83fb299ceab"
|
||||
auth_type=sha256
|
||||
useconfigure=true
|
||||
workdir=emersion-mrsh-d9763a3
|
||||
|
||||
export CFLAGS=-Wno-deprecated-declarations
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
From 4c9a77a1174cdc049d7dc418c43842920bd52f52 Mon Sep 17 00:00:00 2001
|
||||
From: EWouters <6179932+EWouters@users.noreply.github.com>
|
||||
Date: Tue, 12 Apr 2022 17:58:24 +0200
|
||||
Subject: [PATCH 1/4] Add SerenityOS to the mrsh build system
|
||||
|
||||
---
|
||||
configure | 6 ++++--
|
||||
libmrsh.serenity.sym | 7 +++++++
|
||||
2 files changed, 11 insertions(+), 2 deletions(-)
|
||||
create mode 100644 libmrsh.serenity.sym
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index c0e918e..1bf7d26 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -230,9 +230,11 @@ else
|
||||
fi
|
||||
|
||||
printf "Checking for exported symbol restrictions... "
|
||||
-if ! \
|
||||
+if ! (\
|
||||
test_ldflags -Wl,--version-script="libmrsh.gnu.sym" || \
|
||||
- test_ldflags -Wl,-exported_symbols_list,"libmrsh.darwin.sym"
|
||||
+ test_ldflags -Wl,-exported_symbols_list,"libmrsh.darwin.sym" || \
|
||||
+ test_ldflags -Wl,--version-script="libmrsh.serenity.sym"
|
||||
+)
|
||||
then
|
||||
echo no
|
||||
echo "Unable to specify exported symbols (is $(uname) supported?)" >&2
|
||||
diff --git a/libmrsh.serenity.sym b/libmrsh.serenity.sym
|
||||
new file mode 100644
|
||||
index 0000000..33de4a1
|
||||
--- /dev/null
|
||||
+++ b/libmrsh.serenity.sym
|
||||
@@ -0,0 +1,7 @@
|
||||
+{
|
||||
+ global:
|
||||
+ mrsh_*;
|
||||
+ main;
|
||||
+ local:
|
||||
+ *;
|
||||
+};
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.32.0 (Apple Git-132)
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From f254a0f09c9382deb6d2eb7497b453896b9a662f Mon Sep 17 00:00:00 2001
|
||||
From: EWouters <6179932+EWouters@users.noreply.github.com>
|
||||
Date: Tue, 12 Apr 2022 18:00:04 +0200
|
||||
Subject: [PATCH 2/4] Hardcode default path because `confstr` is missing
|
||||
|
||||
---
|
||||
shell/path.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/shell/path.c b/shell/path.c
|
||||
index 3c2bf65..ee2c4e9 100644
|
||||
--- a/shell/path.c
|
||||
+++ b/shell/path.c
|
||||
@@ -26,18 +26,24 @@ char *expand_path(struct mrsh_state *state, const char *file, bool exec,
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
+#ifndef __serenity__
|
||||
size_t pathe_size = confstr(_CS_PATH, NULL, 0);
|
||||
if (pathe_size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
pathe = malloc(pathe_size);
|
||||
+#else
|
||||
+ pathe = strdup("/bin:/usr/bin");
|
||||
+#endif
|
||||
if (pathe == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
+#ifndef __serenity__
|
||||
if (confstr(_CS_PATH, pathe, pathe_size) != pathe_size) {
|
||||
free(pathe);
|
||||
return NULL;
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
char *path = NULL;
|
||||
--
|
||||
2.32.0 (Apple Git-132)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From fa1d2ddff869430ad17e78755a06475307c49a7f Mon Sep 17 00:00:00 2001
|
||||
From: EWouters <6179932+EWouters@users.noreply.github.com>
|
||||
Date: Tue, 12 Apr 2022 18:01:44 +0200
|
||||
Subject: [PATCH 3/4] Workaround for redundant redeclaration of 'environ'
|
||||
|
||||
---
|
||||
main.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/main.c b/main.c
|
||||
index 0f433d2..577afde 100644
|
||||
--- a/main.c
|
||||
+++ b/main.c
|
||||
@@ -14,7 +14,9 @@
|
||||
#include <unistd.h>
|
||||
#include "frontend.h"
|
||||
|
||||
+#ifndef __serenity__
|
||||
extern char **environ;
|
||||
+#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct mrsh_state *state = mrsh_state_create();
|
||||
--
|
||||
2.32.0 (Apple Git-132)
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
From 7d050176ada352b563e551041999d0783475ad13 Mon Sep 17 00:00:00 2001
|
||||
From: EWouters <6179932+EWouters@users.noreply.github.com>
|
||||
Date: Wed, 4 May 2022 16:50:45 +0200
|
||||
Subject: [PATCH 4/4] `glob.h` is missing so we disable glob
|
||||
|
||||
---
|
||||
shell/word.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/shell/word.c b/shell/word.c
|
||||
index df274b7..dd94965 100644
|
||||
--- a/shell/word.c
|
||||
+++ b/shell/word.c
|
||||
@@ -1,7 +1,9 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
+#ifndef __serenity__
|
||||
#include <glob.h>
|
||||
+#endif
|
||||
#include <mrsh/buffer.h>
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
@@ -339,10 +341,13 @@ bool expand_pathnames(struct mrsh_array *expanded,
|
||||
for (size_t i = 0; i < fields->len; ++i) {
|
||||
const struct mrsh_word *field = fields->data[i];
|
||||
|
||||
+#ifndef __serenity__
|
||||
char *pattern = word_to_pattern(field);
|
||||
if (pattern == NULL) {
|
||||
+#endif
|
||||
mrsh_array_add(expanded, mrsh_word_str(field));
|
||||
continue;
|
||||
+#ifndef __serenity__
|
||||
}
|
||||
|
||||
glob_t glob_buf;
|
||||
@@ -361,6 +366,7 @@ bool expand_pathnames(struct mrsh_array *expanded,
|
||||
}
|
||||
|
||||
free(pattern);
|
||||
+#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
--
|
||||
2.32.0 (Apple Git-132)
|
||||
|
22
Ports/mrsh/patches/ReadMe.md
Normal file
22
Ports/mrsh/patches/ReadMe.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Patches for mrsh on SerenityOS
|
||||
|
||||
## `0001-Add-SerenityOS-to-the-mrsh-build-system.patch`
|
||||
|
||||
Add SerenityOS to the mrsh build system
|
||||
|
||||
|
||||
## `0002-Hardcode-default-path-because-confstr-is-missing.patch`
|
||||
|
||||
Hardcode default path because `confstr` is missing
|
||||
|
||||
|
||||
## `0003-Workaround-for-redundant-redeclaration-of-environ.patch`
|
||||
|
||||
Workaround for redundant redeclaration of 'environ'
|
||||
|
||||
|
||||
## `0004-glob.h-is-missing-so-we-disable-glob.patch`
|
||||
|
||||
`glob.h` is missing so we disable glob
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
--- a/shell/task/task.c 2020-02-03 18:16:49.579018362 +0300
|
||||
+++ b/shell/task/task.c 2020-02-03 18:24:17.149890856 +0300
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
-#include <fnmatch.h>
|
||||
+// #include <fnmatch.h>
|
||||
#include <mrsh/ast.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -218,7 +218,7 @@
|
||||
}
|
||||
char *pattern = word_to_pattern(*word_ptr);
|
||||
if (pattern != NULL) {
|
||||
- selected = fnmatch(pattern, word_str, 0) == 0;
|
||||
+ // selected = fnmatch(pattern, word_str, 0) == 0;
|
||||
free(pattern);
|
||||
} else {
|
||||
char *str = mrsh_word_str(*word_ptr);
|
||||
--- a/shell/task/word.c 2020-02-03 18:25:52.544717475 +0300
|
||||
+++ b/shell/task/word.c 2020-02-03 18:26:47.036189658 +0300
|
||||
@@ -1,7 +1,7 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
-#include <fnmatch.h>
|
||||
+// #include <fnmatch.h>
|
||||
#include <mrsh/buffer.h>
|
||||
#include <mrsh/parser.h>
|
||||
#include <stdio.h>
|
||||
@@ -364,11 +364,13 @@
|
||||
trimmed = buf;
|
||||
}
|
||||
|
||||
+/*
|
||||
if (fnmatch(pattern, match, 0) == 0) {
|
||||
char *result = strdup(trimmed);
|
||||
free(buf);
|
||||
return result;
|
||||
}
|
||||
+*/
|
||||
|
||||
buf[i] = ch;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
--- a/shell/word.c 2020-02-04 15:23:40.077301321 +0300
|
||||
+++ b/shell/word.c 2020-02-04 15:24:09.428550187 +0300
|
||||
@@ -1,7 +1,7 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
-#include <glob.h>
|
||||
+// #include <glob.h>
|
||||
#include <mrsh/buffer.h>
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
@@ -338,11 +338,13 @@
|
||||
const struct mrsh_array *fields) {
|
||||
for (size_t i = 0; i < fields->len; ++i) {
|
||||
const struct mrsh_word *field = fields->data[i];
|
||||
-
|
||||
+/*
|
||||
char *pattern = word_to_pattern(field);
|
||||
if (pattern == NULL) {
|
||||
+*/
|
||||
mrsh_array_add(expanded, mrsh_word_str(field));
|
||||
continue;
|
||||
+/*
|
||||
}
|
||||
|
||||
glob_t glob_buf;
|
||||
@@ -361,6 +363,7 @@
|
||||
}
|
||||
|
||||
free(pattern);
|
||||
+*/
|
||||
}
|
||||
|
||||
return true;
|
|
@ -1,18 +0,0 @@
|
|||
--- a/builtin/ulimit.c 2020-02-03 17:43:24.961064732 +0300
|
||||
+++ b/builtin/ulimit.c 2020-02-03 17:46:08.082450486 +0300
|
||||
@@ -14,6 +14,9 @@
|
||||
static const char ulimit_usage[] = "usage: ulimit [-f] [blocks]\n";
|
||||
|
||||
int builtin_ulimit(struct mrsh_state *state, int argc, char *argv[]) {
|
||||
+ fprintf(stderr, "unimplemented\n");
|
||||
+ return 1;
|
||||
+/*
|
||||
mrsh_optind = 0;
|
||||
int opt;
|
||||
while ((opt = mrsh_getopt(argc, argv, ":f")) != -1) {
|
||||
@@ -58,4 +61,5 @@
|
||||
}
|
||||
|
||||
return 0;
|
||||
+*/
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
--- a/shell/path.c 2020-02-03 18:04:51.852832611 +0300
|
||||
+++ b/shell/path.c 2020-02-03 18:06:50.023851071 +0300
|
||||
@@ -27,18 +27,23 @@
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
+/*
|
||||
size_t pathe_size = confstr(_CS_PATH, NULL, 0);
|
||||
if (pathe_size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
pathe = malloc(pathe_size);
|
||||
+*/
|
||||
+ pathe = strdup("/bin:/usr/bin");
|
||||
if (pathe == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
+/*
|
||||
if (confstr(_CS_PATH, pathe, pathe_size) != pathe_size) {
|
||||
free(pathe);
|
||||
return NULL;
|
||||
}
|
||||
+*/
|
||||
}
|
||||
|
||||
static char path[PATH_MAX + 1];
|
|
@ -1,27 +0,0 @@
|
|||
diff -Naur emersion-mrsh-d9763a3/libmrsh.serenity.sym emersion-mrsh-d9763a3.serenity/libmrsh.serenity.sym
|
||||
--- emersion-mrsh-d9763a3/libmrsh.serenity.sym 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ emersion-mrsh-d9763a3.serenity/libmrsh.serenity.sym 2021-04-12 09:48:47.446767471 +0200
|
||||
@@ -0,0 +1,7 @@
|
||||
+{
|
||||
+ global:
|
||||
+ mrsh_*;
|
||||
+ main;
|
||||
+ local:
|
||||
+ *;
|
||||
+};
|
||||
diff -Naur emersion-mrsh-d9763a3/configure emersion-mrsh-d9763a3.serenity/configure
|
||||
--- emersion-mrsh-d9763a3/configure 2021-04-12 10:05:17.437801859 +0200
|
||||
+++ emersion-mrsh-d9763a3.serenity/configure 2021-04-12 10:05:10.304338346 +0200
|
||||
@@ -217,9 +217,11 @@
|
||||
fi
|
||||
|
||||
printf "Checking for exported symbol restrictions... "
|
||||
-if ! \
|
||||
+if ! (\
|
||||
test_ldflags -Wl,--version-script="libmrsh.gnu.sym" || \
|
||||
+ test_ldflags -Wl,--version-script="libmrsh.serenity.sym" || \
|
||||
test_ldflags -Wl,-exported_symbols_list,"libmrsh.darwin.sym"
|
||||
+)
|
||||
then
|
||||
echo no
|
||||
echo "Unable to specify exported symbols (is $(uname) supported?)" >&2
|
|
@ -1,110 +0,0 @@
|
|||
--- a/ast.c 2020-02-03 17:32:44.302405596 +0300
|
||||
+++ b/ast.c 2020-02-03 17:35:40.520962185 +0300
|
||||
@@ -576,6 +576,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
case MRSH_NODE_COMMAND:;
|
||||
struct mrsh_command *cmd = mrsh_node_get_command(node);
|
||||
switch (cmd->type) {
|
||||
@@ -626,6 +627,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
case MRSH_NODE_WORD:;
|
||||
struct mrsh_word *word = mrsh_node_get_word(node);
|
||||
switch (word->type) {
|
||||
@@ -653,8 +655,10 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
|
||||
static void position_next(struct mrsh_position *dst,
|
||||
@@ -700,6 +704,7 @@
|
||||
return;
|
||||
case MRSH_WORD_ARITHMETIC:
|
||||
assert(false); // TODO
|
||||
+ return;
|
||||
case MRSH_WORD_LIST:;
|
||||
struct mrsh_word_list *wl = mrsh_word_get_list(word);
|
||||
if (wl->children.len == 0) {
|
||||
@@ -713,6 +718,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
|
||||
void mrsh_command_range(struct mrsh_command *cmd, struct mrsh_position *begin,
|
||||
@@ -800,8 +806,10 @@
|
||||
mrsh_command_get_function_definition(cmd);
|
||||
*begin = fd->name_range.begin;
|
||||
mrsh_command_range(fd->body, NULL, end);
|
||||
+ return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
|
||||
static void buffer_append_str(struct mrsh_buffer *buf, const char *str) {
|
||||
@@ -818,6 +826,7 @@
|
||||
case MRSH_WORD_COMMAND:
|
||||
case MRSH_WORD_ARITHMETIC:
|
||||
assert(false);
|
||||
+ return;
|
||||
case MRSH_WORD_LIST:;
|
||||
const struct mrsh_word_list *wl = mrsh_word_get_list(word);
|
||||
for (size_t i = 0; i < wl->children.len; ++i) {
|
||||
@@ -827,6 +836,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
|
||||
char *mrsh_word_str(const struct mrsh_word *word) {
|
||||
@@ -891,6 +901,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
case MRSH_NODE_COMMAND:;
|
||||
struct mrsh_command *cmd = mrsh_node_get_command(node);
|
||||
switch (cmd->type) {
|
||||
@@ -956,6 +967,7 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
case MRSH_NODE_WORD:;
|
||||
// TODO: quoting
|
||||
struct mrsh_word *word = mrsh_node_get_word(node);
|
||||
@@ -1002,8 +1014,10 @@
|
||||
return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
assert(false);
|
||||
+ return;
|
||||
}
|
||||
|
||||
char *mrsh_node_format(struct mrsh_node *node) {
|
||||
--- a/main.c 2020-02-03 18:40:40.433381483 +0300
|
||||
+++ b/main.c 2020-02-03 18:39:57.708015856 +0300
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <unistd.h>
|
||||
#include "frontend.h"
|
||||
|
||||
-extern char **environ;
|
||||
+// extern char **environ;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct mrsh_state *state = mrsh_state_create();
|
Loading…
Add table
Reference in a new issue