homebrew-core/Formula/bareos-client.rb

113 lines
4.5 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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/22.0.1.tar.gz"
sha256 "4b59c90e767ff6e84278d4671ec487fdcd3c85bb0b4dbf886e9637ae8f4ae505"
license "AGPL-3.0-only"
livecheck do
url :stable
regex(%r{^Release/(\d+(?:\.\d+)+)$}i)
end
bottle do
sha256 arm64_ventura: "c31bff5b89e2fd69fbff2c19fdfbe383527d5d8eca3432c1a3a70e9c7517ab9f"
sha256 arm64_monterey: "5a655725bfb5880b577446a8e0f2ab0dbd5e68ec573145ebc23b873db49346d6"
sha256 arm64_big_sur: "3549a05fe64407e3272cb7e424db96fb98054eb1b59fc3eeecb1a081cf0dc198"
sha256 ventura: "4a0c60b4b2890665f46b79e5b6cd094cdad8dc652b2c01a913dc8ae48585e49a"
sha256 monterey: "62d3c9fb618f92b7020155a40b4ad35d492ac12f14d8d59eeda4e50a521f7d15"
sha256 big_sur: "d1d568fae299d0b058065845fd02cefb1e7e15c81549cea7e51619ea5b6445c5"
sha256 x86_64_linux: "fd6faed2dc6a3a6e078fa58d00df9aa23cf671eec7fa5fd2d50e9d455de0979d"
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 warnings:
# lmdb/mdb.c:2282:13: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
# fastlzlib.c:512:63: error: unused parameter output_length [-Werror=unused-parameter]
# Upstream issue: https://bugs.bareos.org/view.php?id=1504
if OS.linux?
ENV.append_to_cflags "-Wno-unused-but-set-variable"
ENV.append_to_cflags "-Wno-unused-parameter"
end
# 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
service do
run [opt_sbin/"bareos-fd", "-f"]
require_root true
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")
# Check if the configuration is valid.
system sbin/"bareos-fd", "-t"
end
end