homebrew-core/Formula/bareos-client.rb

109 lines
4.5 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.6.tar.gz"
sha256 "da883c7d8ded422dfc8fd9ab8467c3d79faf0d9b367328de7860ab85e1507172"
license "AGPL-3.0-only"
livecheck do
url :stable
regex(%r{^Release/(\d+(?:\.\d+)+)$}i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "6a7c8eb1e58e66920d4f3fd61261979452ef3d77d6d1f301b4d60c9693ea5406"
sha256 cellar: :any, arm64_monterey: "ee1e7a11d5a1baf0349ded5e412a8d1b4bd8344e11d507d2a39cc6c43fdda849"
sha256 cellar: :any, arm64_big_sur: "f1ccf5e63e388372fad315f56427ed49ecb9110636d5437253907984a9ce650d"
sha256 cellar: :any, ventura: "f0c9c7a88f80433a6d3464580a550982d7893623b4191149d6f8ff2b536cbd8d"
sha256 cellar: :any, monterey: "6f9388b0b0bd05562ce6586ccb1af830d386b62447ae07f5a6f63b48f72c4dfb"
sha256 cellar: :any, big_sur: "729711ab587ccd5342eba3fd5e6d76bab59aef3a8cd85cf8f4ed2124904e90ea"
sha256 x86_64_linux: "758ec8851a851efd5e8c7762ee6ee4e80460143a152c67b8e4b5cdc66d0c28e0"
end
depends_on "cmake" => :build
depends_on "jansson"
depends_on "lzo"
depends_on "openssl@3"
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 Linux build failure by disabling warning:
# lmdb/mdb.c:2282:13: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
# TODO: Try to remove in the next release which has various compiler warning changes
ENV.append_to_cflags "-Wno-unused-but-set-variable" if OS.linux?
# 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@3"].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@3"].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