73 lines
2.5 KiB
Ruby
73 lines
2.5 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.85.tar.gz"
|
|
sha256 "f36b93ecac9397c15f461de9b1689ee5a2ed6b5135db0085916233053ff3f886"
|
|
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
|
|
rebuild 1
|
|
sha256 arm64_big_sur: "a5dff893836bb30d9dd1b2ae17a3b5c57936a570014babd188d6d6935fb8cd25"
|
|
sha256 big_sur: "d277d696e1432881e4bbbc0d68443fbdec125d0dd83c9041d5d58bcab0acae5e"
|
|
sha256 catalina: "945ab265756b63a2040d5bdcc4f8c2c24e379d60ed2e21249b77eade885630ff"
|
|
sha256 mojave: "6054ac54814f919df6733c9f8180444b3b199321cbb0616b5ae084afa0ceaf66"
|
|
sha256 x86_64_linux: "942087bde70b4afff2bd59105ab5e0b17fb025745034b7baaafaa4c337be150f"
|
|
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
|