123 lines
4.6 KiB
Ruby
123 lines
4.6 KiB
Ruby
require "language/node"
|
||
|
||
class Lanraragi < Formula
|
||
desc "Web application for archival and reading of manga/doujinshi"
|
||
homepage "https://github.com/Difegue/LANraragi"
|
||
url "https://github.com/Difegue/LANraragi/archive/v.0.8.5.tar.gz"
|
||
sha256 "2cf53f7405a6a4e16e6d61a1109bdd87c25471c2ee6cf2fb79129c7f5666fa31"
|
||
license "MIT"
|
||
head "https://github.com/Difegue/LANraragi.git", branch: "dev"
|
||
|
||
bottle do
|
||
sha256 cellar: :any, arm64_monterey: "5aa823c1f1838e971751b56f2a3cd42bd815c9513b13d327e432e9017570b970"
|
||
sha256 cellar: :any, arm64_big_sur: "2e1ef247998188562bc78cfef1689cbee1134cd834280fd243a0c1452b1a28aa"
|
||
sha256 cellar: :any, monterey: "aa53aeb1ec9499a301c79f7011e3b228655ebe4c03e19de3f935478da467d969"
|
||
sha256 cellar: :any, big_sur: "879f9384947c8453d3c803edf591f2c61decab4a5d39d4205c3db799d2ce2d23"
|
||
sha256 cellar: :any, catalina: "44bb28ad1890524464db94ca26c07c838bf287c6ba784d6d60ddef7645552b16"
|
||
sha256 cellar: :any_skip_relocation, x86_64_linux: "2a80e239000c32a4f07b7aebc708bca123526653e5e995841eee6de002b4ffd9"
|
||
end
|
||
|
||
depends_on "nettle" => :build
|
||
depends_on "pkg-config" => :build
|
||
depends_on "cpanminus"
|
||
depends_on "ghostscript"
|
||
depends_on "giflib"
|
||
depends_on "imagemagick"
|
||
depends_on "jpeg"
|
||
depends_on "libpng"
|
||
depends_on "node"
|
||
depends_on "openssl@1.1"
|
||
depends_on "perl"
|
||
depends_on "redis"
|
||
depends_on "zstd"
|
||
|
||
uses_from_macos "libarchive"
|
||
|
||
resource "libarchive-headers" do
|
||
on_macos do
|
||
url "https://opensource.apple.com/tarballs/libarchive/libarchive-83.100.2.tar.gz"
|
||
sha256 "e54049be1b1d4f674f33488fdbcf5bb9f9390db5cc17a5b34cbeeb5f752b207a"
|
||
end
|
||
end
|
||
|
||
resource "Image::Magick" do
|
||
url "https://cpan.metacpan.org/authors/id/J/JC/JCRISTY/Image-Magick-7.0.11-3.tar.gz"
|
||
sha256 "232f2312c09a9d9ebc9de6c9c6380b893511ef7c6fc358d457a4afcec26916aa"
|
||
end
|
||
|
||
def install
|
||
ENV.prepend_create_path "PERL5LIB", "#{libexec}/lib/perl5"
|
||
ENV.prepend_path "PERL5LIB", "#{libexec}/lib"
|
||
|
||
# On Linux, use the headers provided by the libarchive formula rather than the ones provided by Apple.
|
||
ENV["CFLAGS"] = if OS.mac?
|
||
"-I#{libexec}/include"
|
||
else
|
||
"-I#{Formula["libarchive"].opt_include}"
|
||
end
|
||
|
||
ENV["OPENSSL_PREFIX"] = Formula["openssl@1.1"].opt_prefix
|
||
|
||
imagemagick = Formula["imagemagick"]
|
||
resource("Image::Magick").stage do
|
||
inreplace "Makefile.PL" do |s|
|
||
s.gsub! "/usr/local/include/ImageMagick-#{imagemagick.version.major}",
|
||
"#{imagemagick.opt_include}/ImageMagick-#{imagemagick.version.major}"
|
||
end
|
||
|
||
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
|
||
system "make"
|
||
system "make", "install"
|
||
end
|
||
|
||
if OS.mac?
|
||
resource("libarchive-headers").stage do
|
||
cd "libarchive/libarchive" do
|
||
(libexec/"include").install "archive.h", "archive_entry.h"
|
||
end
|
||
end
|
||
end
|
||
|
||
system "cpanm", "Config::AutoConf", "--notest", "-l", libexec
|
||
system "npm", "install", *Language::Node.local_npm_install_args
|
||
system "perl", "./tools/install.pl", "install-full"
|
||
|
||
prefix.install "README.md"
|
||
(libexec/"lib").install Dir["lib/*"]
|
||
libexec.install "script", "package.json", "public", "templates", "tests", "lrr.conf"
|
||
cd "tools/build/homebrew" do
|
||
bin.install "lanraragi"
|
||
libexec.install "redis.conf"
|
||
end
|
||
end
|
||
|
||
def caveats
|
||
<<~EOS
|
||
Automatic thumbnail generation will not work properly on macOS < 10.15 due to the bundled Libarchive being too old.
|
||
Opening archives for reading will generate thumbnails normally.
|
||
EOS
|
||
end
|
||
|
||
test do
|
||
# Make sure lanraragi writes files to a path allowed by the sandbox
|
||
ENV["LRR_LOG_DIRECTORY"] = ENV["LRR_TEMP_DIRECTORY"] = testpath
|
||
%w[server.pid shinobu.pid minion.pid].each { |file| touch file }
|
||
|
||
# Set PERL5LIB as we're not calling the launcher script
|
||
ENV["PERL5LIB"] = libexec/"lib/perl5"
|
||
|
||
# This can't have its _user-facing_ functionality tested in the `brew test`
|
||
# environment because it needs Redis. It fails spectacularly tho with some
|
||
# table flip emoji. So let's use those to confirm _some_ functionality.
|
||
output = <<~EOS
|
||
キタ━━━━━━(゚∀゚)━━━━━━!!!!!
|
||
(╯・_>・)╯︵ ┻━┻
|
||
It appears your Redis database is currently not running.
|
||
The program will cease functioning now.
|
||
EOS
|
||
# Execute through npm to avoid starting a redis-server
|
||
return_value = OS.mac? ? 61 : 111
|
||
assert_match output, shell_output("npm start --prefix #{libexec}", return_value)
|
||
end
|
||
end
|