74 lines
2.6 KiB
Ruby
74 lines
2.6 KiB
Ruby
class Dnsmasq < Formula
|
|
desc "Lightweight DNS forwarder and DHCP server"
|
|
homepage "https://thekelleys.org.uk/dnsmasq/doc.html"
|
|
url "https://thekelleys.org.uk/dnsmasq/dnsmasq-2.86.tar.gz"
|
|
sha256 "ef15f608a83ee2b1d1d2c1f11d089a7e0ac401ffb0991de73fc01ce5f290e512"
|
|
license any_of: ["GPL-2.0-only", "GPL-3.0-only"]
|
|
|
|
livecheck do
|
|
url "https://thekelleys.org.uk/dnsmasq/"
|
|
regex(/href=.*?dnsmasq[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "9f25c2cfab3902767464a11a49151503c8532a554ee9f8452f536bbbec4c7b04"
|
|
sha256 arm64_big_sur: "958b73b470c3fad28aa5144afd18cbc423448d70bb74ecd45ee296384f97b37e"
|
|
sha256 monterey: "d4e2c92c41d0a580868a2bc68c3b1caa5257bd241b89c1b88c5e74c73d59f78b"
|
|
sha256 big_sur: "ebcab796c2876217e0bcaa2db862ce407a784c81f8d5d2c2b625122945e13944"
|
|
sha256 catalina: "fb1bbf13dd64a0fd3e4d75773795cd7edc4345bbdf3290399ebaca6f08d645ad"
|
|
sha256 mojave: "4ea6a7c2ab644ee388a5489307c3c4bb2b358f7eafeb32676fd1cdcc89aeb33d"
|
|
sha256 x86_64_linux: "b5ae5a7152ef11bbcdc2a8444d3c4f830da1228b484eb98b1e2db8e0ce6e19f5"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
|
|
def install
|
|
ENV.deparallelize
|
|
|
|
# Fix etc location
|
|
inreplace %w[dnsmasq.conf.example src/config.h man/dnsmasq.8
|
|
man/es/dnsmasq.8 man/fr/dnsmasq.8].each do |s|
|
|
s.gsub! "/var/lib/misc/dnsmasq.leases",
|
|
var/"lib/misc/dnsmasq/dnsmasq.leases", false
|
|
s.gsub! "/etc/dnsmasq.conf", etc/"dnsmasq.conf", false
|
|
s.gsub! "/var/run/dnsmasq.pid", var/"run/dnsmasq/dnsmasq.pid", false
|
|
s.gsub! "/etc/dnsmasq.d", etc/"dnsmasq.d", false
|
|
s.gsub! "/etc/ppp/resolv.conf", etc/"dnsmasq.d/ppp/resolv.conf", false
|
|
s.gsub! "/etc/dhcpc/resolv.conf", etc/"dnsmasq.d/dhcpc/resolv.conf", false
|
|
s.gsub! "/usr/sbin/dnsmasq", HOMEBREW_PREFIX/"sbin/dnsmasq", false
|
|
end
|
|
|
|
# Fix compilation on newer macOS versions.
|
|
ENV.append_to_cflags "-D__APPLE_USE_RFC_3542"
|
|
|
|
inreplace "Makefile" do |s|
|
|
s.change_make_var! "CFLAGS", ENV.cflags
|
|
s.change_make_var! "LDFLAGS", ENV.ldflags
|
|
end
|
|
|
|
system "make", "install", "PREFIX=#{prefix}"
|
|
|
|
etc.install "dnsmasq.conf.example" => "dnsmasq.conf"
|
|
end
|
|
|
|
def post_install
|
|
(var/"lib/misc/dnsmasq").mkpath
|
|
(var/"run/dnsmasq").mkpath
|
|
(etc/"dnsmasq.d/ppp").mkpath
|
|
(etc/"dnsmasq.d/dhcpc").mkpath
|
|
touch etc/"dnsmasq.d/ppp/.keepme"
|
|
touch etc/"dnsmasq.d/dhcpc/.keepme"
|
|
end
|
|
|
|
plist_options startup: true
|
|
|
|
service do
|
|
run [opt_sbin/"dnsmasq", "--keep-in-foreground", "-C", etc/"dnsmasq.conf", "-7", etc/"dnsmasq.d,*.conf"]
|
|
keep_alive true
|
|
end
|
|
|
|
test do
|
|
system "#{sbin}/dnsmasq", "--test"
|
|
end
|
|
end
|