93 lines
3.0 KiB
Ruby
93 lines
3.0 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 :stable
|
|
strategy :github_latest
|
|
regex(%r{href=.*?/tag/yaws[._-]v?(\d+(?:\.\d+)+)["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "c2662269d0c221c95b3d3b02fdac694c7f2bb280a9126f03b13577fffb13faa2"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "3335822fd2d1607a87add7fd8e66e301ee3d871cac31f9bc2b60aea0ae390529"
|
|
sha256 cellar: :any_skip_relocation, catalina: "8f37611285571c333ea08c520a65644f984bc7ccbe81c78b5d6596853a7efeeb"
|
|
sha256 cellar: :any_skip_relocation, mojave: "a8af172fe0c1677ff0baa5aa06160ce15f8d69b8e31f7e5d36bc39ed9c11b1ec"
|
|
sha256 cellar: :any_skip_relocation, high_sierra: "e2871412886f0d452a576b25cbedecd415824edd19b479d90a068599de866e09"
|
|
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
|