From babe053ad275863b83ee4cf34ae405527f900678 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Tue, 9 Jul 2019 20:10:09 +0300 Subject: [PATCH] st: implement openpty() in patch for android-5 to avoid specifying libutil in dependencies --- x11-packages/st/avoid-libutil.patch | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x11-packages/st/avoid-libutil.patch diff --git a/x11-packages/st/avoid-libutil.patch b/x11-packages/st/avoid-libutil.patch new file mode 100644 index 000000000..bc81c0ad0 --- /dev/null +++ b/x11-packages/st/avoid-libutil.patch @@ -0,0 +1,39 @@ +diff -uNr st-0.8.2/st.c st-0.8.2.mod/st.c +--- st-0.8.2/st.c 2019-02-09 13:50:41.000000000 +0200 ++++ st-0.8.2.mod/st.c 2019-07-09 20:07:26.109439488 +0300 +@@ -762,6 +762,35 @@ + perror("Couldn't call stty"); + } + ++#ifdef __ANDROID__ ++#if __ANDROID_API__ < 24 ++int openpty(int* amaster, int* aslave, char* name, const struct termios* termp, const struct winsize* winp) ++{ ++ char buf[512]; ++ ++ int master = open("/dev/ptmx", O_RDWR); ++ if (master == -1) return -1; ++ if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail; ++ ++ int slave = open(buf, O_RDWR | O_NOCTTY); ++ if (slave == -1) goto fail; ++ ++ /* XXX Should we ignore errors here? */ ++ if (termp) tcsetattr(slave, TCSANOW, termp); ++ if (winp) ioctl(slave, TIOCSWINSZ, winp); ++ ++ *amaster = master; ++ *aslave = slave; ++ if (name != NULL) strcpy(name, buf); ++ return 0; ++ ++fail: ++ close(master); ++ return -1; ++} ++#endif ++#endif ++ + int + ttynew(char *line, char *cmd, char *out, char **args) + {