92 lines
2.8 KiB
Ruby
92 lines
2.8 KiB
Ruby
class Yaws < Formula
|
|
desc "Webserver for dynamic content (written in Erlang)"
|
|
homepage "http://yaws.hyber.org"
|
|
url "https://github.com/erlyaws/yaws/archive/yaws-2.0.8.tar.gz"
|
|
sha256 "0776bc4f9d50cf6a2bff277c0bc8ddb06218d54c53a9335e872f230565da0620"
|
|
license "BSD-3-Clause"
|
|
head "https://github.com/erlyaws/yaws.git"
|
|
|
|
livecheck do
|
|
url "https://github.com/erlyaws/yaws/releases/latest"
|
|
regex(%r{href=.*?/tag/yaws[._-]v?(\d+(?:\.\d+)+)["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "3335822fd2d1607a87add7fd8e66e301ee3d871cac31f9bc2b60aea0ae390529" => :big_sur
|
|
sha256 "8f37611285571c333ea08c520a65644f984bc7ccbe81c78b5d6596853a7efeeb" => :catalina
|
|
sha256 "a8af172fe0c1677ff0baa5aa06160ce15f8d69b8e31f7e5d36bc39ed9c11b1ec" => :mojave
|
|
sha256 "e2871412886f0d452a576b25cbedecd415824edd19b479d90a068599de866e09" => :high_sierra
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "erlang"
|
|
|
|
# the default config expects these folders to exist
|
|
skip_clean "var/log/yaws"
|
|
skip_clean "lib/yaws/examples/ebin"
|
|
skip_clean "lib/yaws/examples/include"
|
|
|
|
def install
|
|
system "autoreconf", "-fvi"
|
|
system "./configure", "--prefix=#{prefix}",
|
|
# Ensure pam headers are found on Xcode-only installs
|
|
"--with-extrainclude=#{MacOS.sdk_path}/usr/include/security",
|
|
"SED=/usr/bin/sed"
|
|
system "make", "install", "WARNINGS_AS_ERRORS="
|
|
|
|
cd "applications/yapp" do
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
|
|
# the default config expects these folders to exist
|
|
(lib/"yaws/examples/ebin").mkpath
|
|
(lib/"yaws/examples/include").mkpath
|
|
end
|
|
|
|
def post_install
|
|
(var/"log/yaws").mkpath
|
|
(var/"yaws/www").mkpath
|
|
end
|
|
|
|
test do
|
|
user = "user"
|
|
password = "password"
|
|
port = free_port
|
|
|
|
(testpath/"www/example.txt").write <<~EOS
|
|
Hello World!
|
|
EOS
|
|
|
|
(testpath/"yaws.conf").write <<~EOS
|
|
logdir = #{mkdir(testpath/"log").first}
|
|
ebin_dir = #{mkdir(testpath/"ebin").first}
|
|
include_dir = #{mkdir(testpath/"include").first}
|
|
|
|
<server localhost>
|
|
port = #{port}
|
|
listen = 127.0.0.1
|
|
docroot = #{testpath}/www
|
|
<auth>
|
|
realm = foobar
|
|
dir = /
|
|
user = #{user}:#{password}
|
|
</auth>
|
|
</server>
|
|
EOS
|
|
fork do
|
|
exec bin/"yaws", "-c", testpath/"yaws.conf", "--erlarg", "-noshell"
|
|
end
|
|
sleep 3
|
|
|
|
output = shell_output("curl --silent localhost:#{port}/example.txt")
|
|
assert_match "401 authentication needed", output
|
|
|
|
output = shell_output("curl --user #{user}:#{password} --silent localhost:#{port}/example.txt")
|
|
assert_equal "Hello World!\n", output
|
|
end
|
|
end
|