homebrew-core/Formula/minidlna.rb

95 lines
3.3 KiB
Ruby

class Minidlna < Formula
desc "Media server software, compliant with DLNA/UPnP-AV clients"
homepage "https://sourceforge.net/projects/minidlna/"
url "https://downloads.sourceforge.net/project/minidlna/minidlna/1.3.0/minidlna-1.3.0.tar.gz"
sha256 "47d9b06b4c48801a4c1112ec23d24782728b5495e95ec2195bbe5c81bc2d3c63"
license "GPL-2.0-only"
revision 2
bottle do
sha256 cellar: :any, arm64_monterey: "cbe84dc9d2a120e54adfac02535fa45f8ef563f652c5045f4f70ad149d6c038f"
sha256 cellar: :any, arm64_big_sur: "17fbf29b2147f239fb8735d045982503aa02ad5754ae8d594db0dd8c04ea072a"
sha256 cellar: :any, monterey: "932bd20744ba7651d52fe94c30d22ba3e516262ba3a30fabeaf7df4bd8aa38b7"
sha256 cellar: :any, big_sur: "74997619d4be6c977bc2897df4ac94ee73a27bbe691993a44920f919e7812556"
sha256 cellar: :any, catalina: "227628b6e6547aad4698fe39234868a2ad3ef9b72a4bffbb60b8a482de7fe219"
sha256 cellar: :any_skip_relocation, x86_64_linux: "684149c230fa8e599513de4ede63d9eed17dd9d0726a04ac421e8e76a166d22d"
end
head do
url "https://git.code.sf.net/p/minidlna/git.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "gettext" => :build
depends_on "libtool" => :build
end
depends_on "ffmpeg"
depends_on "flac"
depends_on "jpeg"
depends_on "libexif"
depends_on "libid3tag"
depends_on "libogg"
depends_on "libvorbis"
depends_on "sqlite"
fails_with gcc: "5" # ffmpeg is compiled with GCC
def install
system "./autogen.sh" if build.head?
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
def post_install
conf = <<~EOS
friendly_name=Mac DLNA Server
media_dir=#{ENV["HOME"]}/.config/minidlna/media
db_dir=#{ENV["HOME"]}/.config/minidlna/cache
log_dir=#{ENV["HOME"]}/.config/minidlna
EOS
(pkgshare/"minidlna.conf").write conf unless File.exist? pkgshare/"minidlna.conf"
end
def caveats
<<~EOS
Simple single-user configuration:
mkdir -p ~/.config/minidlna
cp #{opt_pkgshare}/minidlna.conf ~/.config/minidlna/minidlna.conf
ln -s YOUR_MEDIA_DIR ~/.config/minidlna/media
minidlnad -f ~/.config/minidlna/minidlna.conf -P ~/.config/minidlna/minidlna.pid
EOS
end
service do
run [opt_sbin/"minidlnad", "-d", "-f", "#{ENV["HOME"]}/.config/minidlna/minidlna.conf",
"-P", "#{ENV["HOME"]}/.config/minidlna/minidlna.pid"]
keep_alive true
log_path var/"log/minidlnad.log"
error_log_path var/"log/minidlnad.log"
end
test do
require "expect"
(testpath/".config/minidlna/media").mkpath
(testpath/".config/minidlna/cache").mkpath
(testpath/"minidlna.conf").write <<~EOS
friendly_name=Mac DLNA Server
media_dir=#{testpath}/.config/minidlna/media
db_dir=#{testpath}/.config/minidlna/cache
log_dir=#{testpath}/.config/minidlna
EOS
port = free_port
io = IO.popen("#{sbin}/minidlnad -d -f minidlna.conf -p #{port} -P #{testpath}/minidlna.pid", "r")
io.expect("debug: Initial file scan completed", 30)
assert_predicate testpath/"minidlna.pid", :exist?
assert_match "MiniDLNA #{version}", shell_output("curl localhost:#{port}")
end
end