about summary refs log tree commit diff
path: root/pkgs/applications/networking/sniffers/wireshark
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/sniffers/wireshark')
-rw-r--r--pkgs/applications/networking/sniffers/wireshark/default.nix44
1 files changed, 32 insertions, 12 deletions
diff --git a/pkgs/applications/networking/sniffers/wireshark/default.nix b/pkgs/applications/networking/sniffers/wireshark/default.nix
index d7d9d68bf3327..04f62befcc9bd 100644
--- a/pkgs/applications/networking/sniffers/wireshark/default.nix
+++ b/pkgs/applications/networking/sniffers/wireshark/default.nix
@@ -9,6 +9,7 @@
 , buildPackages
 , c-ares
 , cmake
+, fixDarwinDylibNames
 , flex
 , gettext
 , glib
@@ -49,12 +50,14 @@
 , withQt ? true
 , qt6 ? null
 }:
-
+let
+  isAppBundle = withQt && stdenv.hostPlatform.isDarwin;
+in
 assert withQt -> qt6 != null;
 
 stdenv.mkDerivation rec {
   pname = "wireshark-${if withQt then "qt" else "cli"}";
-  version = "4.2.4";
+  version = "4.2.6";
 
   outputs = [ "out" "dev" ];
 
@@ -62,7 +65,7 @@ stdenv.mkDerivation rec {
     repo = "wireshark";
     owner = "wireshark";
     rev = "v${version}";
-    hash = "sha256-yGKqklNy1SkmWOaYI0jsTy2rLq5W/dbh8fIUrBSSdw8=";
+    hash = "sha256-zlFTUgsEKraE9crS5SZ13r93JJzUb6eyBhusJbbGwsE=";
   };
 
   patches = [
@@ -86,6 +89,8 @@ stdenv.mkDerivation rec {
   ] ++ lib.optionals withQt [
     qt6.wrapQtAppsHook
     wrapGAppsHook3
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
+    fixDarwinDylibNames
   ];
 
   buildInputs = [
@@ -121,13 +126,13 @@ stdenv.mkDerivation rec {
     qtmultimedia
     qtsvg
     qttools
-  ]) ++ lib.optionals (withQt && stdenv.isLinux) [
+  ]) ++ lib.optionals (withQt && stdenv.hostPlatform.isLinux) [
     qt6.qtwayland
-  ] ++ lib.optionals stdenv.isLinux [
+  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
     libcap
     libnl
     sbc
-  ] ++ lib.optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
     ApplicationServices
     gmp
     SystemConfiguration
@@ -139,7 +144,7 @@ stdenv.mkDerivation rec {
     "-DBUILD_wireshark=${if withQt then "ON" else "OFF"}"
     # Fix `extcap` and `plugins` paths. See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=16444
     "-DCMAKE_INSTALL_LIBDIR=lib"
-    "-DENABLE_APPLICATION_BUNDLE=${if withQt && stdenv.isDarwin then "ON" else "OFF"}"
+    "-DENABLE_APPLICATION_BUNDLE=${if isAppBundle then "ON" else "OFF"}"
     "-DLEMON_C_COMPILER=cc"
   ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
     "-DHAVE_C99_VSNPRINTF_EXITCODE__TRYRUN_OUTPUT="
@@ -163,14 +168,20 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     cmake --install . --prefix "''${!outputDev}" --component Development
-  '' + lib.optionalString (stdenv.isDarwin && withQt) ''
+  '' + lib.optionalString isAppBundle ''
     mkdir -p $out/Applications
     mv $out/bin/Wireshark.app $out/Applications/Wireshark.app
+  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
+    local flags=()
+    for file in $out/lib/*.dylib; do
+      flags+=(-change @rpath/"$(basename "$file")" "$file")
+    done
 
-    for f in $(find $out/Applications/Wireshark.app/Contents/PlugIns -name "*.so"); do
-        for dylib in $(otool -L $f | awk '/^\t*lib/ {print $1}'); do
-            install_name_tool -change "$dylib" "$out/lib/$dylib" "$f"
-        done
+    for file in $out/lib/wireshark/extcap/*; do
+      if [ -L "$file" ]; then continue; fi
+      echo "$file: fixing dylib references"
+      # note that -id does nothing on binaries
+      install_name_tool -id "$file" "''${flags[@]}" "$file"
     done
   '';
 
@@ -178,6 +189,15 @@ stdenv.mkDerivation rec {
     qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
   '';
 
+  # This is done to remove some binary wrappers that wrapQtApps adds in *.app directories.
+  # Copying because unfortunately pointing Wireshark (when built as an appbundle) at $out/lib instead is nontrivial.
+  postFixup = lib.optionalString isAppBundle ''
+    rm -rf $out/Applications/Wireshark.app/Contents/MacOS/extcap $out/Applications/Wireshark.app/Contents/PlugIns
+    mkdir -p $out/Applications/Wireshark.app/Contents/PlugIns/wireshark
+    cp -r $out/lib/wireshark/plugins/4-2 $out/Applications/Wireshark.app/Contents/PlugIns/wireshark/4-2
+    cp -r $out/lib/wireshark/extcap $out/Applications/Wireshark.app/Contents/MacOS/extcap
+  '';
+
   meta = with lib; {
     description = "Powerful network protocol analyzer";
     longDescription = ''