require "formula" class Mosquitto < Formula desc "Message broker implementing MQ telemetry transport protocol" homepage "http://mosquitto.org/" url "http://mosquitto.org/files/source/mosquitto-1.4.2.tar.gz" sha1 "208ce5f01fcf25fff6b241b22add055ba2884822" bottle do sha256 "5ddaaa8d6a3b1243e56a401352a30c98baac64912d727db4f1d863c91cde49d5" => :yosemite sha256 "ebf06abb4e01eb008cc77ae09ae3ab2d593d4150398ebe5d25e0a08b0c80f4e5" => :mavericks sha256 "120219f9750c23bc66635222c9f79a4434188fbdb046a5a43b8d1d350eb62bde" => :mountain_lion end depends_on "pkg-config" => :build depends_on "cmake" => :build depends_on "c-ares" depends_on "libwebsockets" => :recommended # mosquitto requires OpenSSL >=1.0 for TLS support depends_on "openssl" def install args = std_cmake_args args << "-DWITH_WEBSOCKETS=ON" if build.with? "libwebsockets" system "cmake", ".", *args system "make", "install" # Create the working directory (var/"mosquitto").mkpath end test do quiet_system "#{sbin}/mosquitto", "-h" assert_equal 3, $?.exitstatus end def caveats; <<-EOD.undent mosquitto has been installed with a default configuration file. You can make changes to the configuration by editing: #{etc}/mosquitto/mosquitto.conf EOD end plist_options :manual => "mosquitto -c #{HOMEBREW_PREFIX}/etc/mosquitto/mosquitto.conf" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_sbin}/mosquitto -c #{etc}/mosquitto/mosquitto.conf RunAtLoad KeepAlive WorkingDirectory #{var}/mosquitto EOS end end