Ports: Add a kakoune port

This commit is contained in:
demostanis 2022-09-10 18:17:36 +02:00 committed by Linus Groh
parent 6880359064
commit fe94636ac3
Notes: sideshowbarker 2024-07-17 05:49:44 +09:00
5 changed files with 110 additions and 0 deletions

View file

@ -98,6 +98,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`joe`](joe/) | joe's own editor | 4.6 | https://joe-editor.sourceforge.io/ |
| [`jot`](jot/) | jot (OpenBSD) | 6.6 | https://github.com/ibara/libpuffy |
| [`jq`](jq/) | jq | 1.6 | https://stedolan.github.io/jq/ |
| [`kakoune`](kakoune/) | Modal text editor | 24d6072 | https://github.com/mawww/kakoune |
| [`klong`](klong/) | Klong | 20220315 | https://t3x.org/klong/ |
| [`less`](less/) | less | 590 | https://www.greenwoodsoftware.com/less/ |
| [`libarchive`](libarchive/) | libarchive | 3.6.1 | https://libarchive.org/ |

9
Ports/kakoune/package.sh Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env -S bash ../.port_include.sh
port='kakoune'
version='24d6072353f7c7e7cac84b4eb085036a8c852f96'
files="https://github.com/mawww/kakoune/archive/${version}.tar.gz ${version}.tar.gz 16440b204770972f318e24e4e178ada474b7cfeb029cefa69e9ff035700a129e"
auth_type='sha256'
depends=("bash" "sed")
makeopts+=(
"LDFLAGS=-L${DESTDIR}/usr/local/lib"
)

View file

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: demostanis <demostanis@protonmail.com>
Date: Sat, 10 Sep 2022 20:19:23 +0200
Subject: [PATCH] Use /proc/self/exe on SerenityOS
---
src/file.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/file.cc b/src/file.cc
index d38c956..9c74364 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -603,7 +603,7 @@ FsStatus get_fs_status(StringView filename)
String get_kak_binary_path()
{
char buffer[2048];
-#if defined(__linux__) or defined(__CYGWIN__) or defined(__gnu_hurd__)
+#if defined(__linux__) or defined(__CYGWIN__) or defined(__gnu_hurd__) or defined(__serenity__)
ssize_t res = readlink("/proc/self/exe", buffer, 2048);
kak_assert(res != -1);
buffer[res] = '\0';
--
2.37.3

View file

@ -0,0 +1,66 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: demostanis <demostanis@protonmail.com>
Date: Sat, 10 Sep 2022 23:32:51 +0200
Subject: [PATCH] Use bash instead of /bin/sh
---
src/shell_manager.cc | 43 +++++--------------------------------------
1 file changed, 5 insertions(+), 38 deletions(-)
diff --git a/src/shell_manager.cc b/src/shell_manager.cc
index 96cfb06..4eb71db 100644
--- a/src/shell_manager.cc
+++ b/src/shell_manager.cc
@@ -34,44 +34,11 @@ namespace Kakoune
ShellManager::ShellManager(ConstArrayView<EnvVarDesc> builtin_env_vars)
: m_env_vars{builtin_env_vars}
{
- auto is_executable = [](StringView path) {
- struct stat st;
- if (stat(path.zstr(), &st))
- return false;
-
- bool executable = (st.st_mode & S_IXUSR)
- | (st.st_mode & S_IXGRP)
- | (st.st_mode & S_IXOTH);
- return S_ISREG(st.st_mode) and executable;
- };
-
- if (const char* shell = getenv("KAKOUNE_POSIX_SHELL"))
- {
- if (not is_executable(shell))
- throw runtime_error{format("KAKOUNE_POSIX_SHELL '{}' is not executable", shell)};
- m_shell = shell;
- }
- else // Get a guaranteed to be POSIX shell binary
- {
- #if defined(_CS_PATH)
- auto size = confstr(_CS_PATH, nullptr, 0);
- String path; path.resize(size-1, 0);
- confstr(_CS_PATH, path.data(), size);
- #else
- StringView path = "/bin:/usr/bin";
- #endif
- for (auto dir : StringView{path} | split<StringView>(':'))
- {
- auto candidate = format("{}/sh", dir);
- if (is_executable(candidate))
- {
- m_shell = std::move(candidate);
- break;
- }
- }
- if (m_shell.empty())
- throw runtime_error{format("unable to find a posix shell in {}", path)};
- }
+ // We hardcode bash since /bin/sh (/bin/Shell) is not
+ // a POSIX-compliant shell, that will error out when
+ // fed with Kakoune's scripts. It is expected to be
+ // installed along with the port.
+ m_shell = "/usr/local/bin/bash";
// Add Kakoune binary location to the path to guarantee that %sh{ ... }
// have access to the kak command regardless of if the user installed it
--
2.37.3

View file

@ -0,0 +1,9 @@
# Patches for Kakoune on SerenityOS
## `0001-Use-proc-self-exe-on-SerenityOS.patch`
Use /proc/self/exe on SerenityOS
## `0002-Use-bash-instead-of-bin-sh.patch`
Use bash instead of /bin/sh