homebrew-core/Formula/sysdig.rb

115 lines
4.4 KiB
Ruby

class Sysdig < Formula
desc "System-level exploration and troubleshooting tool"
homepage "https://sysdig.com/"
license "Apache-2.0"
revision 8
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_ventura: "56f06fce0f517306e085ecaad7ce6d4e5a0fa2e4dbb9e21263c4d023ea715ed6"
sha256 arm64_monterey: "ff684cddac03d6c30fd4b2ceae492eb5528d5c22b3b32324303b15c31be662a4"
sha256 arm64_big_sur: "65114a1660c646dfbaa095cd922f6840f8e8b2658fbb4b3e7890fa82f566484f"
sha256 ventura: "9ecf14d8ce20e8859e239ad7497e244a15c459e4110e4277245ce34d2cfcb7bf"
sha256 monterey: "cbc6554ef1ea6abeafca41cf198287725570b4e42a81c649537197897c87fd08"
sha256 big_sur: "4e2198aed7509c1367e63fbec1e6a1f46bead140e2ea4c1cde3b60a421269dfd"
sha256 catalina: "ddacde082b4e2b358cd7602ee1826fb777f132f36d733a7f57bc1f6572873660"
sha256 cellar: :any_skip_relocation, x86_64_linux: "1da482af1e21d340040bcf3c21863438052dad58feb1fd644c503f4273a630a0"
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