Diff below adds a new option for the libvte to rely on openpty(3) to
allocate a pseudo-tty. With it, we no longer need the gnome-pty-helper.

If you use a terminal relying on the libvte, please test this diff and
report any breakage and/or improvement. Oks are also welcome ;)


Martin


Index: vte/Makefile
===================================================================
RCS file: /cvs/ports/devel/vte/Makefile,v
retrieving revision 1.95
diff -u -p -r1.95 Makefile
--- vte/Makefile        6 Feb 2012 22:07:09 -0000       1.95
+++ vte/Makefile        23 Feb 2012 16:08:42 -0000
@@ -14,7 +14,7 @@ SHARED_LIBS+= vte     14.1    # 2609.0
 FULLPKGNAME-main=      vte-${GNOME_VERSION}
 FULLPKGNAME-python=    py-${DISTNAME}
 
-REVISION-main =                5
+REVISION-main =                6
 REVISION-python =      3
 
 CATEGORIES=            devel
@@ -39,7 +39,7 @@ WANTLIB += Xi Xinerama Xrandr Xrender Xx
 WANTLIB += expat ffi fontconfig freetype gdk_pixbuf-2.0 gio-2.0
 WANTLIB += glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0 m ncurses
 WANTLIB += pango-1.0 pangocairo-1.0 pangoft2-1.0 pcre pixman-1
-WANTLIB += png pthread-stubs xcb xcb-render xcb-shm z
+WANTLIB += png pthread-stubs stdc++ util xcb xcb-render xcb-shm z
 
 
 MODPY_RUNDEP=          No
@@ -63,8 +63,13 @@ CONFIGURE_ARGS+=     --enable-python
 
 MODGNOME_TOOLS=        goi
 
-CONFIGURE_STYLE=       gnu
+AUTOCONF_VERSION=      2.68
+AUTOMAKE_VERSION=      1.11
+
+CONFIGURE_STYLE=       autoconf
 CONFIGURE_ARGS+=       --disable-Bsymbolic \
+                       --disable-gnome-pty-helper \
+                       --enable-bsd-pty \
                        --with-gtk=2.0 \
                        --program-suffix=2
 
Index: vte/patches/patch-src_pty_c
===================================================================
RCS file: /cvs/ports/devel/vte/patches/patch-src_pty_c,v
retrieving revision 1.9
diff -u -p -r1.9 patch-src_pty_c
--- vte/patches/patch-src_pty_c 26 Sep 2011 14:25:09 -0000      1.9
+++ vte/patches/patch-src_pty_c 23 Feb 2012 16:07:28 -0000
@@ -1,94 +1,90 @@
-$OpenBSD: patch-src_pty_c,v 1.9 2011/09/26 14:25:09 jasper Exp $
+$OpenBSD$
 
-- Party revert to previous behaviour of returning -1, instead of failing
-  to compile.
+Use openpty(3) backend instead of gnome-pty-helper
 
-- Adjust gnome-pty-helper2 binary name.
-
---- src/pty.c.orig     Tue Aug 16 23:52:48 2011
-+++ src/pty.c  Mon Sep 26 15:44:22 2011
-@@ -795,7 +795,8 @@ _vte_pty_ptsname(int master,
-                     "%s failed: %s", "ioctl(TIOCGPTN)", g_strerror(errno));
-         return NULL;
- #else
--#error no ptsname implementation for this platform
-+#warning no ptsname implementation for this platform
-+      return NULL;
+--- src/pty.c
++++ src/pty.c
+@@ -54,6 +54,9 @@
+ #include <termios.h>
  #endif
+ #include <unistd.h>
++#ifdef HAVE_UTIL_H
++#include <util.h>
++#endif
+ #ifdef HAVE_STROPTS_H
+ #include <stropts.h>
+ #endif
+@@ -734,6 +737,7 @@ vte_pty_get_size(VtePty *pty,
+       }
  }
  
-@@ -903,7 +904,8 @@ _vte_pty_unlockpt(int fd,
-         }
++#ifndef VTE_USE_BSD_PTY
+ /*
+  * _vte_pty_ptsname:
+  * @master: file descriptor to the PTY master
+@@ -951,6 +955,44 @@ _vte_pty_open_unix98(VtePty *pty,
          return TRUE;
- #else
--#error no unlockpt implementation for this platform
-+#warning no unlockpt implementation for this platform
-+      return -1;
- #endif
  }
  
-@@ -1181,8 +1183,8 @@ _vte_pty_start_helper(GError **error)
-               close(tunnel);
-               close(_vte_pty_helper_tunnel);
-               /* Exec our helper. */
--              execl(LIBEXECDIR "/gnome-pty-helper",
--                    "gnome-pty-helper", NULL);
-+              execl(LIBEXECDIR "/gnome-pty-helper2",
-+                    "gnome-pty-helper2", NULL);
-               /* Bail. */
-               _exit(1);
-       }
-@@ -1197,7 +1199,7 @@ failure:
- 
-         g_set_error(error, VTE_PTY_ERROR,
-                     VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                    "Failed to start gnome-pty-helper: %s",
-+                    "Failed to start gnome-pty-helper2: %s",
-                     g_strerror (errsv));
++#else
++/*
++ * _vte_pty_open_bsd:
++ * @pty: a #VtePty
++ * @error: a location to store a #GError, or %NULL
++ *
++ * Opens new file descriptors to a new PTY master and slave.
++ *
++ * Returns: %TRUE on success, %FALSE on failure with @error filled in
++ */
++static gboolean
++_vte_pty_open_bsd(VtePty *pty,
++                  GError **error)
++{
++#ifdef HAVE_OPENPTY
++        VtePtyPrivate *priv = pty->priv;
++      int parentfd, childfd;
++
++      if (openpty(&parentfd, &childfd, NULL, NULL, NULL) != 0) {
++                int errsv = errno;
++                g_set_error(error, VTE_PTY_ERROR, VTE_PTY_ERROR_PTY98_FAILED,
++                            "%s failed: %s", "openpty", g_strerror(errsv));
++                errno = errsv;
++              return FALSE;
++      }
++
++        priv->pty_fd = parentfd;
++        priv->child_setup_data.mode = TTY_OPEN_BY_FD;
++        priv->child_setup_data.tty.fd = childfd;
++        priv->using_helper = FALSE;
++
++        return TRUE;
++#else
++#error no openpty implementation for this platform
++#endif
++}
++#endif /* VTE_USE_BSD_PTY */
++
+ #ifdef VTE_USE_GNOME_PTY_HELPER
+ #ifdef HAVE_RECVMSG
+ static void
+@@ -1511,7 +1553,7 @@ vte_pty_initable_init (GInitable *initable,
+                 }
  
-         if (tmp[0] != -1)
-@@ -1285,7 +1287,7 @@ _vte_pty_open_with_helper(VtePty *pty,
-                     &ops, sizeof(ops)) != sizeof(ops)) {
-                 g_set_error (error, VTE_PTY_ERROR,
-                               VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                              "Failed to send request to gnome-pty-helper: 
%s",
-+                              "Failed to send request to gnome-pty-helper2: 
%s",
-                               g_strerror(errno));
-                 return FALSE;
-         }
-@@ -1295,7 +1297,7 @@ _vte_pty_open_with_helper(VtePty *pty,
-                     &ret, sizeof(ret)) != sizeof(ret)) {
-                 g_set_error (error, VTE_PTY_ERROR,
-                               VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                              "Failed to read response from gnome-pty-helper: 
%s",
-+                              "Failed to read response from 
gnome-pty-helper2: %s",
-                               g_strerror(errno));
-                 return FALSE;
+                 g_error_free(err);
+-                /* Fall back to unix98 PTY */
++                /* Fall back to unix98 or bsd PTY */
          }
-@@ -1304,7 +1306,7 @@ _vte_pty_open_with_helper(VtePty *pty,
-         if (ret == 0) {
-                 g_set_error_literal (error, VTE_PTY_ERROR,
-                                       VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                                      "gnome-pty-helper failed to open pty");
-+                                      "gnome-pty-helper2 failed to open pty");
-                 return FALSE;
-         }
-         _vte_debug_print(VTE_DEBUG_PTY, "Helper returns success.\n");
-@@ -1313,7 +1315,7 @@ _vte_pty_open_with_helper(VtePty *pty,
-                     &tag, sizeof(tag)) != sizeof(tag)) {
-                 g_set_error (error, VTE_PTY_ERROR,
-                               VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                              "Failed to read tag from gnome-pty-helper: %s",
-+                              "Failed to read tag from gnome-pty-helper2: %s",
-                               g_strerror(errno));
-                 return FALSE;
+ #else
+         if (priv->flags & VTE_PTY_NO_FALLBACK) {
+@@ -1521,7 +1563,11 @@ vte_pty_initable_init (GInitable *initable,
          }
-@@ -1330,7 +1332,7 @@ _vte_pty_open_with_helper(VtePty *pty,
+ #endif /* VTE_USE_GNOME_PTY_HELPER */
+ 
++#ifndef VTE_USE_BSD_PTY
+         ret = _vte_pty_open_unix98(pty, error);
++#else
++      ret = _vte_pty_open_bsd(pty, error);
++#endif /* VTE_USE_BSD_PTY */
  
-                 g_set_error (error, VTE_PTY_ERROR,
-                               VTE_PTY_ERROR_PTY_HELPER_FAILED,
--                              "Failed to read master or slave pty from 
gnome-pty-helper: %s",
-+                              "Failed to read master or slave pty from 
gnome-pty-helper2: %s",
-                               g_strerror(errsv));
-                 errno = errsv;
-                 return FALSE;
+   out:
+       _vte_debug_print(VTE_DEBUG_PTY,
Index: vte/pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/devel/vte/pkg/PLIST-main,v
retrieving revision 1.19
diff -u -p -r1.19 PLIST-main
--- vte/pkg/PLIST-main  6 Feb 2012 22:07:09 -0000       1.19
+++ vte/pkg/PLIST-main  13 Feb 2012 10:27:22 -0000
@@ -21,11 +21,6 @@ lib/libvte.la
 @lib lib/libvte.so.${LIBvte_VERSION}
 lib/pkgconfig/vte.pc
 lib/python${MODPY_VERSION}/site-packages/gtk-2.0/
-@mode g+s
-@group utmp
-@bin libexec/gnome-pty-helper2
-@mode
-@group
 share/gir-1.0/Vte-0.0.gir
 share/gtk-doc/html/vte-0.0/
 share/gtk-doc/html/vte-0.0/VteReaper.html
Index: vte3//Makefile
===================================================================
RCS file: /cvs/ports/devel/vte3/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- vte3//Makefile      6 Feb 2012 22:07:09 -0000       1.10
+++ vte3//Makefile      23 Feb 2012 16:08:09 -0000
@@ -6,7 +6,7 @@ GNOME_PROJECT=          vte
 GNOME_VERSION=         0.30.1
 
 PKGNAME=               vte3-${GNOME_VERSION}
-REVISION=              1
+REVISION=              2
 
 SHARED_LIBS +=  vte2_90                   1.0 # 3009.0
 
@@ -32,13 +32,18 @@ WANTLIB += cairo-gobject drm expat ffi f
 WANTLIB += gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0
 WANTLIB += gthread-2.0 gtk-3 m ncurses pango-1.0 pangocairo-1.0
 WANTLIB += pangoft2-1.0 pcre pixman-1 png pthread pthread-stubs
-WANTLIB += util xcb xcb-render xcb-shm z
+WANTLIB += stdc++ util xcb xcb-render xcb-shm z
 
 LIB_DEPENDS=           x11/gtk+3
 
 MODGNOME_TOOLS=        goi
 
-CONFIGURE_STYLE=       gnu
+AUTOCONF_VERSION=      2.68
+AUTOMAKE_VERSION=      1.11
+
+CONFIGURE_STYLE=       autoconf
 CONFIGURE_ARGS+=       --disable-Bsymbolic \
+                       --disable-gnome-pty-helper \
+                       --enable-bsd-pty
 
 .include <bsd.port.mk>
Index: vte3//patches/patch-configure_in
===================================================================
RCS file: vte3//patches/patch-configure_in
diff -N vte3//patches/patch-configure_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ vte3//patches/patch-configure_in    21 Feb 2012 11:27:49 -0000
@@ -0,0 +1,51 @@
+$OpenBSD$
+
+Support for the openpty(3) backend.
+
+--- configure.in
++++ configure.in
+@@ -313,7 +313,7 @@ AC_SUBST(VTE_DEFAULT_EMULATION)
+ AM_CONDITIONAL(VTE_DEFAULT_EMULATION, [test "$emulation" != xterm])
+ 
+ # Check for headers.
+-AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h 
sys/wait.h stropts.h termios.h wchar.h)
++AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h 
sys/wait.h stropts.h termios.h util.h wchar.h)
+ AC_HEADER_TIOCGWINSZ
+ 
+ # Check for PTY handling functions.
+@@ -324,6 +324,7 @@ AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid 
getpt grantpt unlockpt pts
+ 
AC_CHECK_FUNC(socket,[have_socket=1],AC_CHECK_LIB(socket,socket,[have_socket=1; 
LIBS="$LIBS -lsocket"]))
+ 
AC_CHECK_FUNC(socketpair,[have_socketpair=1],AC_CHECK_LIB(socket,socketpair,[have_socketpair=1;
 LIBS="$LIBS -lsocket"]))
+ 
AC_CHECK_FUNC(recvmsg,[have_recvmsg=1],AC_CHECK_LIB(socket,recvmsg,[have_recvmsg=1;
 LIBS="$LIBS -lsocket -lnsl"]))
++AC_CHECK_FUNC(openpty,[have_openpty=1],AC_CHECK_LIB(util,openpty,[have_openpty=1;
 LIBS="$LIBS -lutil"]))
+ if test x$have_socket = x1 ; then
+       AC_DEFINE(HAVE_SOCKET,1,[Define if you have the socket function.])
+ fi
+@@ -333,6 +334,9 @@ fi
+ if test x$have_recvmsg = x1 ; then
+       AC_DEFINE(HAVE_RECVMSG,1,[Define if you have the recvmsg function.])
+ fi
++if test x$have_openpty = x1 ; then
++      AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
++fi
+ AC_CHECK_FUNC(floor,,AC_CHECK_LIB(m,floor,LIBS=["$LIBS -lm"]))
+ AC_CHECK_FUNCS([ceil floor])
+ 
+@@ -423,6 +427,17 @@ fi
+ AM_CONDITIONAL(BUILD_GNOME_PTY_HELPER,[test "$enable_gnome_pty_helper" != no])
+ 
+ 
################################################################################
++# BSD PTY
++################################################################################
++
++AC_ARG_ENABLE(bsd-pty, [AS_HELP_STRING(--enable-bsd-pty,Support bsd rather 
than unix98 ptys [default=no])], enable_bsd_pty="$enableval", 
enable_bsd_pty=yes)
++if test "$enable_bsd_pty" != no; then
++      AC_DEFINE(VTE_USE_BSD_PTY,1,[Define if you intend to use bsd-pty.])
++      AC_CONFIG_SUBDIRS(bsd-pty)
++fi
++AM_CONDITIONAL(BUILD_BSD_PTY,[test "$enable_bsd_pty" != no])
++
++################################################################################
+ # Glade catalogue
+ 
################################################################################
+ 
Index: vte3//patches/patch-gnome-pty-helper_Makefile_in
===================================================================
RCS file: vte3//patches/patch-gnome-pty-helper_Makefile_in
diff -N vte3//patches/patch-gnome-pty-helper_Makefile_in
--- vte3//patches/patch-gnome-pty-helper_Makefile_in    26 Sep 2011 14:31:33 
-0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-$OpenBSD: patch-gnome-pty-helper_Makefile_in,v 1.1.1.1 2011/09/26 14:31:33 
jasper Exp $
-
-Don't bother calling install-exec-hook. We already adjust
-permissions in PLIST.
-
---- gnome-pty-helper/Makefile.in.orig  Mon Sep 26 15:48:00 2011
-+++ gnome-pty-helper/Makefile.in       Mon Sep 26 15:49:08 2011
-@@ -580,7 +580,7 @@ install-dvi-am:
- 
- install-exec-am: install-libexecPROGRAMS
-       @$(NORMAL_INSTALL)
--      $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
-+      $(MAKE) $(AM_MAKEFLAGS)
- install-html: install-html-am
- 
- install-html-am:
Index: vte3//patches/patch-src_pty_c
===================================================================
RCS file: /cvs/ports/devel/vte3/patches/patch-src_pty_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-src_pty_c
--- vte3//patches/patch-src_pty_c       26 Sep 2011 14:31:33 -0000      1.1.1.1
+++ vte3//patches/patch-src_pty_c       21 Feb 2012 11:29:59 -0000
@@ -1,27 +1,90 @@
-$OpenBSD: patch-src_pty_c,v 1.1.1.1 2011/09/26 14:31:33 jasper Exp $
+$OpenBSD$
 
-Party revert to previous behaviour of returning -1, instead of failing
-to compile.
+Use openpty(3) backend instead of gnome-pty-helper
 
---- src/pty.c.orig     Mon Aug 29 13:16:26 2011
-+++ src/pty.c  Mon Sep 26 15:46:55 2011
-@@ -795,7 +795,8 @@ _vte_pty_ptsname(int master,
-                     "%s failed: %s", "ioctl(TIOCGPTN)", g_strerror(errno));
-         return NULL;
- #else
--#error no ptsname implementation for this platform
-+#warning no ptsname implementation for this platform
-+      return NULL;
+--- src/pty.c
++++ src/pty.c
+@@ -54,6 +54,9 @@
+ #include <termios.h>
+ #endif
+ #include <unistd.h>
++#ifdef HAVE_UTIL_H
++#include <util.h>
++#endif
+ #ifdef HAVE_STROPTS_H
+ #include <stropts.h>
  #endif
+@@ -734,6 +737,7 @@ vte_pty_get_size(VtePty *pty,
+       }
  }
  
-@@ -903,7 +904,8 @@ _vte_pty_unlockpt(int fd,
-         }
++#ifndef VTE_USE_BSD_PTY
+ /*
+  * _vte_pty_ptsname:
+  * @master: file descriptor to the PTY master
+@@ -951,6 +955,44 @@ _vte_pty_open_unix98(VtePty *pty,
          return TRUE;
- #else
--#error no unlockpt implementation for this platform
-+#warning no unlockpt implementation for this platform
-+      return -1;
- #endif
  }
  
++#else
++/*
++ * _vte_pty_open_bsd:
++ * @pty: a #VtePty
++ * @error: a location to store a #GError, or %NULL
++ *
++ * Opens new file descriptors to a new PTY master and slave.
++ *
++ * Returns: %TRUE on success, %FALSE on failure with @error filled in
++ */
++static gboolean
++_vte_pty_open_bsd(VtePty *pty,
++                  GError **error)
++{
++#ifdef HAVE_OPENPTY
++        VtePtyPrivate *priv = pty->priv;
++      int parentfd, childfd;
++
++      if (openpty(&parentfd, &childfd, NULL, NULL, NULL) != 0) {
++                int errsv = errno;
++                g_set_error(error, VTE_PTY_ERROR, VTE_PTY_ERROR_PTY98_FAILED,
++                            "%s failed: %s", "openpty", g_strerror(errsv));
++                errno = errsv;
++              return FALSE;
++      }
++
++        priv->pty_fd = parentfd;
++        priv->child_setup_data.mode = TTY_OPEN_BY_FD;
++        priv->child_setup_data.tty.fd = childfd;
++        priv->using_helper = FALSE;
++
++        return TRUE;
++#else
++#error no openpty implementation for this platform
++#endif
++}
++#endif /* VTE_USE_BSD_PTY */
++
+ #ifdef VTE_USE_GNOME_PTY_HELPER
+ #ifdef HAVE_RECVMSG
+ static void
+@@ -1511,7 +1553,7 @@ vte_pty_initable_init (GInitable *initable,
+                 }
+ 
+                 g_error_free(err);
+-                /* Fall back to unix98 PTY */
++                /* Fall back to unix98 or bsd PTY */
+         }
+ #else
+         if (priv->flags & VTE_PTY_NO_FALLBACK) {
+@@ -1521,7 +1563,11 @@ vte_pty_initable_init (GInitable *initable,
+         }
+ #endif /* VTE_USE_GNOME_PTY_HELPER */
+ 
++#ifndef VTE_USE_BSD_PTY
+         ret = _vte_pty_open_unix98(pty, error);
++#else
++      ret = _vte_pty_open_bsd(pty, error);
++#endif /* VTE_USE_BSD_PTY */
+ 
+   out:
+       _vte_debug_print(VTE_DEBUG_PTY,
Index: vte3//pkg/PLIST
===================================================================
RCS file: /cvs/ports/devel/vte3/pkg/PLIST,v
retrieving revision 1.7
diff -u -p -r1.7 PLIST
--- vte3//pkg/PLIST     6 Feb 2012 22:07:09 -0000       1.7
+++ vte3//pkg/PLIST     21 Feb 2012 10:56:10 -0000
@@ -19,11 +19,6 @@ lib/libvte2_90.la
 @lib lib/libvte2_90.so.${LIBvte2_90_VERSION}
 lib/pkgconfig/
 lib/pkgconfig/vte-2.90.pc
-@mode g+s
-@group utmp
-@bin libexec/gnome-pty-helper
-@mode
-@group
 share/gir-1.0/
 share/gir-1.0/Vte-2.90.gir
 share/gtk-doc/

Reply via email to