Toggle diff (289 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 5fcbdd4586..b64d6fc966 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1384,6 +1384,10 @@ dist_patch_DATA = \
%D%/packages/patches/lightdm-arguments-ordering.patch \
%D%/packages/patches/lightdm-vncserver-check.patch \
%D%/packages/patches/lightdm-vnc-color-depth.patch \
+ %D%/packages/patches/linenoise-add-install-target.patch \
+ %D%/packages/patches/linenoise-add-symbol-map.patch \
+ %D%/packages/patches/linenoise-mark-internal-functions-static.patch \
+ %D%/packages/patches/linenoise-use-symbol-map.patch \
%D%/packages/patches/localed-xorg-keyboard.patch \
%D%/packages/patches/kcontacts-incorrect-country-name.patch \
%D%/packages/patches/kde-cli-tools-delay-mime-db.patch \
diff --git a/gnu/packages/patches/linenoise-add-install-target.patch
b/gnu/packages/patches/linenoise-add-install-target.patch
new file mode 100644
index 0000000000..7371126574
--- /dev/null
+++ b/gnu/packages/patches/linenoise-add-install-target.patch
@@ -0,0 +1,51 @@
+This patch is taken from https://github.com/antirez/linenoise/pull/174
+
+Subject: [PATCH] linenoise: Add a makefile for creating and installing
libraries and headers.
+--- a/GNUmakefile.libs 1970-01-01 07:30:00.000000000 +0730
++++ b/GNUmakefile.libs 2023-02-21 13:29:52.275610851 +0800
+@@ -0,0 +1,45 @@
++PREFIX ?= /usr/local
++INCLUDEDIR ?= $(PREFIX)/include
++LIBDIR ?= $(PREFIX)/lib
++
++SOURCES = linenoise.c
++HEADERS = $(SOURCES:%.c=%.h)
++OBJECTS = $(SOURCES:%.c=%.o)
++
++LIBVERSION = 0.0.0
++
++SHLIBNAME = liblinenoise.so.$(LIBVERSION)
++SONAME = liblinenoise.so.$(word 1, $(subst ., ,$(LIBVERSION)))
++STLIBNAME = liblinenoise.a
++
++LD = $(CC)
++
++DEFAULT_CPPFLAGS =
++DEFAULT_CFLAGS = -Wall -W -O2 -g -fPIC
++DEFAULT_LDFLAGS = -shared -Wl,-soname,$(SONAME)
++
++all: $(SHLIBNAME) $(STLIBNAME)
++
++$(SHLIBNAME): $(OBJECTS)
++ $(LD) $(DEFAULT_LDFLAGS) $(LDFLAGS) $^ -o $@
++
++$(STLIBNAME): $(OBJECTS)
++ $(AR) $(ARFLAGS) $@ $^
++
++$(OBJECTS) : %.o : %.c
++ $(CC) $(DEFAULT_CPPFLAGS) $(CPPFLAGS) $(DEFAULT_CFLAGS) $(CFLAGS) \
++ -c $< -o $@
++
++install: $(SHLIBNAME)
++ install -d $(DESTDIR)$(INCLUDEDIR)
++ install -m 0644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
++ install -d $(DESTDIR)$(LIBDIR)
++ install -m 0644 $(STLIBNAME) $(DESTDIR)$(LIBDIR)
++ install -m 0755 $(SHLIBNAME) $(DESTDIR)$(LIBDIR)
++ ln -sf $(SHLIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
++ ln -sf $(SHLIBNAME) $(DESTDIR)$(LIBDIR)/liblinenoise.so
++
++clean:
++ rm -f $(SHLIBNAME) $(STLIBNAME) $(OBJECTS)
++
++.PHONY: all clean install
diff --git a/gnu/packages/patches/linenoise-add-symbol-map.patch
b/gnu/packages/patches/linenoise-add-symbol-map.patch
new file mode 100644
index 0000000000..ec241e60b1
--- /dev/null
+++ b/gnu/packages/patches/linenoise-add-symbol-map.patch
@@ -0,0 +1,25 @@
+This patch is taken from https://github.com/antirez/linenoise/pull/174
+
+Subject: [PATCH] linenoise: Add a symbol-map for versioning symbols in
the shared library.
+--- a/symbol.map 1970-01-01 07:30:00.000000000 +0730
++++ b/symbol.map 2023-02-21 13:31:08.620340334 +0800
+@@ -0,0 +1,19 @@
++LINENOISE_0.0 {
++global:
++ linenoiseSetCompletionCallback;
++ linenoiseSetHintsCallback;
++ linenoiseSetFreeHintsCallback;
++ linenoiseAddCompletion;
++ linenoise;
++ linenoiseFree;
++ linenoiseHistoryAdd;
++ linenoiseHistorySetMaxLen;
++ linenoiseHistorySave;
++ linenoiseHistoryLoad;
++ linenoiseClearScreen;
++ linenoiseSetMultiLine;
++ linenoisePrintKeyCodes;
++
++local:
++ *;
++};
diff --git
a/gnu/packages/patches/linenoise-mark-internal-functions-static.patch
b/gnu/packages/patches/linenoise-mark-internal-functions-static.patch
new file mode 100644
index 0000000000..e08bb05f19
--- /dev/null
+++ b/gnu/packages/patches/linenoise-mark-internal-functions-static.patch
@@ -0,0 +1,95 @@
+This patch is adapted from https://github.com/antirez/linenoise/pull/174
+
+Subject: [PATCH] linenoise: Mark functions that are not part of the API
as static.
+--- a/linenoise.c 1970-01-01 07:30:01.000000000 +0730
++++ b/linenoise.c 2023-02-21 13:28:59.739080092 +0800
+@@ -473,7 +473,7 @@
+
+ /* Helper of refreshSingleLine() and refreshMultiLine() to show hints
+ * to the right of the prompt. */
+-void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int
plen) {
++static void refreshShowHints(struct abuf *ab, struct linenoiseState
*l, int plen) {
+ char seq[64];
+ if (hintsCallback && plen+l->len < l->cols) {
+ int color = -1, bold = 0;
+@@ -635,7 +637,7 @@
+ /* Insert the character 'c' at cursor current position.
+ *
+ * On error writing to the terminal -1 is returned, otherwise 0. */
+-int linenoiseEditInsert(struct linenoiseState *l, char c) {
++static int linenoiseEditInsert(struct linenoiseState *l, char c) {
+ if (l->len < l->buflen) {
+ if (l->len == l->pos) {
+ l->buf[l->pos] = c;
+@@ -662,7 +664,7 @@
+ }
+
+ /* Move cursor on the left. */
+-void linenoiseEditMoveLeft(struct linenoiseState *l) {
++static void linenoiseEditMoveLeft(struct linenoiseState *l) {
+ if (l->pos > 0) {
+ l->pos--;
+ refreshLine(l);
+@@ -670,7 +672,7 @@
+ }
+
+ /* Move cursor on the right. */
+-void linenoiseEditMoveRight(struct linenoiseState *l) {
++static void linenoiseEditMoveRight(struct linenoiseState *l) {
+ if (l->pos != l->len) {
+ l->pos++;
+ refreshLine(l);
+@@ -678,7 +680,7 @@
+ }
+
+ /* Move cursor to the start of the line. */
+-void linenoiseEditMoveHome(struct linenoiseState *l) {
++static void linenoiseEditMoveHome(struct linenoiseState *l) {
+ if (l->pos != 0) {
+ l->pos = 0;
+ refreshLine(l);
+@@ -686,7 +688,7 @@
+ }
+
+ /* Move cursor to the end of the line. */
+-void linenoiseEditMoveEnd(struct linenoiseState *l) {
++static void linenoiseEditMoveEnd(struct linenoiseState *l) {
+ if (l->pos != l->len) {
+ l->pos = l->len;
+ refreshLine(l);
+@@ -697,7 +699,7 @@
+ * entry as specified by 'dir'. */
+ #define LINENOISE_HISTORY_NEXT 0
+ #define LINENOISE_HISTORY_PREV 1
+-void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
++static void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
+ if (history_len > 1) {
+ /* Update the current history entry before to
+ * overwrite it with the next one. */
+@@ -721,7 +723,7 @@
+
+ /* Delete the character at the right of the cursor without altering
the cursor
+ * position. Basically this is what happens with the "Delete" keyboard
key. */
+-void linenoiseEditDelete(struct linenoiseState *l) {
++static void linenoiseEditDelete(struct linenoiseState *l) {
+ if (l->len > 0 && l->pos < l->len) {
+ memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1);
+ l->len--;
+@@ -731,7 +733,7 @@
+ }
+
+ /* Backspace implementation. */
+-void linenoiseEditBackspace(struct linenoiseState *l) {
++static void linenoiseEditBackspace(struct linenoiseState *l) {
+ if (l->pos > 0 && l->len > 0) {
+ memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos);
+ l->pos--;
+@@ -743,7 +745,7 @@
+
+ /* Delete the previosu word, maintaining the cursor at the start of the
+ * current word. */
+-void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
++static void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
+ size_t old_pos = l->pos;
+ size_t diff;
+
diff --git a/gnu/packages/patches/linenoise-use-symbol-map.patch
b/gnu/packages/patches/linenoise-use-symbol-map.patch
new file mode 100644
index 0000000000..c58378adf1
--- /dev/null
+++ b/gnu/packages/patches/linenoise-use-symbol-map.patch
@@ -0,0 +1,14 @@
+This patch is taken from https://github.com/antirez/linenoise/pull/174
+
+Subject: [PATCH] linenoise: Add a symbol-map for versioning symbols in
the shared library.
+--- a/GNUmakefile.libs 2023-02-21 13:29:52.275610851 +0800
++++ b/GNUmakefile.libs 2023-02-21 13:30:55.336216832 +0800
+@@ -16,7 +16,7 @@
+
+ DEFAULT_CPPFLAGS =
+ DEFAULT_CFLAGS = -Wall -W -O2 -g -fPIC
+-DEFAULT_LDFLAGS = -shared -Wl,-soname,$(SONAME)
++DEFAULT_LDFLAGS = -shared -Wl,-soname,$(SONAME)
-Wl,--version-script=symbol.map
+
+ all: $(SHLIBNAME) $(STLIBNAME)
+
diff --git a/gnu/packages/shells.scm b/gnu/packages/shells.scm
index 0c8cbf3f4c..8561db835f 100644
--- a/gnu/packages/shells.scm
+++ b/gnu/packages/shells.scm
@@ -658,27 +658,25 @@ (define-public linenoise
(uri (git-reference
(url "https://github.com/antirez/linenoise")
(commit commit)))
- (file-name (string-append name "-" version "-checkout"))
+ (file-name (git-file-name name version))
(sha256
(base32
- "1z16qwix8z6a40fskdgxsibkqgdrp4q6ncp4n6hnv4r9iihy2d8r"))))
+ "1z16qwix8z6a40fskdgxsibkqgdrp4q6ncp4n6hnv4r9iihy2d8r"))
+ (patches (search-patches
+ "linenoise-mark-internal-functions-static.patch"
+ "linenoise-add-install-target.patch"
+ "linenoise-add-symbol-map.patch"
+ "linenoise-use-symbol-map.patch"))))
(build-system gnu-build-system)
(arguments
- `(#:tests? #f ; no tests are included
- #:make-flags
- (list ,(string-append "CC=" (cc-for-target)))
- #:phases
- (modify-phases %standard-phases
- (delete 'configure)
- (replace 'install
- (lambda* (#:key outputs #:allow-other-keys)
- ;; At the moment there is no 'make install' in upstream.
- (let* ((out (assoc-ref outputs "out")))
- (install-file "linenoise.h"
- (string-append out "/include/linenoise"))
- (install-file "linenoise.c"
- (string-append out "/include/linenoise"))
- #t))))))
+ (list #:tests? #f ; no tests are included
+ #:make-flags
+ #~(list (string-append "CC=" #$(cc-for-target))
+ (string-append "PREFIX=" #$output)
+ "--makefile=GNUmakefile.libs")
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure))))
(home-page "https://github.com/antirez/linenoise")
(synopsis "Minimal zero-config readline replacement")
(description
base-commit: 08edbd2535ae622d319a51e6f877d23d75dc24f3
--
2.39.1