From 7e6266d33da6651c82a7a94b79ebc7a9865ca7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sun, 15 Jan 2023 19:52:21 +0000 Subject: [PATCH] MSYS2: Add Lua 5.1 support and fix test suite failures --- README.msys2 | 12 ++++++++---- cmake/modules/FindLUA.cmake | 9 +++++++++ cmakeconfig.h.in | 3 +++ epan/epan.c | 6 +++++- packaging/msys2/mingw-w64-wireshark-git/PKGBUILD | 1 + test/fixtures_ws.py | 1 + test/suite_clopts.py | 2 ++ test/suite_wslua.py | 3 +++ tools/msys2-setup.sh | 15 +++++---------- 9 files changed, 37 insertions(+), 15 deletions(-) diff --git a/README.msys2 b/README.msys2 index 5a82edd117..e9cfb58f76 100644 --- a/README.msys2 +++ b/README.msys2 @@ -30,9 +30,12 @@ How to build the Wireshark MSYS2 package: The application must be run from the MINGW64 shell. -Currently the Wireshark MinGW-w64 build has the following limitations: +Currently the MinGW-w64 build has the following limitations compared to +the MSVC build: -* The ETW extcap (etwdump) is not supported. +* The Event Tracing for Windows (ETW) extcap is not supported. + +* Lua version is 5.1 (MSVC uses Lua 5.2) and does not have UTF-8 patches[1]. * Some optional dependencies are not available in the official MSYS2 repositories. These are: @@ -40,11 +43,12 @@ Currently the Wireshark MinGW-w64 build has the following limitations: - AirPcap - libsmi - Kerberos - - Lua-unicode (Lua 5.1 is available and can be used instead) - SBC codec - BCG729 codec * There is currently no way to build a stand-alone distributable binary package, similar to the Wireshark NSIS installer built using Visual Studio. -* Many compiler warnings to be fixed. +References: + +[1]https://github.com/Lekensteyn/lua-unicode diff --git a/cmake/modules/FindLUA.cmake b/cmake/modules/FindLUA.cmake index 0336ca6a10..bc2a41e1f6 100644 --- a/cmake/modules/FindLUA.cmake +++ b/cmake/modules/FindLUA.cmake @@ -100,6 +100,15 @@ IF(LUA_FOUND) ) mark_as_advanced( LUA_DLL_DIR LUA_DLL ) endif() + if(LUA_DLL_DIR MATCHES ".*/lua-.*-unicode-.*") + # Do we have Lua with Unicode for Windows patches? + # https://github.com/Lekensteyn/lua-unicode + # XXX Would be better if it was possible to + # detect a Lua-unicode build from C and Lua code + # but upstream rejected patches for that so we do + # it here. + set(HAVE_LUA_UNICODE True) + endif() ELSE(LUA_FOUND) SET( LUA_LIBRARIES ) SET( LUA_INCLUDE_DIRS ) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index ab4d21c511..623de76cd5 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -163,6 +163,9 @@ /* Define to use Lua */ #cmakedefine HAVE_LUA 1 +/* Define to 1 if we have Lua with Unicode for Windows patches. */ +#cmakedefine HAVE_LUA_UNICODE 1 + /* Define to use MIT kerberos */ #cmakedefine HAVE_MIT_KERBEROS 1 diff --git a/epan/epan.c b/epan/epan.c index db3b8720a7..cc98603c52 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -779,8 +779,12 @@ epan_gather_compile_info(feature_list l) { /* Lua */ #ifdef HAVE_LUA +#ifdef HAVE_LUA_UNICODE + with_feature(l, "%s", LUA_RELEASE" (with UfW patches)"); +#else /* HAVE_LUA_UNICODE */ with_feature(l, "%s", LUA_RELEASE); -#else +#endif /* HAVE_LUA_UNICODE */ +#else /* HAVE_LUA */ without_feature(l, "Lua"); #endif /* HAVE_LUA */ diff --git a/packaging/msys2/mingw-w64-wireshark-git/PKGBUILD b/packaging/msys2/mingw-w64-wireshark-git/PKGBUILD index 0834e80005..84c3bb32cf 100644 --- a/packaging/msys2/mingw-w64-wireshark-git/PKGBUILD +++ b/packaging/msys2/mingw-w64-wireshark-git/PKGBUILD @@ -20,6 +20,7 @@ depends=("${MINGW_PACKAGE_PREFIX}-brotli" "${MINGW_PACKAGE_PREFIX}-libpcap" "${MINGW_PACKAGE_PREFIX}-libssh" "${MINGW_PACKAGE_PREFIX}-libxml2" + "${MINGW_PACKAGE_PREFIX}-lua51" "${MINGW_PACKAGE_PREFIX}-lz4" "${MINGW_PACKAGE_PREFIX}-minizip" "${MINGW_PACKAGE_PREFIX}-nghttp2" diff --git a/test/fixtures_ws.py b/test/fixtures_ws.py index 8f4ba7e0d9..10fb5522bd 100644 --- a/test/fixtures_ws.py +++ b/test/fixtures_ws.py @@ -177,6 +177,7 @@ def features(cmd_tshark, make_env): return types.SimpleNamespace( have_x64='Compiled (64-bit)' in tshark_v, have_lua='with Lua' in tshark_v, + have_lua_unicode='(with UfW patches)' in tshark_v, have_nghttp2='with nghttp2' in tshark_v, have_kerberos='with Kerberos' in tshark_v, have_gnutls='with GnuTLS' in tshark_v, diff --git a/test/suite_clopts.py b/test/suite_clopts.py index 553c1dad47..14138f0162 100644 --- a/test/suite_clopts.py +++ b/test/suite_clopts.py @@ -209,6 +209,8 @@ class case_tshark_dump_glossaries(subprocesstest.SubprocessTestCase): '''Folders output with unicode''' if not features.have_lua: self.skipTest('Test requires Lua scripting support.') + if sys.platform == 'win32' and not features.have_lua_unicode: + self.skipTest('Test requires a patched Lua build with UTF-8 support.') proc = self.assertRun((cmd_tshark, '-G', 'folders'), env=unicode_env.env) out = proc.stdout_str pluginsdir = [x.split('\t', 1)[1] for x in out.splitlines() if x.startswith('Personal Lua Plugins:')] diff --git a/test/suite_wslua.py b/test/suite_wslua.py index a564860189..1c69c10ece 100644 --- a/test/suite_wslua.py +++ b/test/suite_wslua.py @@ -8,6 +8,7 @@ # '''Wireshark Lua scripting tests''' +import sys import filecmp import os.path import shutil @@ -284,6 +285,8 @@ class case_wslua_unicode(subprocesstest.SubprocessTestCase): '''Check handling of unicode paths.''' if not features.have_lua: self.skipTest('Test requires Lua scripting support.') + if sys.platform == 'win32' and not features.have_lua_unicode: + self.skipTest('Test requires a patched Lua build with UTF-8 support.') # Prepare test environment, put files in the right places. uni_script = os.path.join(unicode_env.pluginsdir, 'script-Ф-€-中.lua') diff --git a/tools/msys2-setup.sh b/tools/msys2-setup.sh index cfe5f0f210..1c000655b6 100644 --- a/tools/msys2-setup.sh +++ b/tools/msys2-setup.sh @@ -24,7 +24,6 @@ function print_usage() { ADDITIONAL=0 TESTDEPS=0 -LUA=0 OPTIONS= for arg; do case $arg in @@ -41,7 +40,6 @@ for arg; do --install-all) ADDITIONAL=1 TESTDEPS=1 - LUA=1 ;; *) OPTIONS="$OPTIONS $arg" @@ -52,9 +50,10 @@ done PACKAGE_PREFIX="${MINGW_PACKAGE_PREFIX:-mingw-w64-x86_64}" # -# Lua is kind of a mess. Lua 5.2 is not available. Some packages depend -# on LuaJIT and it conflicts with Lua 5.1. This will probably have to -# be fixed by the MSYS2 maintainers. Take a hands off approach for now. +# Lua packaging is kind of a mess. Lua 5.2 is not available. Some packages have +# a hard dependy on LuaJIT and it conflicts with Lua 5.1 and vice-versa. +# This will probably have to be fixed by the MSYS2 maintainers. +# XXX Is this still true? # BASIC_LIST="base-devel \ git \ @@ -70,6 +69,7 @@ BASIC_LIST="base-devel \ ${PACKAGE_PREFIX}-libpcap \ ${PACKAGE_PREFIX}-libssh \ ${PACKAGE_PREFIX}-libxml2 \ + ${PACKAGE_PREFIX}-lua51 \ ${PACKAGE_PREFIX}-lz4 \ ${PACKAGE_PREFIX}-minizip \ ${PACKAGE_PREFIX}-ninja \ @@ -121,8 +121,3 @@ if [ $TESTDEPS -eq 0 ] then printf "\n*** Test deps not installed. Rerun with --install-test-deps to have them.\n" fi - -if [ $LUA -ne 0 ] -then - printf "\n*** Lua 5.1 can be installed with: pacman -S ${PACKAGE_PREFIX}-lua51\n" -fi