homebrew-core/Formula/lighttpd.rb

108 lines
4.0 KiB
Ruby

class Lighttpd < Formula
desc "Small memory footprint, flexible web-server"
homepage "https://www.lighttpd.net/"
url "https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.67.tar.xz"
sha256 "7e04d767f51a8d824b32e2483ef2950982920d427d1272ef4667f49d6f89f358"
license "BSD-3-Clause"
livecheck do
url "https://www.lighttpd.net/download/"
regex(/href=.*?lighttpd[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_monterey: "44407e4dd4021ff95f7f2600f2b3ee588f882ef63c8964be34fa494fc11d9fb6"
sha256 arm64_big_sur: "9f96876d812006781086e73a334bac6d9be27c8b07080548f479f49e1bdf942c"
sha256 monterey: "b767d41ed5cbdba5ae2b2cc46edeeed2ff48d99f79a646d993e5ed0b23592112"
sha256 big_sur: "43f1ac2cebffd57f6f0d25f0175972d57055ba5c517f93fcc7045ef6e4daeff5"
sha256 catalina: "fc11c0e4faff6db25521b9fc27b9f72fe599564c1b2f2d4d64276f746ca8808a"
sha256 x86_64_linux: "1aab21c024ce995eb10b83c02b68d007247f15068f8fc2998e69cef6cc3c84df"
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "openldap"
depends_on "openssl@1.1"
depends_on "pcre2"
uses_from_macos "libxcrypt"
# default max. file descriptors; this option will be ignored if the server is not started as root
MAX_FDS = 512
def install
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--sbindir=#{bin}
--with-bzip2
--with-ldap
--with-openssl
--without-pcre
--with-pcre2
--with-zlib
]
# autogen must be run, otherwise prebuilt configure may complain
# about a version mismatch between included automake and Homebrew's
system "./autogen.sh"
system "./configure", *args
system "make", "install"
unless File.exist? etc/"lighttpd"
(etc/"lighttpd").install "doc/config/lighttpd.conf", "doc/config/modules.conf"
(etc/"lighttpd/conf.d/").install Dir["doc/config/conf.d/*.conf"]
inreplace etc + "lighttpd/lighttpd.conf" do |s|
s.sub!(/^var\.log_root\s*=\s*".+"$/, "var.log_root = \"#{var}/log/lighttpd\"")
s.sub!(/^var\.server_root\s*=\s*".+"$/, "var.server_root = \"#{var}/www\"")
s.sub!(/^var\.state_dir\s*=\s*".+"$/, "var.state_dir = \"#{var}/lighttpd\"")
s.sub!(/^var\.home_dir\s*=\s*".+"$/, "var.home_dir = \"#{var}/lighttpd\"")
s.sub!(/^var\.conf_dir\s*=\s*".+"$/, "var.conf_dir = \"#{etc}/lighttpd\"")
s.sub!(/^server\.port\s*=\s*80$/, "server.port = 8080")
s.sub!(%r{^server\.document-root\s*=\s*server_root \+ "/htdocs"$}, "server.document-root = server_root")
# get rid of "warning: please use server.use-ipv6 only for hostnames, not
# without server.bind / empty address; your config will break if the kernel
# default for IPV6_V6ONLY changes"
s.sub!(/^server.use-ipv6\s*=\s*"enable"$/, 'server.use-ipv6 = "disable"')
s.sub!(/^server\.username\s*=\s*".+"$/, 'server.username = "_www"')
s.sub!(/^server\.groupname\s*=\s*".+"$/, 'server.groupname = "_www"')
s.sub!(/^#server\.network-backend\s*=\s*"sendfile"$/, 'server.network-backend = "writev"')
# "max-connections == max-fds/2",
# https://redmine.lighttpd.net/projects/1/wiki/Server_max-connectionsDetails
s.sub!(/^#server\.max-connections = .+$/, "server.max-connections = " + (MAX_FDS / 2).to_s)
end
end
(var/"log/lighttpd").mkpath
(var/"www/htdocs").mkpath
(var/"lighttpd").mkpath
end
def caveats
<<~EOS
Docroot is: #{var}/www
The default port has been set in #{etc}/lighttpd/lighttpd.conf to 8080 so that
lighttpd can run without sudo.
EOS
end
service do
run [opt_bin/"lighttpd", "-D", "-f", etc/"lighttpd/lighttpd.conf"]
keep_alive false
error_log_path var/"log/lighttpd/output.log"
log_path var/"log/lighttpd/output.log"
working_dir HOMEBREW_PREFIX
end
test do
system "#{bin}/lighttpd", "-t", "-f", etc/"lighttpd/lighttpd.conf"
end
end