diff --git a/pkg.info b/pkg.info index dfaed4d..5263af2 100644 --- a/pkg.info +++ b/pkg.info @@ -1,10 +1,9 @@ name: expect description: A tool for automating interactive applications version: 5.45.4 -revision: 2 +revision: 3 url: https://core.tcl.tk/expect/ license: custom architecture: any -depends: ["glibc","tcl"] -make_depends: ["bash","binutils","coreutils","diffutils","gcc","glibc","grep","make","patch","sed","tcl"] +depends: ["tcl"] type: source diff --git a/source-files/expect-5.45-format-security.patch b/source-files/expect-5.45-format-security.patch new file mode 100644 index 0000000..24bd353 --- /dev/null +++ b/source-files/expect-5.45-format-security.patch @@ -0,0 +1,13 @@ +--- exp_clib.c.orig 2017-03-24 10:34:37.269183513 -0400 ++++ exp_clib.c 2017-03-24 10:34:41.171117943 -0400 +@@ -1938,8 +1938,8 @@ + char *str; + { + if (exp_is_debugging) { +- fprintf(stderr,str); +- if (exp_logfile) fprintf(exp_logfile,str); ++ fprintf(stderr, "%s", str); ++ if (exp_logfile) fprintf(exp_logfile, "%s", str); + } + } + diff --git a/source-files/expect-5.45.4-covscan-fixes.patch b/source-files/expect-5.45.4-covscan-fixes.patch new file mode 100644 index 0000000..f5f8d0b --- /dev/null +++ b/source-files/expect-5.45.4-covscan-fixes.patch @@ -0,0 +1,107 @@ +diff -up expect5.45.4/exp_chan.c.orig expect5.45.4/exp_chan.c +--- expect5.45.4/exp_chan.c.orig 2018-02-02 20:15:52.000000000 +0100 ++++ expect5.45.4/exp_chan.c 2018-10-09 14:14:44.851965292 +0200 +@@ -51,6 +51,8 @@ static void ExpWatchProc _ANSI_ARGS_((C + int mask)); + static int ExpGetHandleProc _ANSI_ARGS_((ClientData instanceData, + int direction, ClientData *handlePtr)); ++void exp_background_channelhandler _ANSI_ARGS_((ClientData, ++ int)); + + /* + * This structure describes the channel type structure for Expect-based IO: +diff -up expect5.45.4/exp_clib.c.orig expect5.45.4/exp_clib.c +--- expect5.45.4/exp_clib.c.orig 2018-10-09 14:14:44.841965281 +0200 ++++ expect5.45.4/exp_clib.c 2018-10-09 14:14:44.873965319 +0200 +@@ -37,6 +37,14 @@ would appreciate credit if this program + # endif + #endif + ++#ifdef HAVE_UNISTD_H ++# include ++#endif ++ ++//#ifdef HAVE_SYS_WAIT_H ++# include ++//#endif ++ + #ifdef HAVE_SYS_FCNTL_H + # include + #else +@@ -2196,6 +2204,7 @@ int exp_getptyslave(); + #define sysreturn(x) return(errno = x, -1) + + void exp_init_pty(); ++void exp_init_tty(); + + /* + The following functions are linked from the Tcl library. They +@@ -2715,6 +2724,7 @@ exp_spawnl TCL_VARARGS_DEF(char *,arg1) + argv[i] = va_arg(args,char *); + if (!argv[i]) break; + } ++ va_end(args); + i = exp_spawnv(argv[0],argv+1); + free((char *)argv); + return(i); +@@ -3188,6 +3198,7 @@ exp_expectl TCL_VARARGS_DEF(int,arg1) + /* Ultrix 4.2 compiler refuses enumerations comparison!? */ + if ((int)type < 0 || (int)type >= (int)exp_bogus) { + fprintf(stderr,"bad type (set %d) in exp_expectl\n",i); ++ va_end(args); + sysreturn(EINVAL); + } + +@@ -3253,6 +3264,7 @@ exp_fexpectl TCL_VARARGS_DEF(FILE *,arg1 + /* Ultrix 4.2 compiler refuses enumerations comparison!? */ + if ((int)type < 0 || (int)type >= (int)exp_bogus) { + fprintf(stderr,"bad type (set %d) in exp_expectl\n",i); ++ va_end(args); + sysreturn(EINVAL); + } + +diff -up expect5.45.4/exp_log.c.orig expect5.45.4/exp_log.c +--- expect5.45.4/exp_log.c.orig 2018-10-09 14:14:44.838965277 +0200 ++++ expect5.45.4/exp_log.c 2018-10-09 14:14:44.852965294 +0200 +@@ -174,7 +174,10 @@ expStdoutLog TCL_VARARGS_DEF(int,arg1) + force_stdout = TCL_VARARGS_START(int,arg1,args); + fmt = va_arg(args,char *); + +- if ((!tsdPtr->logUser) && (!force_stdout) && (!tsdPtr->logAll)) return; ++ if ((!tsdPtr->logUser) && (!force_stdout) && (!tsdPtr->logAll)) { ++ va_end(args); ++ return; ++ } + + (void) vsnprintf(bigbuf,sizeof(bigbuf),fmt,args); + expDiagWriteBytes(bigbuf,-1); +diff -up expect5.45.4/exp_main_sub.c.orig expect5.45.4/exp_main_sub.c +--- expect5.45.4/exp_main_sub.c.orig 2018-10-09 14:14:44.848965289 +0200 ++++ expect5.45.4/exp_main_sub.c 2018-10-09 14:14:44.852965294 +0200 +@@ -57,6 +57,7 @@ int exp_cmdlinecmds = FALSE; + int exp_interactive = FALSE; + int exp_buffer_command_input = FALSE;/* read in entire cmdfile at once */ + int exp_fgets(); ++int exp_tty_cooked_echo(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo); + + Tcl_Interp *exp_interp; /* for use by signal handlers who can't figure out */ + /* the interpreter directly */ +diff -up expect5.45.4/pty_termios.c.orig expect5.45.4/pty_termios.c +--- expect5.45.4/pty_termios.c.orig 2018-10-09 14:17:00.132127498 +0200 ++++ expect5.45.4/pty_termios.c 2018-10-09 14:33:59.393315570 +0200 +@@ -105,6 +105,7 @@ with openpty which supports 4000 while p + + void expDiagLog(); + void expDiagLogPtr(); ++char *expErrnoMsg(int errorNo); + + #include + /*extern char *sys_errlist[];*/ +@@ -189,6 +190,7 @@ static char slave_name[MAXPTYNAMELEN]; + #endif /* HAVE_SCO_CLIST_PTYS */ + + #ifdef HAVE_OPENPTY ++#include + static char master_name[64]; + static char slave_name[64]; + #endif diff --git a/source-files/expect-c99.patch b/source-files/expect-c99.patch new file mode 100644 index 0000000..2a9799b --- /dev/null +++ b/source-files/expect-c99.patch @@ -0,0 +1,21 @@ +diff --git a/exp_chan.c b/exp_chan.c +index c92e26b6fbd02305..944200a63b102672 100644 +--- a/exp_chan.c ++++ b/exp_chan.c +@@ -60,7 +60,7 @@ void exp_background_channelhandler _ANSI_ARGS_((ClientData, + + Tcl_ChannelType expChannelType = { + "exp", /* Type name. */ +- ExpBlockModeProc, /* Set blocking/nonblocking mode.*/ ++ TCL_CHANNEL_VERSION_2, + ExpCloseProc, /* Close proc. */ + ExpInputProc, /* Input proc. */ + ExpOutputProc, /* Output proc. */ +@@ -70,6 +70,7 @@ Tcl_ChannelType expChannelType = { + ExpWatchProc, /* Initialize notifier. */ + ExpGetHandleProc, /* Get OS handles out of channel. */ + NULL, /* Close2 proc */ ++ ExpBlockModeProc, /* Set blocking/nonblocking mode.*/ + }; + + typedef struct ThreadSpecificData { diff --git a/source-files/expect-configure-c99.patch b/source-files/expect-configure-c99.patch new file mode 100644 index 0000000..f65410f --- /dev/null +++ b/source-files/expect-configure-c99.patch @@ -0,0 +1,198 @@ +Avoid calling exit without declaring the function. + +Add missing include for memcpy. + +Use AC_TYPE_SIGNAL to fix REARM_SIG check. Add missing includes. + +Fix various implicit int return types of main. + +diff --git a/configure.in b/configure.in +index 51558fa14d2bcf7e..055c88fbd8797eaa 100755 +--- a/configure.in ++++ b/configure.in +@@ -452,7 +452,11 @@ AC_CHECK_FUNC(siglongjmp, AC_DEFINE(HAVE_SIGLONGJMP)) + # because Unixware 2.0 handles it specially and refuses to compile + # autoconf's automatic test that is a call with no arguments + AC_MSG_CHECKING([for memcpy]) +-AC_TRY_LINK(,[ ++AC_TRY_LINK([ ++#ifdef HAVE_STRING_H ++#include ++#endif ++],[ + char *s1, *s2; + memcpy(s1,s2,0); + ], +@@ -469,6 +473,7 @@ memcpy(s1,s2,0); + AC_MSG_CHECKING([if WNOHANG requires _POSIX_SOURCE]) + AC_TRY_RUN([ + #include ++int + main() { + #ifndef WNOHANG + return 0; +@@ -489,6 +494,7 @@ rm -rf wnohang + AC_TRY_RUN([ + #include + #include ++int + main() { + #ifdef WNOHANG + FILE *fp = fopen("wnohang","w"); +@@ -527,16 +533,21 @@ else + AC_DEFINE(SELECT_MASK_TYPE, fd_set) + fi + +-dnl # Check for the data type of the function used in signal(). This +-dnl # must be before the test for rearming. +-dnl # echo checking return type of signal handlers +-dnl AC_HEADER_EGREP([(void|sighandler_t).*signal], signal.h, retsigtype=void,AC_DEFINE(RETSIGTYPE, int) retsigtype=int) ++AC_TYPE_SIGNAL + + # FIXME: check if alarm exists + AC_MSG_CHECKING([if signals need to be re-armed]) + AC_TRY_RUN([ + #include +-#define RETSIGTYPE $retsigtype ++#ifdef HAVE_STDLIB_H ++# include ++#endif ++#ifdef HAVE_UNISTD_H ++# include ++#endif ++#ifndef NO_SYS_WAIT_H ++# include ++#endif + + int signal_rearms = 0; + +@@ -553,6 +564,7 @@ int n; + signal_rearms++; + } + ++int + main() + { + signal(SIGINT,parent_sigint_handler); +@@ -714,10 +726,11 @@ fi + AC_MSG_CHECKING([for struct sgttyb]) + AC_TRY_RUN([ + #include ++int + main() + { + struct sgttyb tmp; +- exit(0); ++ return 0; + }], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SGTTYB) +@@ -738,10 +751,11 @@ if test $mach -eq 0 ; then + # pty_termios.c is set up to handle pty_termio. + AC_MSG_CHECKING([for struct termio]) + AC_TRY_RUN([#include ++ int + main() + { + struct termio tmp; +- exit(0); ++ return 0; + }], + AC_DEFINE(HAVE_TERMIO) + PTY_TYPE=termios +@@ -760,10 +774,11 @@ if test $mach -eq 0 ; then + # include + # endif + # include ++ int + main() + { + struct termios tmp; +- exit(0); ++ return 0; + }], + AC_DEFINE(HAVE_TERMIOS) + PTY_TYPE=termios +@@ -782,6 +797,7 @@ AC_TRY_RUN([ + #include + #endif + #include ++int + main() { + #if defined(TCGETS) || defined(TCGETA) + return 0; +@@ -804,6 +820,7 @@ AC_TRY_RUN([ + #include + #endif + #include ++int + main() { + #ifdef TIOCGWINSZ + return 0; +@@ -823,6 +840,7 @@ main() { + AC_MSG_CHECKING([for Cray-style ptys]) + SETUID=":" + AC_TRY_RUN([ ++int + main(){ + #ifdef CRAY + return 0; +@@ -878,12 +896,13 @@ AC_MSG_CHECKING([for SV-style timezone]) + AC_TRY_RUN([ + extern char *tzname[2]; + extern int daylight; ++int + main() + { + int *x = &daylight; + char **y = tzname; + +- exit(0); ++ return 0; + }], + AC_DEFINE(HAVE_SV_TIMEZONE) + AC_MSG_RESULT(yes), +diff --git a/tclconfig/tcl.m4 b/tclconfig/tcl.m4 +index 0689cab3da994068..ebe839e5553ba520 100644 +--- a/tclconfig/tcl.m4 ++++ b/tclconfig/tcl.m4 +@@ -2400,7 +2400,7 @@ AC_DEFUN([TEA_TIME_HANDLER], [ + AC_TRY_COMPILE([#include ], + [extern long timezone; + timezone += 1; +- exit (0);], ++ return 0;], + tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)]) + if test $tcl_cv_timezone_long = yes ; then + AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?]) +@@ -2412,7 +2412,7 @@ AC_DEFUN([TEA_TIME_HANDLER], [ + AC_TRY_COMPILE([#include ], + [extern time_t timezone; + timezone += 1; +- exit (0);], ++ return 0;], + tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)]) + if test $tcl_cv_timezone_time = yes ; then + AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?]) +@@ -2452,17 +2452,17 @@ AC_DEFUN([TEA_BUGGY_STRTOD], [ + double value; + value = strtod(infString, &term); + if ((term != infString) && (term[-1] == 0)) { +- exit(1); ++ return 1; + } + value = strtod(nanString, &term); + if ((term != nanString) && (term[-1] == 0)) { +- exit(1); ++ return 1; + } + value = strtod(spaceString, &term); + if (term == (spaceString+1)) { +- exit(1); ++ return 1; + } +- exit(0); ++ return 0; + }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy, + tcl_cv_strtod_buggy=buggy)]) + if test "$tcl_cv_strtod_buggy" = buggy; then diff --git a/source.sh b/source.sh index 8514e39..916ea7e 100644 --- a/source.sh +++ b/source.sh @@ -10,30 +10,48 @@ FILENAME="${DOWNLOAD##*/}" prepare() { wget "$DOWNLOAD" tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" + + cd "$BPM_SOURCE" + # Apply patches from Arch Linux + patch -Np1 < "$BPM_WORKDIR"/expect-5.45.4-covscan-fixes.patch + patch -Np0 < "$BPM_WORKDIR"/expect-5.45-format-security.patch + # Apply patches from https://sourceforge.net/p/expect/patches/24/ + patch -Np1 < "$BPM_WORKDIR"/expect-c99.patch + patch -Np1 < "$BPM_WORKDIR"/expect-configure-c99.patch + + autoreconf -i } # The build function is executed in the source directory # This function is used to compile the source code build() { - ./configure --prefix=/usr \ - --with-tcl=/usr/lib \ - --enable-shared \ - --mandir=/usr/share/man \ - --with-tclinclude=/usr/include + ./configure --prefix=/usr \ + --mandir=/usr/share/man \ + --with-tcl=/usr/lib \ + --with-tclinclude=/usr/include \ + --enable-shared \ + --disable-rpath make } # The check function is executed in the source directory # This function is used to run tests to verify the package has been compiled correctly check() { - make test + SHELL=/bin/sh make test | tee tests.log # Save output to file to read la + + set -e + grep -q 'Files with failing tests' tests.log && exit 1 # Throw error if any files had failing tests + set +e } # The package function is executed in the source directory # This function is used to move the compiled files into the output directory package() { make DESTDIR="$BPM_OUTPUT" install - ln -svf expect"${BPM_PKG_VERSION}"/libexpect"${BPM_PKG_VERSION}".so "$BPM_OUTPUT"/usr/lib - mkdir -p "$BPM_OUTPUT"/usr/share/licenses/expect/ - cp license.terms "$BPM_OUTPUT"/usr/share/licenses/expect/license.terms + + # Create libexpect link + ln -sf expect"${BPM_PKG_VERSION}"/libexpect"${BPM_PKG_VERSION}".so "$BPM_OUTPUT"/usr/lib + + # Install package license + install -Dm644 license.terms "$BPM_OUTPUT"/usr/share/licenses/expect/license.terms }