homebrew-core/Formula/logrotate.rb
2019-10-12 09:35:10 +02:00

69 lines
2.3 KiB
Ruby

class Logrotate < Formula
desc "Rotates, compresses, and mails system logs"
homepage "https://github.com/logrotate/logrotate"
url "https://github.com/logrotate/logrotate/releases/download/3.15.1/logrotate-3.15.1.tar.xz"
sha256 "491fec9e89f1372f02a0ab66579aa2e9d63cac5178dfa672c204c88e693a908b"
bottle do
cellar :any
sha256 "95f2d314052e8c01a227231483b649186f9c6b1e489c0c14f83864420f8825bb" => :catalina
sha256 "19923834d4fb0303cfda1825d5bdf0916cd7bd6bd094a76036b5d6f2e3a2f0e0" => :mojave
sha256 "d01fb02bceeccb6d21e7db2ccdffc49edd21f61553c1d4e5684eb4e63c8523d1" => :high_sierra
sha256 "bb2de9bc3d629bce8f0e49a145a0cfde09e3f41b8fb59a1cb846641505edb6c6" => :sierra
end
depends_on "popt"
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--with-compress-command=/usr/bin/gzip",
"--with-uncompress-command=/usr/bin/gunzip",
"--with-state-file-path=#{var}/lib/logrotate.status"
system "make", "install"
inreplace "examples/logrotate.conf", "/etc/logrotate.d", "#{etc}/logrotate.d"
etc.install "examples/logrotate.conf" => "logrotate.conf"
(etc/"logrotate.d").mkpath
end
plist_options :manual => "logrotate"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{sbin}/logrotate</string>
<string>#{etc}/logrotate.conf</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>6</integer>
<key>Minute</key>
<integer>25</integer>
</dict>
</dict>
</plist>
EOS
end
test do
(testpath/"test.log").write("testlograndomstring")
(testpath/"testlogrotate.conf").write <<~EOS
#{testpath}/test.log {
size 1
copytruncate
}
EOS
system "#{sbin}/logrotate", "-s", "logstatus", "testlogrotate.conf"
assert(File.size?("test.log").nil?, "File is not zero length!")
end
end