lol

expect: fix build with clang 16

* Use patches from upstream issue tracker that fix most compilation
issues and the configure script; and
* Modify `exp_win.c` and `pty_termios.c` to build properly on Darwin.

+44 -2
+13 -2
pkgs/tools/misc/expect/default.nix
··· 6 6 7 7 src = fetchurl { 8 8 url = "mirror://sourceforge/expect/Expect/${version}/expect${version}.tar.gz"; 9 - sha256 = "0d1cp5hggjl93xwc8h1y6adbnrvpkk0ywkd00inz9ndxn21xm9s9"; 9 + hash = "sha256-Safag7C92fRtBKBN7sGcd2e7mjI+QMR4H4nK92C5LDQ="; 10 10 }; 11 11 12 12 patches = [ 13 13 (fetchpatch { 14 14 url = "https://raw.githubusercontent.com/buildroot/buildroot/c05e6aa361a4049eabd8b21eb64a34899ef83fc7/package/expect/0001-enable-cross-compilation.patch"; 15 - sha256 = "1jwx2l1slidvcpahxbyqs942l81jd62rzbxliyd9lwysk38c8b6b"; 15 + hash = "sha256-yyzE0Jjac5qaj7Svn4VpMiAqSNLYrw7VZbtFqgMVncs="; 16 16 }) 17 17 (substituteAll { 18 18 src = ./fix-cross-compilation.patch; 19 19 tcl = "${buildPackages.tcl}/bin/tclsh"; 20 20 }) 21 + # The following patches fix compilation with clang 15+ 22 + (fetchpatch { 23 + url = "https://sourceforge.net/p/expect/patches/24/attachment/0001-Add-prototype-to-function-definitions.patch"; 24 + hash = "sha256-X2Vv6VVM3KjmBHo2ukVWe5YTVXRmqe//Kw2kr73OpZs="; 25 + }) 26 + (fetchpatch { 27 + url = "https://sourceforge.net/p/expect/patches/_discuss/thread/b813ca9895/6759/attachment/expect-configure-c99.patch"; 28 + hash = "sha256-PxQQ9roWgVXUoCMxkXEgu+it26ES/JuzHF6oML/nk54="; 29 + }) 30 + # Include `sys/ioctl.h` and `util.h` on Darwin, which are required for `ioctl` and `openpty`. 31 + ./fix-darwin-clang16.patch 21 32 ]; 22 33 23 34 postPatch = ''
+31
pkgs/tools/misc/expect/fix-darwin-clang16.patch
··· 1 + diff -ur a/exp_win.c b/exp_win.c 2 + --- a/exp_win.c 2018-02-02 14:15:52.000000000 -0500 3 + +++ b/exp_win.c 2023-10-10 07:47:33.082690432 -0400 4 + @@ -39,7 +39,8 @@ 5 + /* Sigh. On AIX 2.3, termios.h exists but does not define TIOCGWINSZ */ 6 + /* Instead, it has to come from ioctl.h. However, As I said above, this */ 7 + /* can't be cavalierly included on all machines, even when it exists. */ 8 + -#if defined(HAVE_TERMIOS) && !defined(HAVE_TIOCGWINSZ_IN_TERMIOS_H) 9 + +/* Darwin also has termios.h, but it requires ioctl.h for `ioctl`. */ 10 + +#if defined(HAVE_TERMIOS) && (defined(__APPLE__) || !defined(HAVE_TIOCGWINSZ_IN_TERMIOS_H)) 11 + # include <sys/ioctl.h> 12 + #endif 13 + 14 + diff -ur d/pty_termios.c c/pty_termios.c 15 + --- d/pty_termios.c 2023-10-10 07:59:23.244452442 -0400 16 + +++ c/pty_termios.c 2023-10-10 08:00:35.303231582 -0400 17 + @@ -7,7 +7,13 @@ 18 + 19 + */ 20 + 21 + -#include <pty.h> /* openpty */ 22 + +/* openpty */ 23 + +#ifdef __APPLE__ 24 + +#include <util.h> 25 + +#else /* pty.h is Linux-specific */ 26 + +#include <pty.h> 27 + +#endif 28 + + 29 + #include <stdio.h> 30 + #include <signal.h> 31 +