/
wireshark.rb
106 lines (95 loc) 路 3.99 KB
/
wireshark.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
class Wireshark < Formula
desc "Graphical network analyzer and capture tool"
homepage "https://www.wireshark.org"
url "https://www.wireshark.org/download/src/all-versions/wireshark-4.2.4.tar.xz"
mirror "https://1.eu.dl.wireshark.org/src/all-versions/wireshark-4.2.4.tar.xz"
sha256 "46bd0f4474337144b30816fb2d8f14e72a26d0391f24fe0b7b619acdcdad8c0c"
license "GPL-2.0-or-later"
head "https://gitlab.com/wireshark/wireshark.git", branch: "master"
# Upstream indicates stable releases with an even-numbered minor (see:
# https://wiki.wireshark.org/Development/ReleaseNumbers).
livecheck do
url "https://www.wireshark.org/download.html"
regex(/href=.*?wireshark[._-]v?(\d+\.\d*[02468](?:\.\d+)*)\.t/i)
end
bottle do
sha256 arm64_sonoma: "13ced3cd27d8c68b1250123d24d0c202c296795fbdbb55078402c4852e2d3920"
sha256 arm64_ventura: "f6b02b8850471e30ca461753ba3487ee79d0d51f9d041ae8fd64d6fa6ea711bf"
sha256 arm64_monterey: "96da6c1578c6eff01085d498e4b94989e1a631b1d2893678070439658cfc4e0c"
sha256 sonoma: "9b0e56b4ebb9354c01e5e6edad53968699afd2a302a72fdbe2bde7289c3322ea"
sha256 ventura: "f5173322281a3aeaecc94821555687979fda9e909cfddf7b102958b3064219ec"
sha256 monterey: "6010a4e5583737ddbab89eecc89d86bb1834c658759562a044d9a623b34f5e5c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "8ef9dc9cc4dc3955c999c3cffd84d7b7363b8b89113c30ed31f75584edeb9b16"
end
depends_on "cmake" => :build
depends_on "c-ares"
depends_on "glib"
depends_on "gnutls"
depends_on "libgcrypt"
depends_on "libmaxminddb"
depends_on "libnghttp2"
depends_on "libsmi"
depends_on "libssh"
depends_on "lua"
depends_on "speexdsp"
uses_from_macos "bison" => :build
uses_from_macos "flex" => :build
uses_from_macos "python" => :build
uses_from_macos "libpcap"
uses_from_macos "libxml2"
def install
args = %W[
-DENABLE_CARES=ON
-DENABLE_GNUTLS=ON
-DENABLE_MAXMINDDB=ON
-DBUILD_wireshark_gtk=OFF
-DENABLE_PORTAUDIO=OFF
-DENABLE_LUA=ON
-DLUA_INCLUDE_DIR=#{Formula["lua"].opt_include}/lua
-DLUA_LIBRARY=#{Formula["lua"].opt_lib/shared_library("liblua")}
-DCARES_INCLUDE_DIR=#{Formula["c-ares"].opt_include}
-DGCRYPT_INCLUDE_DIR=#{Formula["libgcrypt"].opt_include}
-DGNUTLS_INCLUDE_DIR=#{Formula["gnutls"].opt_include}
-DMAXMINDDB_INCLUDE_DIR=#{Formula["libmaxminddb"].opt_include}
-DENABLE_SMI=ON
-DBUILD_sshdump=ON
-DBUILD_ciscodump=ON
-DENABLE_NGHTTP2=ON
-DBUILD_wireshark=OFF
-DENABLE_APPLICATION_BUNDLE=OFF
-DENABLE_QT5=OFF
-DCMAKE_INSTALL_NAME_DIR:STRING=#{lib}
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
system "cmake", "--install", "build", "--component", "Development"
end
def caveats
<<~EOS
This formula only installs the command-line utilities by default.
Install Wireshark.app with Homebrew Cask:
brew install --cask wireshark
If your list of available capture interfaces is empty
(default macOS behavior), install ChmodBPF:
brew install --cask wireshark-chmodbpf
EOS
end
test do
(testpath/"test.cpp").write <<~EOS
#include <stdio.h>
#include <ws_version.h>
int main() {
printf("%d.%d.%d", WIRESHARK_VERSION_MAJOR, WIRESHARK_VERSION_MINOR,
WIRESHARK_VERSION_MICRO);
return 0;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-I#{include}/wireshark", "-o", "test"
output = shell_output("./test")
assert_equal version.to_s, output
system bin/"randpkt", "-b", "100", "-c", "2", "capture.pcap"
output = shell_output("#{bin}/capinfos -Tmc capture.pcap")
assert_equal "File name,Number of packets\ncapture.pcap,2\n", output
end
end