From 4f789b90d69371235c3b58ffef848451ef19f9b3 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 02:10:11 +0100 Subject: [PATCH] Package libedit and libbsd for native network and X clients --- libbsd/PKGBUILD.vile | 27 +++++++++++++++++++++++++++ libedit/PKGBUILD.vile | 28 ++++++++++++++++++++++++++++ libedit/history.c | 16 ++++++++++++++++ libedit/wchar.c | 13 +++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 libbsd/PKGBUILD.vile create mode 100644 libedit/PKGBUILD.vile create mode 100644 libedit/history.c create mode 100644 libedit/wchar.c diff --git a/libbsd/PKGBUILD.vile b/libbsd/PKGBUILD.vile new file mode 100644 index 0000000..f0791f3 --- /dev/null +++ b/libbsd/PKGBUILD.vile @@ -0,0 +1,27 @@ +defpkgbuild(libbsd, + #:pkgname, "libbsd", + #:pkgver, "0.12.2", + #:pkgrel, 2, + #:pkgdesc, "BSD library functions and development headers", + #:arch, [#:x86-64, #:aarch64], + #:url, "https://libbsd.freedesktop.org/", + ; Upstream COPYING itemizes the BSD variants and additional notices by file. + #:license, ["BSD-2-Clause", "BSD-3-Clause", "Beerware", "ISC", "MIT", "LicenseRef-libbsd-COPYING"], + #:depends, ["musl", "libmd", "bsd-compat-headers"], + #:makedepends, ["linux-headers"], + #:source, ["https://libbsd.freedesktop.org/releases/libbsd-0.12.2.tar.xz"], + #:sha256sums, ["b88cc9163d0c652aaf39a99991d974ddba1c3a9711db8f1b5838af2a14731014"], + #:build, fn() { + run("vinix-configure", "libbsd-0.12.2/configure") + run("make") + }, + #:check, fn() { + run("make", "-C", "test", "endian", "overlay") + run("vinix-run", "--library-path", "src/.libs", "test/.libs/endian") + run("vinix-run", "--library-path", "src/.libs", "test/.libs/overlay") + }, + #:package, fn() { + run("make", "install", string-append("DESTDIR=", pkgdir())) + run("find", pkgdir(), "-name", "*.la", "-delete") + run("install", "-Dm644", "libbsd-0.12.2/COPYING", string-append(pkgdir(), "/usr/share/licenses/libbsd/COPYING")) + }) diff --git a/libedit/PKGBUILD.vile b/libedit/PKGBUILD.vile new file mode 100644 index 0000000..1b634a7 --- /dev/null +++ b/libedit/PKGBUILD.vile @@ -0,0 +1,28 @@ +defpkgbuild(libedit, + #:pkgname, "libedit", + #:pkgver, "20240808.3.1", + #:pkgrel, 1, + #:pkgdesc, "NetBSD command-line editing and history library", + #:arch, [#:x86-64, #:aarch64], + #:url, "https://www.thrysoee.dk/editline/", + #:license, "BSD-3-Clause", + #:depends, ["musl", "ncurses"], + #:source, ["https://www.thrysoee.dk/editline/libedit-20240808-3.1.tar.gz", "history.c", "wchar.c"], + #:sha256sums, ["5f0573349d77c4a48967191cdd6634dd7aa5f6398c6a57fe037cc02696d6099f", "a0fdb40f4681d9c4ff14e576c99eaf2c45d98c2e9869e91a9f3b992bc3ab3f3f", + "1ab07b1d432adad891ffe252bd62459ef05f4453fa1984fd46292eab7eb39a1b"], + #:build, fn() { + run("vinix-cc", "wchar.c", "-o", "check-wchar") + run("vinix-run", "./check-wchar") + run("env", "CPPFLAGS=-D__STDC_ISO_10646__=201103L", "vinix-configure", "libedit-20240808-3.1/configure") + run("make") + }, + #:check, fn() { + run("make", "install", string-append("DESTDIR=", srcdir(), "/checked")) + run("vinix-cc", "history.c", "-Ichecked/usr/include", "-Lchecked/usr/lib", "-o", "history-check", "-ledit") + run("vinix-run", "--library-path", "checked/usr/lib", "./history-check") + }, + #:package, fn() { + run("make", "install", string-append("DESTDIR=", pkgdir())) + run("find", pkgdir(), "-name", "*.la", "-delete") + run("install", "-Dm644", "libedit-20240808-3.1/COPYING", string-append(pkgdir(), "/usr/share/licenses/libedit/COPYING")) + }) diff --git a/libedit/history.c b/libedit/history.c new file mode 100644 index 0000000..c4ea301 --- /dev/null +++ b/libedit/history.c @@ -0,0 +1,16 @@ +#include +#include + +int main(void) { + HistEvent event; + History *history_state = history_init(); + if (!history_state) + return 1; + if (history(history_state, &event, H_SETSIZE, 4) < 0 || + history(history_state, &event, H_ENTER, "vinix") < 0 || + history(history_state, &event, H_FIRST) < 0 || + strcmp(event.str, "vinix") != 0) + return 1; + history_end(history_state); + return 0; +} diff --git a/libedit/wchar.c b/libedit/wchar.c new file mode 100644 index 0000000..7d2e0ed --- /dev/null +++ b/libedit/wchar.c @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +int main(void) { + if (!setlocale(LC_CTYPE, "C.UTF-8") || sizeof(wchar_t) != 4 || WCHAR_MAX < INT32_MAX) + return EXIT_FAILURE; + wchar_t wc; + mbstate_t state = {0}; + return mbrtowc(&wc, "\xf0\x9f\x8c\x8d", 4, &state) == 4 && wc == 0x1f30d + ? EXIT_SUCCESS : EXIT_FAILURE; +} -- 2.56.1