mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
Merge pull request #330742 from Feyorsh/wireshark-darwin
This commit is contained in:
commit
9028a0db10
|
@ -9,6 +9,7 @@
|
|||
, buildPackages
|
||||
, c-ares
|
||||
, cmake
|
||||
, fixDarwinDylibNames
|
||||
, flex
|
||||
, gettext
|
||||
, glib
|
||||
|
@ -49,7 +50,9 @@
|
|||
, withQt ? true
|
||||
, qt6 ? null
|
||||
}:
|
||||
|
||||
let
|
||||
isAppBundle = withQt && stdenv.isDarwin;
|
||||
in
|
||||
assert withQt -> qt6 != null;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
|
@ -86,6 +89,8 @@ stdenv.mkDerivation rec {
|
|||
] ++ lib.optionals withQt [
|
||||
qt6.wrapQtAppsHook
|
||||
wrapGAppsHook3
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
fixDarwinDylibNames
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
|
@ -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.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 = ''
|
||||
|
|
Loading…
Reference in a new issue