2010-03-12 01:18:34 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Sleepwatcher < Formula
|
2010-03-12 01:18:34 +00:00
|
|
|
homepage 'http://www.bernhard-baehr.de/'
|
2012-02-21 06:04:21 +00:00
|
|
|
url 'http://www.bernhard-baehr.de/sleepwatcher_2.2.tgz'
|
2012-09-03 18:33:56 +00:00
|
|
|
sha1 'd4e4abb0bf0e1b3db9166d1eae38b8701fc28bf8'
|
2010-03-12 01:18:34 +00:00
|
|
|
|
|
|
|
def install
|
|
|
|
# Adjust Makefile to build native binary only
|
|
|
|
inreplace "sources/Makefile" do |s|
|
2010-08-10 15:05:31 +00:00
|
|
|
s.gsub! /^(CFLAGS)_PPC.*$/, "\\1 = #{ENV.cflags} -prebind"
|
2010-03-12 01:18:34 +00:00
|
|
|
s.gsub! /^(CFLAGS_X86)/, "#\\1"
|
|
|
|
s.change_make_var! "BINDIR", "$(PREFIX)/sbin"
|
|
|
|
s.change_make_var! "MANDIR", "$(PREFIX)/share/man"
|
|
|
|
s.gsub! /^(.*?)CFLAGS_PPC(.*?)[.]ppc/, "\\1CFLAGS\\2"
|
|
|
|
s.gsub! /^(.*?CFLAGS_X86.*?[.]x86)/, "#\\1"
|
|
|
|
s.gsub! /^(\t(lipo|rm).*?[.](ppc|x86))/, "#\\1"
|
|
|
|
s.gsub! "-o root -g wheel", ""
|
|
|
|
end
|
|
|
|
|
|
|
|
# Build and install binary
|
2012-02-21 06:04:21 +00:00
|
|
|
cd "sources" do
|
2010-03-12 01:18:34 +00:00
|
|
|
system "mv", "../sleepwatcher.8", "."
|
|
|
|
system "make", "install", "PREFIX=#{prefix}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write the sleep/wakeup scripts
|
|
|
|
(prefix + 'etc/sleepwatcher').install Dir["config/rc.*"]
|
|
|
|
|
|
|
|
# Write the launchd scripts
|
|
|
|
inreplace Dir["config/*.plist"] do |s|
|
|
|
|
s.gsub! "/etc", (etc + 'sleepwatcher')
|
|
|
|
s.gsub! "/usr/local/sbin", (HOMEBREW_PREFIX + 'sbin')
|
|
|
|
end
|
|
|
|
prefix.install Dir["config/*.plist"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
For SleepWatcher to work, you will need to read the following:
|
|
|
|
|
|
|
|
#{prefix}/ReadMe.rtf
|
|
|
|
|
|
|
|
Ignore information about installing the binary and man page,
|
|
|
|
but read information regarding setup of the launchd files which
|
|
|
|
are installed here:
|
|
|
|
|
|
|
|
#{Dir[(prefix + '*.plist')].join("\n ")}
|
|
|
|
|
|
|
|
These are the examples provided by the author.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|