From 424a04b3c20bf830723c187470b6d802422783b8 Mon Sep 17 00:00:00 2001 From: Krul Ceter Date: Sat, 21 Jan 2023 08:36:07 +0300 Subject: [PATCH] EternalTerminal: update to 6.2.4. * replace disable_testing.patch with upstream build_testing.patch in order to properly disable building tests with the "BUILD_TESTING" flag. * apply use_system_libs.patch to use system libraries instead of the vendored ones. * gcc complains at "string"/"vector" not having a type in src/base/TunnelUtils.(hpp|cpp); apply upstream patch. * clean up the mess made with build_wrksrc in the previous commit. * gflags was dropped upstream in version 6.0.1: MisterTea/EternalTerminal@f601aab21165de0d05c797d67603924eb4c797f5 --- .../patches/build_testing.patch | 89 ++++++++++++++ .../patches/disable-tests.patch | 30 ----- .../EternalTerminal/patches/fix-cflags.patch | 4 +- .../EternalTerminal/patches/tunnelutils.patch | 45 +++++++ .../patches/use_system_libs.patch | 112 ++++++++++++++++++ srcpkgs/EternalTerminal/template | 24 ++-- 6 files changed, 260 insertions(+), 44 deletions(-) create mode 100644 srcpkgs/EternalTerminal/patches/build_testing.patch delete mode 100644 srcpkgs/EternalTerminal/patches/disable-tests.patch create mode 100644 srcpkgs/EternalTerminal/patches/tunnelutils.patch create mode 100644 srcpkgs/EternalTerminal/patches/use_system_libs.patch diff --git a/srcpkgs/EternalTerminal/patches/build_testing.patch b/srcpkgs/EternalTerminal/patches/build_testing.patch new file mode 100644 index 000000000000..3ba509d228df --- /dev/null +++ b/srcpkgs/EternalTerminal/patches/build_testing.patch @@ -0,0 +1,89 @@ +https://github.com/MisterTea/EternalTerminal/pull/562.patch + +From d39008320d401264770636abe9d77ba69e65c620 Mon Sep 17 00:00:00 2001 +From: Krul Ceter +Date: Sat, 21 Jan 2023 07:36:17 +0300 +Subject: [PATCH] Add BUILD_TESTING to make tests optional by choice + +The option is enabled by default, so it should not disrupt the default +behavior. +--- + CMakeLists.txt | 48 ++++++++++++++++++++++++++---------------------- + 1 file changed, 26 insertions(+), 22 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ef239d3e..2368dfc2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -165,6 +165,7 @@ endif() + + option(CODE_COVERAGE "Enable code coverage" OFF) + option(FUZZING "Enable builds for fuzz testing" OFF) ++option(BUILD_TESTING "Build tests" ON) + option(DISABLE_CRASH_LOG "Disable installing easylogging crash handler" OFF) + + add_definitions(-DET_VERSION="${PROJECT_VERSION}") +@@ -521,30 +522,33 @@ else(WIN32) + ${CORE_LIBRARIES}) + decorate_target(htmd) + +- enable_testing() ++ if(BUILD_TESTING) ++ enable_testing() + +- file(GLOB TEST_SRCS test/*Test.cpp) +- add_executable( +- et-test +- ${TEST_SRCS} +- test/Main.cpp +- ) +- add_dependencies(et-test TerminalCommon et-lib) +- target_link_libraries( ++ file(GLOB TEST_SRCS test/*Test.cpp) ++ add_executable( + et-test +- TerminalCommon +- et-lib +- ${CMAKE_THREAD_LIBS_INIT} +- ${PROTOBUF_LIBS} +- ${sodium_LIBRARY_RELEASE} +- ${SELINUX_LIBRARIES} +- ${UTEMPTER_LIBRARIES} +- ${Boost_LIBRARIES} +- ${CORE_LIBRARIES}) +- add_test(et-test et-test) +- decorate_target(et-test) ++ ${TEST_SRCS} ++ test/Main.cpp ++ ) + +- if(FUZZING) ++ add_dependencies(et-test TerminalCommon et-lib) ++ target_link_libraries( ++ et-test ++ TerminalCommon ++ et-lib ++ ${CMAKE_THREAD_LIBS_INIT} ++ ${PROTOBUF_LIBS} ++ ${sodium_LIBRARY_RELEASE} ++ ${SELINUX_LIBRARIES} ++ ${UTEMPTER_LIBRARIES} ++ ${Boost_LIBRARIES} ++ ${CORE_LIBRARIES}) ++ add_test(et-test et-test) ++ decorate_target(et-test) ++ endif() ++ ++ if(BUILD_TESTING AND FUZZING) + add_executable( + TerminalServerFuzzer + test/TerminalServerFuzzer.cpp +@@ -582,7 +586,7 @@ else(WIN32) + ${Boost_LIBRARIES} + ${CORE_LIBRARIES}) + decorate_fuzzer(TerminalServerRouterFuzzer) +- endif(FUZZING) ++ endif(BUILD_TESTING AND FUZZING) + + install( + TARGETS etserver etterminal et htm htmd diff --git a/srcpkgs/EternalTerminal/patches/disable-tests.patch b/srcpkgs/EternalTerminal/patches/disable-tests.patch deleted file mode 100644 index f7dcee020b9b..000000000000 --- a/srcpkgs/EternalTerminal/patches/disable-tests.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/EternalTerminal/CMakeLists.txt -+++ b/EternalTerminal/CMakeLists.txt -@@ -519,17 +519,8 @@ - ${CORE_LIBRARIES}) - decorate_target(htmd) - -- enable_testing() -- -- file(GLOB TEST_SRCS test/*Test.cpp) -- add_executable( -- et-test -- ${TEST_SRCS} -- test/Main.cpp -- ) -- add_dependencies(et-test TerminalCommon et-lib) -+ add_dependencies(TerminalCommon et-lib) - target_link_libraries( -- et-test - TerminalCommon - et-lib - ${CMAKE_THREAD_LIBS_INIT} -@@ -539,8 +530,6 @@ - ${UTEMPTER_LIBRARIES} - ${Boost_LIBRARIES} - ${CORE_LIBRARIES}) -- add_test(et-test et-test) -- decorate_target(et-test) - - if(FUZZING) - add_executable( diff --git a/srcpkgs/EternalTerminal/patches/fix-cflags.patch b/srcpkgs/EternalTerminal/patches/fix-cflags.patch index 952005b1bd48..ce7e998804ee 100644 --- a/srcpkgs/EternalTerminal/patches/fix-cflags.patch +++ b/srcpkgs/EternalTerminal/patches/fix-cflags.patch @@ -1,7 +1,7 @@ Index: EternalTerminal-et-v6.0.13/CMakeLists.txt =================================================================== ---- a/EternalTerminal/CMakeLists.txt -+++ b/EternalTerminal/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt @@ -187,12 +187,6 @@ "${CMAKE_CXX_FLAGS} -DELPP_DISABLE_DEFAULT_CRASH_HANDLING") endif(DISABLE_CRASH_LOG) diff --git a/srcpkgs/EternalTerminal/patches/tunnelutils.patch b/srcpkgs/EternalTerminal/patches/tunnelutils.patch new file mode 100644 index 000000000000..f5f6fe690091 --- /dev/null +++ b/srcpkgs/EternalTerminal/patches/tunnelutils.patch @@ -0,0 +1,45 @@ +https://github.com/MisterTea/EternalTerminal/commit/fde8a7cb084bb6bc005b8205f4257e7f65978521 + +Only the diff for src/base/TunnelUtils.hpp is used here, the rest is +retained as is. + +From fde8a7cb084bb6bc005b8205f4257e7f65978521 Mon Sep 17 00:00:00 2001 +From: kruceter +Date: Thu, 26 Jan 2023 20:38:12 +0300 +Subject: [PATCH] Fix cross build with GCC 12 (#564) + +* src/base/TunnelUtils.hpp: replace "ETerminal.pb.h" with "Headers.hpp" + +Fixes "strings" and "vectors" not having a type. + +Headers.hpp already includes ETerminal.pb.h. + +* external/cxxopts: update submodule + +Needed in order to fix cross build with GCC 12. + +Note that the submodule is updated to revision +c74846a891b3cc3bfa992d588b1295f528d43039 which is equal to the tagged +version 3.0.0. + +This decision was made due to the changes in master of cxxopts breaking +EternalTerminal (such as removing cxxopts::OptionException from the +code). +--- + external/cxxopts | 2 +- + src/base/TunnelUtils.hpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/base/TunnelUtils.hpp b/src/base/TunnelUtils.hpp +index 207969ee..42e96cc4 100644 +--- a/src/base/TunnelUtils.hpp ++++ b/src/base/TunnelUtils.hpp +@@ -1,7 +1,7 @@ + #ifndef __ET_TUNNEL_UTILS__ + #define __ET_TUNNEL_UTILS__ + +-#include "ETerminal.pb.h" ++#include "Headers.hpp" + + namespace et { + diff --git a/srcpkgs/EternalTerminal/patches/use_system_libs.patch b/srcpkgs/EternalTerminal/patches/use_system_libs.patch new file mode 100644 index 000000000000..557975d1593f --- /dev/null +++ b/srcpkgs/EternalTerminal/patches/use_system_libs.patch @@ -0,0 +1,112 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2368dfc2..a377bc57 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.0.2) + + set(EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external") + ++option(USE_SYSTEM_LIBS "Prefer to use system libraries" OFF) ++ ++if(USE_SYSTEM_LIBS) ++ set(DISABLE_VCPKG ON) ++endif() ++ + if(DISABLE_VCPKG) + else() + # Enable vcpkg +@@ -100,6 +106,68 @@ find_package(Protobuf REQUIRED) + find_package(ZLIB REQUIRED) + find_package(Unwind) + ++if(USE_SYSTEM_LIBS) ++ find_package(cxxopts 3.0.0) ++ if(cxxopts_FOUND) ++ message(STATUS "Found cxxopts (${cxxopts_VERSION})") ++ list(INSERT CORE_LIBRARIES 0 cxxopts::cxxopts) ++ else() ++ message(STATUS "No suitable system cxxopts found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/cxxopts/include) ++ endif() ++ ++ find_package(msgpack 4.1.1) ++ if(msgpack_FOUND) ++ message(STATUS "Found msgpack (${msgpack_VERSION})") ++ list(INSERT CORE_LIBRARIES 0 msgpackc-cxx::msgpackc-cxx) ++ else() ++ message(STATUS "No suitable system msgpack found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/msgpack-c/include) ++ endif() ++ ++ find_package(nlohmann_json 3.10.0) ++ if(nlohmann_json_FOUND) ++ list(INSERT CORE_LIBRARIES 0 nlohmann_json::nlohmann_json) ++ else() ++ message(STATUS "No suitable system json-c++ found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/json/include) ++ endif() ++ ++ find_package(simpleini 4.18) ++ if(simpleini_FOUND) ++ list(INSERT CORE_LIBRARIES 0 simpleini::simpleini) ++ else() ++ message(STATUS "No suitable system simpleini found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/simpleini) ++ endif() ++ ++ if(BUILD_TESTING) ++ find_package(Catch2 2.13.7) ++ if(Catch2_FOUND) ++ message(STATUS "Found catch2 (${Catch2_VERSION})") ++ list(INSERT CORE_LIBRARIES 0 Catch2::Catch2) ++ else() ++ message(STATUS "No suitable system catch2 found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/Catch2/single_include) ++ endif() ++ endif() ++ ++ find_package(httplib 0.8.0) ++ if(httplib_FOUND) ++ list(INSERT CORE_LIBRARIES 0 httplib::httplib) ++ else() ++ message(STATUS "No suitable system httplib found, using bundled library") ++ include_directories(${EXTERNAL_DIR}/cpp-httplib) ++ endif() ++else() ++ include_directories(${EXTERNAL_DIR}/cxxopts/include ++ ${EXTERNAL_DIR}/msgpack-c/include ++ ${EXTERNAL_DIR}/json/include ++ ${EXTERNAL_DIR}/simpleini ++ ${EXTERNAL_DIR}/Catch2/single_include ++ ${EXTERNAL_DIR}/cpp-httplib) ++endif() ++ + # Optional packages + find_package(UTempter) + if(LINUX) +@@ -321,14 +389,8 @@ include_directories( + ${EXTERNAL_DIR}/easyloggingpp/src + ${EXTERNAL_DIR}/ThreadPool + ${EXTERNAL_DIR}/PlatformFolders +- ${EXTERNAL_DIR}/Catch2/single_include +- ${EXTERNAL_DIR}/cxxopts/include +- ${EXTERNAL_DIR}/msgpack-c/include +- ${EXTERNAL_DIR}/json/single_include/nlohmann + ${EXTERNAL_DIR}/sole + ${EXTERNAL_DIR}/base64 +- ${EXTERNAL_DIR}/simpleini +- ${EXTERNAL_DIR}/cpp-httplib + src/base + src/terminal + src/terminal/forwarding +diff --git a/src/base/JsonLib.hpp b/src/base/JsonLib.hpp +index a0de911b..d206bd99 100644 +--- a/src/base/JsonLib.hpp ++++ b/src/base/JsonLib.hpp +@@ -1,5 +1,5 @@ + #pragma once + +-#include "json.hpp" ++#include "nlohmann/json.hpp" + + using json = nlohmann::json; diff --git a/srcpkgs/EternalTerminal/template b/srcpkgs/EternalTerminal/template index 1017a1b4a1ec..4de6d14fc99d 100644 --- a/srcpkgs/EternalTerminal/template +++ b/srcpkgs/EternalTerminal/template @@ -1,34 +1,34 @@ # Template file for 'EternalTerminal' pkgname=EternalTerminal -version=6.2.1 +version=6.2.4 revision=1 # revisions used for the specific versions of submodules. # they can be found in the external/ directory of the source code. _sanitizers_gitrev="99e159ec9bc8dd362b08d18436bd40ff0648417b" _threadpool_gitrev="9a42ec1329f259a5f4881a291db1dcb8f2ad9040" -build_wrksrc=${pkgname} +build_wrksrc=EternalTerminal-et-v${version} build_style=cmake -configure_args="-DDISABLE_VCPKG=ON -DDISABLE_TELEMETRY=ON -DDISABLE_SENTRY=ON" -hostmakedepends="protobuf" -makedepends="gflags-devel libsodium-devel protobuf-devel openssl-devel - zlib-devel" +configure_args="-DUSE_SYSTEM_LIBS=ON -DDISABLE_TELEMETRY=ON -DDISABLE_SENTRY=ON + -DBUILD_TESTING=OFF" +hostmakedepends="protobuf pkg-config" +makedepends="libsodium-devel protobuf-devel openssl-devel zlib-devel cxxopts + msgpack-cxx json-c++" short_desc="Re-Connectable secure remote shell" maintainer="Orphaned " license="Apache-2.0" homepage="https://eternalterminal.dev/" -distfiles="https://github.com/MisterTea/EternalTerminal/archive/et-v${version}.tar.gz +distfiles="https://github.com/MisterTea/EternalTerminal/archive/refs/tags/et-v${version}.tar.gz https://github.com/arsenm/sanitizers-cmake/archive/${_sanitizers_gitrev}.tar.gz https://github.com/progschj/ThreadPool/archive/${_threadpool_gitrev}.tar.gz" -checksum="fdf68a51cb8b62b3dbbacd1d2aeba5d5491e5142e65c97713c2f1ce61d4fdbed +checksum="95cfb79bc2f25d19eb84ca3c28dba860bb52b3750334d373adeb2cd061de6ba6 f9cf386638f455c5d2e7a835b95941201387d2531b8682942d59827663b58341 954e0ecdac1aa0da1e0fa78577ff0d352e53094df43762fbc1884f76a7e1dcd2" system_accounts="_eternal" +patch_args="-Np1 --directory=${build_wrksrc}" # UnixSocketHandler.cpp:53 Error reading: 104 Connection reset by peer # SocketHandler.cpp:91 Failed a call to writeAll: Broken pipe make_check=no -LDFLAGS="-lgflags" - if [ "$XBPS_TARGET_LIBC" = "musl" ]; then makedepends+=" libexecinfo-devel" fi @@ -38,10 +38,10 @@ if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then fi post_extract() { - mv EternalTerminal-et-v${version} ${build_wrksrc} mv sanitizers-cmake-${_sanitizers_gitrev}/* \ ${build_wrksrc}/external/sanitizers-cmake - mv ThreadPool-${_threadpool_gitrev}/* ${build_wrksrc}/external/ThreadPool + mv ThreadPool-${_threadpool_gitrev}/* \ + ${build_wrksrc}/external/ThreadPool } post_patch() {