From 4bef85d7bc5632cba303710df105f0f295093a91 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 28 Aug 2023 11:23:24 +0200 Subject: [PATCH] ports: add socat Fixes #5007 --- repos/ports/ports/socat.hash | 1 + repos/ports/ports/socat.port | 10 + repos/ports/recipes/src/socat/content.mk | 12 + repos/ports/recipes/src/socat/hash | 1 + repos/ports/recipes/src/socat/used_apis | 3 + repos/ports/run/socat.run | 291 ++++++++++++++++++ repos/ports/src/noux-pkg/socat/socat.patch | 326 +++++++++++++++++++++ repos/ports/src/noux-pkg/socat/target.mk | 5 + tool/autopilot.list | 1 + 9 files changed, 650 insertions(+) create mode 100644 repos/ports/ports/socat.hash create mode 100644 repos/ports/ports/socat.port create mode 100644 repos/ports/recipes/src/socat/content.mk create mode 100644 repos/ports/recipes/src/socat/hash create mode 100644 repos/ports/recipes/src/socat/used_apis create mode 100644 repos/ports/run/socat.run create mode 100644 repos/ports/src/noux-pkg/socat/socat.patch create mode 100644 repos/ports/src/noux-pkg/socat/target.mk diff --git a/repos/ports/ports/socat.hash b/repos/ports/ports/socat.hash new file mode 100644 index 0000000000..c7979180cd --- /dev/null +++ b/repos/ports/ports/socat.hash @@ -0,0 +1 @@ +b901b68ba7c1ae5afabb8b7b913201805edafd9f diff --git a/repos/ports/ports/socat.port b/repos/ports/ports/socat.port new file mode 100644 index 0000000000..98128ae564 --- /dev/null +++ b/repos/ports/ports/socat.port @@ -0,0 +1,10 @@ +LICENSE := GPLv2 +VERSION := 1.7.4.4 +DOWNLOADS := socat.archive + +URL(socat) := http://www.dest-unreach.org/socat/download/socat-$(VERSION).tar.gz +SHA(socat) := 0f8f4b9d5c60b8c53d17b60d79ababc4a0f51b3bb6d2bd3ae8a6a4b9d68f195e +DIR(socat) := src/noux-pkg/socat + +PATCHES := src/noux-pkg/socat/socat.patch +PATCH_OPT := -p1 -d src/noux-pkg/socat diff --git a/repos/ports/recipes/src/socat/content.mk b/repos/ports/recipes/src/socat/content.mk new file mode 100644 index 0000000000..7825d73e06 --- /dev/null +++ b/repos/ports/recipes/src/socat/content.mk @@ -0,0 +1,12 @@ +content: src/noux-pkg/socat LICENSE + +PORT_DIR := $(call port_dir,$(REP_DIR)/ports/socat) + +src/noux-pkg/socat: + mkdir -p $@ + cp -a $(PORT_DIR)/src/noux-pkg/socat/* $@ + cp -a $(REP_DIR)/src/noux-pkg/socat/* $@ + +LICENSE: + cp $(PORT_DIR)/src/noux-pkg/socat/COPYING $@ + diff --git a/repos/ports/recipes/src/socat/hash b/repos/ports/recipes/src/socat/hash new file mode 100644 index 0000000000..b115a86623 --- /dev/null +++ b/repos/ports/recipes/src/socat/hash @@ -0,0 +1 @@ +2023-09-27 0e49d77995131e485bd175a29bcfa866604be3ce diff --git a/repos/ports/recipes/src/socat/used_apis b/repos/ports/recipes/src/socat/used_apis new file mode 100644 index 0000000000..737e3c26a5 --- /dev/null +++ b/repos/ports/recipes/src/socat/used_apis @@ -0,0 +1,3 @@ +libc +noux +posix diff --git a/repos/ports/run/socat.run b/repos/ports/run/socat.run new file mode 100644 index 0000000000..d5b317d041 --- /dev/null +++ b/repos/ports/run/socat.run @@ -0,0 +1,291 @@ +proc platform_supported { } { + if {[have_board pc]} { + return 1 + } elseif {[have_board rpi3] && [have_include power_on/qemu]} { + return 1 + } + return 0 +} + +if {![platform_supported]} { + puts "Run script is not supported on this platform" + exit 0 +} + +create_boot_directory + +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/terminal_crosslink \ + [depot_user]/src/vfs \ + [depot_user]/src/fs_rom \ + [depot_user]/src/libc \ + [depot_user]/src/posix \ + [depot_user]/src/socat \ + [depot_user]/src/test-terminal_echo + +if {[have_include power_on/qemu]} { + build { drivers/uart } +} else { + import_from_depot [depot_user]/pkg/[drivers_nic_pkg] \ + [depot_user]/src/nic_router \ + [depot_user]/src/vfs_lwip +} + +append config { + + + + + + + + + + + + + + + + + + + + +} + +if { [have_include power_on/qemu] } { + + append_if [have_board pc] config { + + + + + + + + + + + + } + + append_if [have_board rpi3] config { + + + + + + + + + + + + } + +} else { + + append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } +} + +append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2018-01-01 00:01 + } +append_if [have_include power_on/qemu] config { + +} +append config { + } +if {![have_include power_on/qemu]} { + append config { + + } +} +append config { + + + + + } +if {[have_include power_on/qemu]} { + append config { + + } +} else { + append config { + + } +} +append config { + + + + + + + + + + + + + + + + + + + + + + + + +} + +install_config $config + +build_boot_image [build_artifacts] + +set port 5555 + +if {[have_include power_on/qemu]} { + + set host "localhost" + + # qemu config + append qemu_args " -display none " + + if {[have_board rpi3]} { + # connect comport 0 with TCP port $port + append qemu_args " -serial chardev:uart " + # connect comport 1 to stdio + append qemu_args " -serial stdio " + } else { + # connect comport 0 to stdio + append qemu_args " -serial stdio " + # connect comport 1 with TCP port $port + append qemu_args " -serial chardev:uart " + } + + append qemu_args " -chardev socket,id=uart,port=$port,host=$host,server,nowait,ipv4 " + + run_genode_until {\[init -> uart_drv\].*\n} 30 + +} else { + + set match_string "nic_router. .uplink. dynamic IP config: interface .*\n" + + run_genode_until $match_string 30 + + regexp $match_string $output host + regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $host host +} + +# wait a moment for all components to become ready +after 2000 + +set genode_id [output_spawn_id] + +eval spawn socat - TCP:$host:$port +set host_socat_id [list $spawn_id $genode_id] + +send "test message\n" + +# echo of input by host socat +run_genode_until {test message} 10 $host_socat_id + +# log message from test-terminal_echo +run_genode_until {got 13 byte} 10 $genode_id + +# intro message from test-terminal_echo +run_genode_until {--- Terminal echo test started - now you can type characters to be echoed. ---} 10 $host_socat_id + +# echo from test-terminal_echo +run_genode_until {test message} 10 $host_socat_id diff --git a/repos/ports/src/noux-pkg/socat/socat.patch b/repos/ports/src/noux-pkg/socat/socat.patch new file mode 100644 index 0000000000..b12fbc4609 --- /dev/null +++ b/repos/ports/src/noux-pkg/socat/socat.patch @@ -0,0 +1,326 @@ +socat.patch + +diff --git a/configure b/configure +index a52ae13..3ce708a 100755 +--- a/configure ++++ b/configure +@@ -6285,7 +6285,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6321,7 +6321,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6357,7 +6357,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6393,7 +6393,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6429,7 +6429,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6465,7 +6465,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6501,7 +6501,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6537,7 +6537,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6573,7 +6573,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -6632,7 +6632,7 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sc_cv_type_longlong" >&5 + $as_echo "$sc_cv_type_longlong" >&6; } + +-ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "#include \"sysincludes.h\" ++ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "#include \"${srcdir}/sysincludes.h\" + " + if test "x$ac_cv_type_sig_atomic_t" = xyes; then : + $as_echo "#define HAVE_TYPE_SIG_ATOMIC_T 1" >>confdefs.h +@@ -8109,7 +8109,7 @@ if ${sc_cv_struct_in6_pktinfo+:} false; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -8352,7 +8352,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + + int + main () +@@ -20735,7 +20735,7 @@ else + CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20749,7 +20749,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20763,7 +20763,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20777,7 +20777,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20791,7 +20791,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20805,7 +20805,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20819,7 +20819,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20833,7 +20833,7 @@ if ac_fn_c_try_compile "$LINENO"; then : + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int + main () + { +@@ -20888,7 +20888,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; return!(sizeof(x.cmsg_len)==sizeof(short));} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20902,7 +20902,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20925,7 +20925,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; return!(sizeof(x.cmsg_len)==sizeof(int));} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20939,7 +20939,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20962,7 +20962,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; return !(sizeof(x.cmsg_len)==sizeof(long));} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20976,7 +20976,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -20999,7 +20999,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { struct cmsghdr x; return !(sizeof(x.cmsg_len)==sizeof(long long));} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -21013,7 +21013,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +-#include "sysincludes.h" ++#include "${srcdir}/sysincludes.h" + int main() { x struct cmsghdr; x.cmsg_len=-1; return !(x.cmsg_len<0);} + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +diff --git a/configure.ac b/configure.ac +index 9d60473..86c3bd6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -109,7 +109,7 @@ define(AC_CHECK_PROTOTYPE_LIB,[ + AC_MSG_CHECKING(for $1 prototype) + AC_CACHE_VAL(sc_cv_have_prototype_lib_$1, + [CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1"; +- AC_TRY_LINK([#include "sysincludes.h" ++ AC_TRY_LINK([#include "${srcdir}/sysincludes.h" + $2],[return(&$1==(void *)&$1);], + [sc_cv_have_prototype_lib_$1=yes], + [sc_cv_have_prototype_lib_$1=no]); +@@ -868,7 +868,7 @@ if test $sc_cv_type_longlong = yes; then + fi + AC_MSG_RESULT($sc_cv_type_longlong) + +-AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "sysincludes.h"]) ++AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "${srcdir}/sysincludes.h"]) + + AC_MSG_CHECKING(for bool) + AC_CACHE_VAL(sc_cv_type_bool, +@@ -1443,7 +1443,7 @@ fi + dnl check for struct in6_pktinfo + AC_MSG_CHECKING(for struct in6_pktinfo) + AC_CACHE_VAL(sc_cv_struct_in6_pktinfo, +-[AC_TRY_COMPILE([#include "sysincludes.h"], ++[AC_TRY_COMPILE([#include "${srcdir}/sysincludes.h"], + [struct in6_pktinfo s;], + [sc_cv_struct_in6_pktinfo=yes], + [sc_cv_struct_in6_pktinfo=no])]) +@@ -1950,7 +1950,7 @@ AC_TYPEOF_COMPONENT([#include + struct rlimit, rlim_max, HAVE_TYPEOF_RLIM_MAX, sc_cv_type_rlimit_rlimmax_basic) + + # Fedora-19 doc says it is socklen_t which is equivalent to unsigned int, but it is equivalent to size_t (x86_64) +-AC_TYPEOF_COMPONENT([#include "sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len) ++AC_TYPEOF_COMPONENT([#include "${srcdir}/sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len) + ### snprintf, vsnprintf + + AC_MSG_CHECKING(for /dev/ptmx) +diff --git a/error.c b/error.c +index 2fad6c2..e34f426 100644 +--- a/error.c ++++ b/error.c +@@ -420,6 +420,9 @@ void diag_flush(void) { + return; + } + ++ if (diag_sock_recv == -1) ++ return; ++ + while (recv(diag_sock_recv, &recv_dgram, sizeof(recv_dgram)-1, + 0 /* for canonical reasons */ + #ifdef MSG_DONTWAIT +@@ -520,10 +523,11 @@ int diag_select(int nfds, fd_set *readfds, fd_set *writefds, + if (exceptfds) { memcpy(&save_exceptfds, exceptfds, sizeof(*exceptfds)); } + + while (1) { +- FD_SET(diag_sock_recv, readfds); ++ if (diag_sock_recv >= 0) ++ FD_SET(diag_sock_recv, readfds); + result = Select(nfds, readfds, writefds, + exceptfds, timeout); +- if (!FD_ISSET(diag_sock_recv, readfds)) { ++ if ((diag_sock_recv == -1) || !FD_ISSET(diag_sock_recv, readfds)) { + /* select terminated not due to diag_sock_recv, normalt continuation */ + break; + } diff --git a/repos/ports/src/noux-pkg/socat/target.mk b/repos/ports/src/noux-pkg/socat/target.mk new file mode 100644 index 0000000000..9315327cc2 --- /dev/null +++ b/repos/ports/src/noux-pkg/socat/target.mk @@ -0,0 +1,5 @@ +include $(call select_from_repositories,mk/noux.mk) + +INSTALL_TARGET = install + +PATCHES := src/noux-pkg/socat/socat.patch diff --git a/tool/autopilot.list b/tool/autopilot.list index 8f0c4d2b50..f0726439be 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -68,6 +68,7 @@ smartcard smbios_decoder smp sntp_client +socat ssh_exec_channel sub_rm tar_rom