From 21accda0a9c3abde25fe54321b05e9014849f633 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 2 May 2016 01:27:20 -0400 Subject: [PATCH] mosh: Link against libutil for openpty and forkpty --- packages/mosh/build.sh | 2 +- packages/mosh/makefile.am.patch | 10 +-- packages/mosh/mosh.cc.patch | 4 +- packages/mosh/pty.cc.patch | 150 ---------------------------------------- packages/mosh/shittypty.h.patch | 38 ---------- 5 files changed, 8 insertions(+), 196 deletions(-) delete mode 100644 packages/mosh/pty.cc.patch delete mode 100644 packages/mosh/shittypty.h.patch diff --git a/packages/mosh/build.sh b/packages/mosh/build.sh index 44aa23f8..72689cb6 100644 --- a/packages/mosh/build.sh +++ b/packages/mosh/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=http://mosh.mit.edu/ TERMUX_PKG_DESCRIPTION="Mobile shell that supports roaming and intelligent local echo" TERMUX_PKG_VERSION=1.2.5.20160402 -TERMUX_PKG_BUILD_REVISION=1 +TERMUX_PKG_BUILD_REVISION=2 TERMUX_PKG_SRCURL=http://mosh.mit.edu/mosh-${TERMUX_PKG_VERSION}.tar.gz _COMMIT=f30738e3256e90850e945c08624fce90b1ba78a1 TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/archive/${_COMMIT}.zip diff --git a/packages/mosh/makefile.am.patch b/packages/mosh/makefile.am.patch index 4059c9b6..1a31a3cd 100644 --- a/packages/mosh/makefile.am.patch +++ b/packages/mosh/makefile.am.patch @@ -1,6 +1,7 @@ ---- ../mosh/src/frontend/Makefile.am 2016-04-08 10:26:08.000000000 +1000 -+++ ./src/frontend/Makefile.am 2016-04-29 00:42:03.147468293 +1000 -@@ -11,9 +11,14 @@ +diff -u -r ../mosh-f30738e3256e90850e945c08624fce90b1ba78a1/src/frontend/Makefile.am ./src/frontend/Makefile.am +--- ../mosh-f30738e3256e90850e945c08624fce90b1ba78a1/src/frontend/Makefile.am 2016-04-07 20:26:08.000000000 -0400 ++++ ./src/frontend/Makefile.am 2016-05-02 01:20:09.868867123 -0400 +@@ -11,9 +11,15 @@ bin_PROGRAMS += mosh-client endif @@ -14,4 +15,5 @@ mosh_client_SOURCES = mosh-client.cc stmclient.cc stmclient.h terminaloverlay.cc terminaloverlay.h mosh_server_SOURCES = mosh-server.cc -+mosh_cfront_SOURCES = mosh.cc pty.cc shittypty.h ++mosh_cfront_SOURCES = mosh.cc ++mosh_cfront_LDADD = -lutil diff --git a/packages/mosh/mosh.cc.patch b/packages/mosh/mosh.cc.patch index 1f303c2b..2f8e2889 100644 --- a/packages/mosh/mosh.cc.patch +++ b/packages/mosh/mosh.cc.patch @@ -1,6 +1,6 @@ --- ../mosh/src/frontend/mosh.cc 2016-04-29 00:42:24.837700203 +1000 +++ ./src/frontend/mosh.cc 2016-04-29 00:40:13.346294286 +1000 -@@ -0,0 +1,521 @@ +@@ -0,0 +1,519 @@ +// Mosh: the mobile shell +// Copyright 2012 Keith Winstein +// @@ -47,8 +47,6 @@ +#include +#endif + -+#include "shittypty.h" -+ +#if !HAVE_GETLINE +ssize_t getline( char ** restrict linep, + size_t * restrict linecapp, diff --git a/packages/mosh/pty.cc.patch b/packages/mosh/pty.cc.patch deleted file mode 100644 index 4f769f53..00000000 --- a/packages/mosh/pty.cc.patch +++ /dev/null @@ -1,150 +0,0 @@ ---- ../mosh/src/frontend/pty.cc 2016-04-29 00:42:37.207832463 +1000 -+++ ./src/frontend/pty.cc 2016-04-29 00:40:31.306486322 +1000 -@@ -0,0 +1,147 @@ -+/* -+ Mosh: the mobile shell -+ Copyright 2012 Keith Winstein -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation, either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . -+*/ -+ -+#include "config.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#ifndef HAVE_OPENPTY -+/* from dropbear 0.53.1 sshpty.c, original license: "can be used freely for any purpose." */ -+int my_openpty (int *amaster, int *aslave, char *name, const struct termios *termp, -+ const struct winsize *winp) -+{ -+ int master, slave; -+ char *name_slave; -+ -+ master = open("/dev/ptmx", O_RDWR); -+ if (master == -1) { -+// TRACE(("Fail to open master")) -+ return -1; -+ } -+ -+ if (grantpt(master)) -+ goto fail; -+ -+ if (unlockpt(master)) -+ goto fail; -+ -+ name_slave = ptsname(master); -+// TRACE(("openpty: slave name %s", name_slave)) -+ slave = open(name_slave, O_RDWR | O_NOCTTY); -+ if (slave == -1) -+ { -+ goto fail; -+ } -+ -+ if(termp) -+ tcsetattr(slave, TCSAFLUSH, termp); -+ if (winp) -+ ioctl (slave, TIOCSWINSZ, winp); -+ -+ *amaster = master; -+ *aslave = slave; -+ if (name != NULL) -+ strcpy(name, name_slave); -+ -+ return 0; -+ -+ fail: -+ close (master); -+ return -1; -+} -+#endif -+ -+#ifndef HAVE_LOGIN_TTY -+/* from glibc 2.14, login/login_tty.c, under the BSD license */ -+int login_tty(int fd) -+{ -+ (void) setsid(); -+#ifdef TIOCSCTTY -+ if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) -+ return (-1); -+#else -+ { -+ /* This might work. */ -+ char *fdname = ttyname (fd); -+ int newfd; -+ if (fdname) -+ { -+ if (fd != 0) -+ (void) close (0); -+ if (fd != 1) -+ (void) close (1); -+ if (fd != 2) -+ (void) close (2); -+ newfd = open (fdname, O_RDWR); -+ (void) close (newfd); -+ } -+ } -+#endif -+ while (dup2(fd, 0) == -1 && errno == EBUSY) -+ ; -+ while (dup2(fd, 1) == -1 && errno == EBUSY) -+ ; -+ while (dup2(fd, 2) == -1 && errno == EBUSY) -+ ; -+ if (fd > 2) -+ (void) close(fd); -+ return (0); -+} -+#endif -+ -+int my_forkpty (int *amaster, char *name, const struct termios *termp, const struct winsize *winp) { -+#ifdef HAVE_FORKPTY -+//return forkpty(amaster, name, termp, winp); -+#else -+/* from glibc 2.14, login/forkpty.c, under the LGPL 2.1 (or later) license */ -+ int master, slave, pid; -+ -+ if (openpty (&master, &slave, name, termp, winp) == -1) -+ return -1; -+ -+ switch (pid = fork ()) -+ { -+ case -1: -+ close (master); -+ close (slave); -+ return -1; -+ case 0: -+ /* Child. */ -+ close (master); -+ if (login_tty (slave)) -+ _exit (1); -+ -+ return 0; -+ default: -+ /* Parent. */ -+ *amaster = master; -+ close (slave); -+ -+ return pid; -+ } -+#endif -+} diff --git a/packages/mosh/shittypty.h.patch b/packages/mosh/shittypty.h.patch deleted file mode 100644 index c87c128b..00000000 --- a/packages/mosh/shittypty.h.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- ../mosh/src/frontend/shittypty.h 2016-04-29 00:42:50.787977659 +1000 -+++ ./src/frontend/shittypty.h 2016-04-29 00:40:48.256667557 +1000 -@@ -0,0 +1,35 @@ -+/* -+ Mosh: the mobile shell -+ Copyright 2012 Keith Winstein -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation, either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . -+*/ -+ -+#ifndef PTY_HPP -+#define PTY_HPP -+ -+#include "config.h" -+ -+#ifndef HAVE_FORKPTY -+#define forkpty my_forkpty -+int my_forkpty (int *amaster, char *name, const struct termios *termp, const struct winsize *winp); -+#endif -+ -+#ifndef HAVE_OPENPTY -+#define openpty my_openpty -+int my_openpty (int *amaster, int *aslave, char *name, const struct termios *termp, -+ const struct winsize *winp); -+#endif -+ -+#endif -- 2.11.0