Pulled expect-5.44.1.15 into portage-stable overlay.

expect is needed for running DejaGNU tests. This pulls the latest stable expect from upstream portage into the
portage-stable overlay.

TEST=emerge expect.
BUG=chromium-os:17342

Change-Id: Ie117e49afeacf4d5c552f38c0bdfaa888054736b
Reviewed-on: http://gerrit.chromium.org/gerrit/3731
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Raymes Khoury <raymes@chromium.org>
diff --git a/dev-tcltk/expect/expect-5.44.1.15.ebuild b/dev-tcltk/expect/expect-5.44.1.15.ebuild
new file mode 100644
index 0000000..006a65b
--- /dev/null
+++ b/dev-tcltk/expect/expect-5.44.1.15.ebuild
@@ -0,0 +1,96 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-tcltk/expect/expect-5.44.1.15.ebuild,v 1.16 2010/12/17 22:56:19 vapier Exp $
+
+EAPI="3"
+
+inherit autotools eutils
+
+DESCRIPTION="tool for automating interactive applications"
+HOMEPAGE="http://expect.nist.gov/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~x86-macos ~x86-solaris"
+IUSE="debug doc threads X"
+
+# We need dejagnu for src_test, but dejagnu needs expect
+# to compile/run, so we cant add dejagnu to DEPEND :/
+DEPEND=">=dev-lang/tcl-8.2[threads?]
+	X? ( >=dev-lang/tk-8.2[threads?] )"
+RDEPEND="${DEPEND}"
+
+src_prepare() {
+	sed -i "s#/usr/local/bin#${EPREFIX}/usr/bin#" expect{,k}.man || die
+	# stops any example scripts being installed by default
+	sed -i \
+		-e '/^install:/s/install-libraries //' \
+		-e 's/^SCRIPTS_MANPAGES = /_&/' \
+		Makefile.in
+
+	epatch "${FILESDIR}"/${P}-gfbsd.patch
+	epatch "${FILESDIR}"/${P}-ldflags.patch
+	epatch "${FILESDIR}"/${P}_with-tk-no.patch
+	epatch "${FILESDIR}"/${P}-headers.patch #337943
+	epatch "${FILESDIR}"/${P}-expectk.patch
+	sed -i 's:ifdef HAVE_SYS_WAIT_H:ifndef NO_SYS_WAIT_H:' *.c
+
+	eautoconf
+}
+
+src_configure() {
+	local myconf
+	local tclv
+	local tkv
+	# Find the version of tcl/tk that has headers installed.
+	# This will be the most recently merged, not necessarily the highest
+	# version number.
+	tclv=$(grep TCL_VER ${EPREFIX}/usr/include/tcl.h | sed 's/^.*"\(.*\)".*/\1/')
+	#tkv isn't really needed, included for symmetry and the future
+	#tkv=$(grep	 TK_VER ${EPREFIX}/usr/include/tk.h  | sed 's/^.*"\(.*\)".*/\1/')
+	myconf="--with-tcl=${EPREFIX}/usr/$(get_libdir) --with-tclinclude=${EPREFIX}/usr/$(get_libdir)/tcl${tclv}/include/generic --with-tk=yes"
+
+	if use X ; then
+		#--with-x is enabled by default
+		#configure needs to find the file tkConfig.sh and tk.h
+		#tk.h is in /usr/lib so don't need to explicitly set --with-tkinclude
+		myconf="$myconf --with-tk=${EPREFIX}/usr/$(get_libdir) --with-tkinclude=${EPREFIX}/usr/include"
+	else
+		#configure knows that tk depends on X so just disable X
+		myconf="$myconf --with-tk=no"
+	fi
+
+	econf \
+		$myconf \
+		--enable-shared \
+		$(use_enable threads) \
+		$(use_enable amd64 64bit) \
+		$(use_enable debug symbols)
+}
+
+src_test() {
+	# we need dejagnu to do tests ... but dejagnu needs
+	# expect ... so don't do tests unless we have dejagnu
+	type -p runtest || return 0
+	emake test || die "emake test failed"
+}
+
+expect_make_var() {
+	touch pkgIndex.tcl-hand
+	printf 'all:;echo $('$1')\ninclude Makefile' | emake --no-print-directory -s -f -
+	rm -f pkgIndex.tcl-hand
+}
+
+src_install() {
+	emake install DESTDIR="${D}" || die
+	dodoc ChangeLog FAQ HISTORY NEWS README
+
+	# install examples if 'doc' is set
+	if use doc ; then
+		insinto /usr/share/doc/${PF}/examples
+		doins $(printf 'example/%s ' $(expect_make_var SCRIPTS)) || die
+		docinto examples
+		dodoc example/README $(printf 'example/%s.man ' $(expect_make_var _SCRIPTS_MANPAGES)) || die
+	fi
+}
diff --git a/dev-tcltk/expect/files/expect-5.44.1.15-expectk.patch b/dev-tcltk/expect/files/expect-5.44.1.15-expectk.patch
new file mode 100644
index 0000000..0c0ba80
--- /dev/null
+++ b/dev-tcltk/expect/files/expect-5.44.1.15-expectk.patch
@@ -0,0 +1,14 @@
+expectk is only built when TK_BIN_DIR is defined.  the configure script
+takes care of figuring out this value, but then they forgot to actually
+write it out to the Makefile.
+
+--- Makefile.in
++++ Makefile.in
+@@ -24,6 +24,7 @@
+ # SETUID = chmod u+s
+ 
+ LIB_RUNTIME_DIR = $(DESTDIR)@libdir@
++TK_BIN_DIR = @TK_BIN_DIR@
+ 
+ # The following Expect scripts are not necessary to have installed as
+ # commands, but are very useful. Edit out what you don't want
diff --git a/dev-tcltk/expect/files/expect-5.44.1.15-gfbsd.patch b/dev-tcltk/expect/files/expect-5.44.1.15-gfbsd.patch
new file mode 100644
index 0000000..d67de21
--- /dev/null
+++ b/dev-tcltk/expect/files/expect-5.44.1.15-gfbsd.patch
@@ -0,0 +1,17 @@
+--- expect-5.44.1.15/tclconfig/tcl.m4.orig	2010-04-08 22:49:51.568043292 -0700
++++ expect-5.44.1.15/tclconfig/tcl.m4	2010-04-08 22:50:28.207915301 -0700
+@@ -1579,12 +1579,12 @@
+ 	FreeBSD-*)
+ 	    # FreeBSD 3.* and greater have ELF.
+ 	    SHLIB_CFLAGS="-fPIC"
+-	    SHLIB_LD="ld -Bshareable -x"
++	    SHLIB_LD="${CC} -shared"
+ 	    SHLIB_LD_LIBS='${LIBS}'
+ 	    SHLIB_SUFFIX=".so"
+ 	    DL_OBJS="tclLoadDl.o"
+ 	    DL_LIBS=""
+-	    LDFLAGS="$LDFLAGS -export-dynamic"
++	    LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
+ 	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ 	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
+ 	    if test "${TCL_THREADS}" = "1" ; then
diff --git a/dev-tcltk/expect/files/expect-5.44.1.15-headers.patch b/dev-tcltk/expect/files/expect-5.44.1.15-headers.patch
new file mode 100644
index 0000000..77e4d91
--- /dev/null
+++ b/dev-tcltk/expect/files/expect-5.44.1.15-headers.patch
@@ -0,0 +1,86 @@
+https://sourceforge.net/tracker/?func=detail&aid=3071706&group_id=13179&atid=113179
+
+--- a/exp_clib.c
++++ b/exp_clib.c
+@@ -15,6 +15,12 @@
+ #endif
+ #include <sys/types.h>
+ #include <sys/ioctl.h>
++#ifdef HAVE_UNISTD_H
++# include <unistd.h>
++#endif
++#ifdef HAVE_SYS_WAIT_H
++#include <sys/wait.h>
++#endif
+ 
+ #ifdef TIME_WITH_SYS_TIME
+ # include <sys/time.h>
+--- a/exp_trap.c
++++ b/exp_trap.c
+@@ -13,6 +13,7 @@
+ #include <stdio.h>
+ #include <signal.h>
+ #include <sys/types.h>
++#include <string.h>
+ 
+ #ifdef HAVE_SYS_WAIT_H
+ #include <sys/wait.h>
+--- a/pty_termios.c
++++ b/pty_termios.c
+@@ -9,6 +9,8 @@
+ 
+ #include <stdio.h>
+ #include <signal.h>
++#include <string.h>
++#include <pty.h>
+ 
+ #if defined(SIGCLD) && !defined(SIGCHLD)
+ #define SIGCHLD SIGCLD
+@@ -100,6 +100,7 @@
+ 
+ #include "exp_tty_in.h"
+ #include "exp_rename.h"
++#include "exp_int.h"
+ #include "exp_pty.h"
+ 
+ void expDiagLog();
+--- a/exp_chan.c
++++ b/exp_chan.c
+@@ -34,6 +34,7 @@
+ #include "exp_rename.h"
+ #include "exp_prog.h"
+ #include "exp_command.h"
++#include "exp_event.h"
+ #include "exp_log.h"
+ #include "tcldbg.h" /* Dbg_StdinMode */
+ 
+--- a/exp_clib.c
++++ b/exp_clib.c
+@@ -1955,6 +1955,7 @@
+ 
+ #include "expect.h"
+ #include "exp_int.h"
++EXTERN void		exp_init_tty _ANSI_ARGS_((void));
+ 
+ /* exp_glob.c - expect functions for doing glob
+  *
+--- a/exp_tty.h
++++ b/exp_tty.h
+@@ -17,6 +17,7 @@
+ 
+ void exp_tty_raw(int set);
+ void exp_tty_echo(int set);
++int exp_tty_cooked_echo(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo);
+ void exp_tty_break(Tcl_Interp *interp, int fd);
+ int exp_tty_raw_noecho(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo);
+ int exp_israw(void);
+--- a/exp_main_tk.c
++++ b/exp_main_tk.c
+@@ -32,6 +32,7 @@
+ static char sccsid[] = "@(#) tkAppInit.c 1.19 95/12/23 17:09:24";
+ #endif /* not lint */
+ 
++#include <string.h>
+ #include <ctype.h>
+ 
+ #include "tk.h"
diff --git a/dev-tcltk/expect/files/expect-5.44.1.15-ldflags.patch b/dev-tcltk/expect/files/expect-5.44.1.15-ldflags.patch
new file mode 100644
index 0000000..be3641c
--- /dev/null
+++ b/dev-tcltk/expect/files/expect-5.44.1.15-ldflags.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile.in b/Makefile.in
+index cc2c79b..1083eaf 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -148,7 +148,7 @@ OBJEXT		= @OBJEXT@
+ RANLIB		= @RANLIB@
+ RANLIB_STUB	= @RANLIB_STUB@
+ SHLIB_CFLAGS	= @SHLIB_CFLAGS@
+-SHLIB_LD	= @SHLIB_LD@
++SHLIB_LD	= @SHLIB_LD@ $(LDFLAGS)
+ SHLIB_LD_LIBS	= @SHLIB_LD_LIBS@
+ STLIB_LD	= @STLIB_LD@
+ TCL_DEFS	= @TCL_DEFS@
diff --git a/dev-tcltk/expect/files/expect-5.44.1.15_with-tk-no.patch b/dev-tcltk/expect/files/expect-5.44.1.15_with-tk-no.patch
new file mode 100644
index 0000000..cea372d
--- /dev/null
+++ b/dev-tcltk/expect/files/expect-5.44.1.15_with-tk-no.patch
@@ -0,0 +1,117 @@
+This is a minimal patch that does not keep indentation consistent in tcl.m4
+Updating indentation would make the patch much bigger and less readable.
+
+Signed-off-by: Gilles Espinasse <g.esp@free.fr>
+
+Index: INSTALL
+===================================================================
+RCS file: /cvsroot/expect/expect/INSTALL,v
+retrieving revision 5.30
+diff -u -r5.30 INSTALL
+--- INSTALL	21 Jun 1999 18:41:41 -0000	5.30
++++ INSTALL	30 May 2009 11:51:21 -0000
+@@ -152,6 +152,7 @@
+ 
+ 	--with-tk=...		Specifies the directory containing Tk's
+ 				configure file (tkConfig.sh).
++				--with-tk=no disable Tk usage in expect
+ 
+ 	--with-tkinclude=...	Specifies the directory containing Tk's
+ 				private include files (such as tkInt.h)
+Index: Makefile.in
+===================================================================
+RCS file: /cvsroot/expect/expect/Makefile.in,v
+retrieving revision 5.45
+diff -u -r5.45 Makefile.in
+--- Makefile.in	3 Oct 2008 17:05:14 -0000	5.45
++++ Makefile.in	30 May 2009 11:51:21 -0000
+@@ -103,7 +103,11 @@
+ PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
+ 
+ lib_BINARIES	= $(PKG_LIB_FILE)
+-bin_BINARIES	= expect expectk
++bin_BINARIES	= expect
++ifneq ($(TK_BIN_DIR),)
++  bin_BINARIES	+= expectk
++endif
++
+ BINARIES	= $(lib_BINARIES) $(bin_BINARIES)
+ 
+ SHELL		= @SHELL@
+Index: tclconfig/tcl.m4
+===================================================================
+RCS file: /cvsroot/expect/expect/tclconfig/tcl.m4,v
+retrieving revision 1.3
+diff -u -r1.3 tcl.m4
+--- tclconfig/tcl.m4	25 Jan 2006 21:52:11 -0000	1.3
++++ tclconfig/tcl.m4	30 May 2009 11:51:23 -0000
+@@ -181,10 +181,12 @@
+ #
+ #	Adds the following arguments to configure:
+ #		--with-tk=...
++#		--with-tk=no disable Tk usage
+ #
+ #	Defines the following vars:
+ #		TK_BIN_DIR	Full path to the directory containing
+ #				the tkConfig.sh file
++#				Empty if Tk is disabled
+ #------------------------------------------------------------------------
+ 
+ AC_DEFUN(TEA_PATH_TKCONFIG, [
+@@ -201,6 +203,12 @@
+ 	    AC_HELP_STRING([--with-tk],
+ 		[directory containing tk configuration (tkConfig.sh)]),
+ 	    with_tkconfig=${withval})
++
++	if test x"${with_tkconfig}" = x"no" ; then
++	    AC_MSG_RESULT([Tk is disabled by --with-tk=no])
++	    unset TK_BIN_DIR
++	else
++
+ 	AC_MSG_CHECKING([for Tk configuration])
+ 	AC_CACHE_VAL(ac_cv_c_tkconfig,[
+ 
+@@ -309,6 +317,7 @@
+ 	    TK_BIN_DIR=${ac_cv_c_tkconfig}
+ 	    AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
+ 	fi
++	fi
+     fi
+ ])
+ 
+@@ -420,6 +429,7 @@
+ #------------------------------------------------------------------------
+ 
+ AC_DEFUN(TEA_LOAD_TKCONFIG, [
++    if test x"${with_tkconfig}" != x"no" ; then
+     AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
+ 
+     if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
+@@ -501,6 +511,7 @@
+ 
+     AC_SUBST(TK_LIBS)
+     AC_SUBST(TK_XINCLUDES)
++    fi
+ ])
+ 
+ #------------------------------------------------------------------------
+@@ -3528,6 +3539,11 @@
+ #------------------------------------------------------------------------
+ 
+ AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
++    if test x"${with_tkconfig}" = x"no" ; then
++	TK_INCLUDES=""
++	AC_SUBST(TK_INCLUDES)
++    else
++
+     AC_MSG_CHECKING([for Tk public headers])
+ 
+     AC_ARG_WITH(tkinclude, [  --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
+@@ -3608,6 +3624,7 @@
+ 	fi
+ 	AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
+     fi
++    fi
+ ])
+ 
+ #------------------------------------------------------------------------