homebrew-core/Formula/sysdig.rb

113 lines
4.1 KiB
Ruby

class Sysdig < Formula
desc "System-level exploration and troubleshooting tool"
homepage "https://sysdig.com/"
license "Apache-2.0"
revision 6
stable do
url "https://github.com/draios/sysdig/archive/0.29.3.tar.gz"
sha256 "6b96797859002ab69a2bed4fdba1c7fe8064ecf8661621ae7d8fbf8599ffa636"
# Update to value of FALCOSECURITY_LIBS_VERSION found in
# https://github.com/draios/sysdig/blob/#{version}/cmake/modules/falcosecurity-libs.cmake
resource "falcosecurity-libs" do
url "https://github.com/falcosecurity/libs/archive/e5c53d648f3c4694385bbe488e7d47eaa36c229a.tar.gz"
sha256 "80903bc57b7f9c5f24298ecf1531cf66ef571681b4bd1e05f6e4db704ffb380b"
end
end
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 arm64_monterey: "f218a091ca9b6964d58dadc90fe862173f43951b09169f9b2532a6ee3b2fd5ab"
sha256 arm64_big_sur: "5a2f36091aca4ef98ee0cf45f284d0561f3d805083785cbe6058912cb4095a08"
sha256 monterey: "e75bc7edc384b52c53ed171f9bf72d6aeb70c5d4e7dc658976bee226ad10f5bc"
sha256 big_sur: "ce22432a99945a6ec951f9f8e2d8c60eae85a5b1aeecc9f65f3aa22d2eea0d91"
sha256 catalina: "2ea2fe99f92db28fe7611dd0c494f46ace70c0cee18d70fe9cee9d53471d7a15"
sha256 cellar: :any_skip_relocation, x86_64_linux: "8f52fb7645b3a3bb6895c36a077aa39bca60cf0cfaa9b2250e6bd2e5b4e0e3af"
end
head do
url "https://github.com/draios/sysdig.git", branch: "dev"
resource "falcosecurity-libs" do
url "https://github.com/falcosecurity/libs.git", branch: "master"
end
end
depends_on "cmake" => :build
depends_on "nlohmann-json" => :build
depends_on "c-ares"
depends_on "jsoncpp"
depends_on "luajit"
depends_on "openssl@1.1"
depends_on "tbb"
depends_on "yaml-cpp"
uses_from_macos "curl"
uses_from_macos "ncurses"
uses_from_macos "zlib"
on_linux do
depends_on "libb64" => :build
depends_on "elfutils"
depends_on "grpc"
depends_on "jq"
depends_on "protobuf"
end
fails_with gcc: "5" # C++17
# More info on https://gist.github.com/juniorz/9986999
resource "homebrew-sample_file" do
url "https://gist.githubusercontent.com/juniorz/9986999/raw/a3556d7e93fa890a157a33f4233efaf8f5e01a6f/sample.scap"
sha256 "efe287e651a3deea5e87418d39e0fe1e9dc55c6886af4e952468cd64182ee7ef"
end
def install
(buildpath/"falcosecurity-libs").install resource("falcosecurity-libs")
# FIXME: Workaround Apple ARM loader error due to packing.
# ld: warning: pointer not aligned at address 0x10017E21D
# (_g_event_info + 527453 from ../../libscap/libscap.a(event_table.c.o))
# ld: unaligned pointer(s) for architecture arm64
inreplace "falcosecurity-libs/driver/ppm_events_public.h", " __attribute__((packed))", "" if Hardware::CPU.arm?
# These flags are not needed for LuaJIT 2.1 (Ref: https://luajit.org/install.html).
# On Apple ARM, the flags results in broken binaries and need to be removed.
inreplace %w[CMakeLists.txt falcosecurity-libs/cmake/modules/CompilerFlags.cmake],
"set(CMAKE_EXE_LINKER_FLAGS \"-pagezero_size 10000 -image_base 100000000\")",
""
args = std_cmake_args + %W[
-DSYSDIG_VERSION=#{version}
-DUSE_BUNDLED_DEPS=OFF
-DCREATE_TEST_TARGETS=OFF
-DBUILD_LIBSCAP_EXAMPLES=OFF
-DDIR_ETC=#{etc}
-DFALCOSECURITY_LIBS_SOURCE_DIR=#{buildpath}/falcosecurity-libs
]
# `USE_BUNDLED_*=OFF` flags are implied by `USE_BUNDLED_DEPS=OFF`, but let's be explicit.
%w[LUAJIT JSONCPP ZLIB TBB JQ NCURSES B64 OPENSSL CURL CARES PROTOBUF GRPC].each do |dep|
args << "-DUSE_BUNDLED_#{dep}=OFF"
end
args << "-DBUILD_DRIVER=OFF" if OS.linux?
system "cmake", "-S", ".", "-B", "build", *args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
(pkgshare/"demos").install resource("homebrew-sample_file").files("sample.scap")
end
test do
output = shell_output("#{bin}/sysdig -r #{pkgshare}/demos/sample.scap")
assert_match "/tmp/sysdig/sample", output
end
end