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.3.tar.gz"
sha256 "3fc1241981f095c5e3db4e7476cdb273633b630820b1e1eff792b2c4d99b3d11"
license "AGPL-3.0-only"
livecheck do
url :stable
regex(%r{^Release/(\d+(?:\.\d+)+)$}i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "4c198f919032742794f8f141d3417e2e5d0d00c780796a407a521a8f1de667f6"
sha256 cellar: :any, arm64_big_sur: "510815a1a30adf00f990a482ff3b57708f0a57456d0d8a4027f241d145a2bdd1"
sha256 cellar: :any, monterey: "fdf7374d281ab4847660c4aa7b9195fd862ad3d113517781e5f9454d78190c76"
sha256 cellar: :any, big_sur: "108e203dd29a4549b0e3f4ef84f210a74d771bc85ad30f0e078f1f9293b2b3a4"
sha256 cellar: :any, catalina: "b6cb4d213407c2723b5de8b226e7d13c65b2f303154c6b672424e3ff342bc437"
sha256 x86_64_linux: "6f1e70e35203abbe06f7ef4bd2c115213a3d79a06da87077541e1a6b6982ea4a"
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