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.0/logrotate-3.15.0.tar.xz" sha256 "313612c4776a305393454c874ef590d8acf84c9ffa648717731dfe902284ff8f" bottle do cellar :any sha256 "aa5d14ef7aacf37ef9348987cdb5367122d50c0c64b32f4dd809a66a194c2e60" => :mojave sha256 "d0c9c3ad9fe45fe8bda6dfc25cbf5e4b56d0c3489f578cdd09c65dfdd992d856" => :high_sierra sha256 "58b6fbae1676aa8fe9342b799eef31499ae1f111e7989c304465fda16ee650d0" => :sierra end depends_on "popt" # https://github.com/logrotate/logrotate/issues/241 "macOS timer functions" # Should be safe to remove on > 3.15.0 release patch do url "https://github.com/logrotate/logrotate/commit/0d805ce.patch?full_index=1" sha256 "a374fb6354c517da9a229373241db4802c549c05d7822462b905f0262a316be0" end 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 Label #{plist_name} ProgramArguments #{sbin}/logrotate #{etc}/logrotate.conf RunAtLoad StartCalendarInterval Hour 6 Minute 25 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