Browse Source

tmux and neovim: Use the new libutil library

android-5
Fredrik Fornwall 9 years ago
parent
commit
87745886da
  1. 2
      packages/neovim/build.sh
  2. 79
      packages/neovim/forkpty-android.patch
  3. 11
      packages/neovim/src-nvim-CMakeLists.txt.patch
  4. 2
      packages/tmux/build.sh
  5. 67
      packages/tmux/tmux.patch

2
packages/neovim/build.sh

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Ambitious Vim-fork focused on extensibility and agility
TERMUX_PKG_VERSION=0.0.`date "+%Y%m%d%H%M"`
TERMUX_PKG_SRCURL=https://github.com/neovim/neovim/archive/master.zip
TERMUX_PKG_NO_SRC_CACHE=yes
TERMUX_PKG_DEPENDS="libuv, libmsgpack, libandroid-support, libluajit, libvterm, libtermkey"
TERMUX_PKG_DEPENDS="libuv, libmsgpack, libandroid-support, libluajit, libvterm, libtermkey, libutil"
TERMUX_PKG_FOLDERNAME="neovim-master"
TERMUX_PKG_HOSTBUILD=true

79
packages/neovim/forkpty-android.patch

@ -1,79 +0,0 @@
diff -N -u -r ../neovim-master/src/nvim/event/forkpty-android.h ./src/nvim/event/forkpty-android.h
--- ../neovim-master/src/nvim/event/forkpty-android.h 1969-12-31 19:00:00.000000000 -0500
+++ ./src/nvim/event/forkpty-android.h 2015-03-23 18:59:01.425165645 -0400
@@ -0,0 +1,63 @@
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <unistd.h>
+
+int login_tty(int fd)
+{
+ setsid();
+ if (ioctl(fd, TIOCSCTTY, NULL) == -1) return -1;
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ if (fd > 2) close(fd);
+ return 0;
+}
+
+int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
+{
+ char buf[512];
+ int master, slave;
+
+ master = open("/dev/ptmx", O_RDWR);
+ if (master == -1) return -1;
+ if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail;
+
+ slave = open(buf, O_RDWR | O_NOCTTY);
+ if (slave == -1) goto fail;
+
+ /* XXX Should we ignore errors here? */
+ if (termp) tcsetattr(slave, TCSAFLUSH, termp);
+ if (winp) ioctl(slave, TIOCSWINSZ, winp);
+
+ *amaster = master;
+ *aslave = slave;
+ if (name != NULL) strcpy(name, buf);
+ return 0;
+
+fail:
+ close(master);
+ return -1;
+}
+
+
+int forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
+{
+ int master, slave, pid;
+ if (openpty(&master, &slave, name, termp, winp) == -1) return -1;
+ switch (pid = fork()) {
+ case -1:
+ return -1;
+ case 0:
+ close(master);
+ if (login_tty (slave)) _exit (1);
+ return 0;
+ default:
+ *amaster = master;
+ close (slave);
+ return pid;
+ }
+}
diff -N -u -r ../neovim-master/src/nvim/event/pty_process.c ./src/nvim/event/pty_process.c
--- ../neovim-master/src/nvim/event/pty_process.c 2015-03-21 08:21:51.000000000 -0400
+++ ./src/nvim/event/pty_process.c 2015-03-23 18:58:27.561165621 -0400
@@ -14,6 +14,8 @@
# include <libutil.h>
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
# include <util.h>
+#elif defined(__ANDROID__)
+# include "forkpty-android.h"
#else
# include <pty.h>
#endif

11
packages/neovim/src-nvim-CMakeLists.txt.patch

@ -1,11 +0,0 @@
diff -u -r ../neovim-master/src/nvim/CMakeLists.txt ./src/nvim/CMakeLists.txt
--- ../neovim-master/src/nvim/CMakeLists.txt 2015-09-10 20:52:25.000000000 -0400
+++ ./src/nvim/CMakeLists.txt 2015-09-11 10:12:10.807065155 -0400
@@ -235,7 +235,6 @@
if(UNIX)
list(APPEND NVIM_LINK_LIBRARIES
m
- util
)
endif()

2
packages/tmux/build.sh

@ -1,6 +1,6 @@
TERMUX_PKG_HOMEPAGE=http://tmux.github.io/
TERMUX_PKG_DESCRIPTION="Terminal multiplexer implementing switching between several programs in one terminal, detaching them and reattaching them to a different terminal"
TERMUX_PKG_DEPENDS="ncurses, libevent"
TERMUX_PKG_DEPENDS="ncurses, libevent, libutil"
TERMUX_PKG_VERSION=2.0
TERMUX_PKG_BUILD_REVISION=3
TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/tmux/tmux/tmux-${TERMUX_PKG_VERSION}/tmux-${TERMUX_PKG_VERSION}.tar.gz

67
packages/tmux/tmux.patch

@ -1,70 +1,3 @@
diff -u -r -N ../tmux-1.8/compat/forkpty-linux.c ./compat/forkpty-linux.c
--- ../tmux-1.8/compat/forkpty-linux.c 1970-01-01 01:00:00.000000000 +0100
+++ ./compat/forkpty-linux.c 2014-01-08 12:44:00.885192436 +0100
@@ -0,0 +1,63 @@
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <unistd.h>
+
+int login_tty(int fd)
+{
+ setsid();
+ if (ioctl(fd, TIOCSCTTY, NULL) == -1) return -1;
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ if (fd > 2) close(fd);
+ return 0;
+}
+
+int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
+{
+ char buf[512];
+ int master, slave;
+
+ master = open("/dev/ptmx", O_RDWR);
+ if (master == -1) return -1;
+ if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail;
+
+ slave = open(buf, O_RDWR | O_NOCTTY);
+ if (slave == -1) goto fail;
+
+ /* XXX Should we ignore errors here? */
+ if (termp) tcsetattr(slave, TCSAFLUSH, termp);
+ if (winp) ioctl(slave, TIOCSWINSZ, winp);
+
+ *amaster = master;
+ *aslave = slave;
+ if (name != NULL) strcpy(name, buf);
+ return 0;
+
+fail:
+ close(master);
+ return -1;
+}
+
+
+int forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
+{
+ int master, slave, pid;
+ if (openpty(&master, &slave, name, termp, winp) == -1) return -1;
+ switch (pid = fork()) {
+ case -1:
+ return -1;
+ case 0:
+ close(master);
+ if (login_tty (slave)) _exit (1);
+ return 0;
+ default:
+ *amaster = master;
+ close (slave);
+ return pid;
+ }
+}
diff -u -r -N ../tmux-1.8/compat/imsg-buffer.c ./compat/imsg-buffer.c
--- ../tmux-1.8/compat/imsg-buffer.c 2013-02-10 17:20:15.000000000 +0100
+++ ./compat/imsg-buffer.c 2014-01-08 12:33:53.721206934 +0100

Loading…
Cancel
Save