homebrew-core/Formula/bareos-client.rb

103 lines
4.1 KiB
Ruby

class BareosClient < Formula
desc "Client for Bareos (Backup Archiving REcovery Open Sourced)"
homepage "https://www.bareos.org/"
url "https://github.com/bareos/bareos/archive/Release/21.1.4.tar.gz"
sha256 "ed898221182f2dbca712d0e85715cb5f9dd9d2c78f0e20eb7a13ae35d08701bb"
license "AGPL-3.0-only"
livecheck do
url :stable
regex(%r{^Release/(\d+(?:\.\d+)+)$}i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "070415ec259f5509f1930194e4add8be5ebdce1078a4e431b6d654790af76b1a"
sha256 cellar: :any, arm64_big_sur: "d691d0c6582988202fa81d8dd01e10420b61de2ddd383965f811516848df3c78"
sha256 cellar: :any, monterey: "9af0c42007122fd390c7d9395dacd6120f94180a0fd15df3e0255a02b487481d"
sha256 cellar: :any, big_sur: "19d9308e849f60602163ec54c0b372ab5f779bb98002fef4a1870d45b0a066a0"
sha256 cellar: :any, catalina: "7c35043594e6a10486d956f5717342fbf731884c151f2506a14abbc3299b52a6"
sha256 x86_64_linux: "092fcde0d57ebc062213811dd2b734b39b3d6d91f6956061180d88f49f23f044"
end
depends_on "cmake" => :build
depends_on "jansson"
depends_on "lzo"
depends_on "openssl@1.1"
depends_on "readline"
uses_from_macos "zlib"
on_macos do
depends_on "gettext"
end
on_linux do
depends_on "acl"
end
conflicts_with "bacula-fd", because: "both install a `bconsole` executable"
def install
# Work around hardcoded paths to /usr/local Homebrew installation,
# forced static linkage on macOS, and openssl formula alias usage.
inreplace "core/CMakeLists.txt" do |s|
s.gsub! "/usr/local/opt/gettext/lib/libintl.a", Formula["gettext"].opt_lib/shared_library("libintl")
s.gsub! "/usr/local/opt/openssl", Formula["openssl@1.1"].opt_prefix
s.gsub! "/usr/local/", "#{HOMEBREW_PREFIX}/"
end
inreplace "core/src/plugins/CMakeLists.txt" do |s|
s.gsub! "/usr/local/opt/gettext/include", Formula["gettext"].opt_include
s.gsub! "/usr/local/opt/openssl/include", Formula["openssl@1.1"].opt_include
end
inreplace "core/cmake/BareosFindAllLibraries.cmake" do |s|
s.gsub! "/usr/local/opt/lzo/lib/liblzo2.a", Formula["lzo"].opt_lib/shared_library("liblzo2")
s.gsub! "set(OPENSSL_USE_STATIC_LIBS 1)", ""
end
inreplace "core/cmake/FindReadline.cmake",
"/usr/local/opt/readline/lib/libreadline.a",
Formula["readline"].opt_lib/shared_library("libreadline")
system "cmake", "-S", ".", "-B", "build", *std_cmake_args,
"-DENABLE_PYTHON=OFF",
"-Dworkingdir=#{var}/lib/bareos",
"-Darchivedir=#{var}/bareos",
"-Dconfdir=#{etc}/bareos",
"-Dconfigtemplatedir=#{lib}/bareos/defaultconfigs",
"-Dscriptdir=#{lib}/bareos/scripts",
"-Dplugindir=#{lib}/bareos/plugins",
"-Dfd-password=XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX",
"-Dmon-fd-password=XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX",
"-Dbasename=XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX",
"-Dhostname=XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX",
"-Dclient-only=ON"
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
def post_install
(var/"lib/bareos").mkpath
# If no configuration files are present,
# deploy them (copy them and replace variables).
unless (etc/"bareos/bareos-fd.d").exist?
system lib/"bareos/scripts/bareos-config", "deploy_config",
lib/"bareos/defaultconfigs", etc/"bareos", "bareos-fd"
system lib/"bareos/scripts/bareos-config", "deploy_config",
lib/"bareos/defaultconfigs", etc/"bareos", "bconsole"
end
end
plist_options startup: true
service do
run [opt_sbin/"bareos-fd", "-f"]
log_path var/"run/bareos-fd.log"
error_log_path var/"run/bareos-fd.log"
end
test do
# Check if bareos-fd starts at all.
assert_match version.to_s, shell_output("#{sbin}/bareos-fd -? 2>&1", 1)
# Check if the configuration is valid.
system sbin/"bareos-fd", "-t"
end
end