aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2012-11-25 15:06:41 +0000
committerMike McQuaid2012-11-25 23:05:52 +0000
commitfaf51f254d912e5e0c39a1f4fa5a696bd67c56c4 (patch)
treece38bd946efe54188d3997d4c80afd61507abfd0 /Library
parentc3313d084ca6c93207973d005f3ca01a14d556e7 (diff)
downloadbrew-faf51f254d912e5e0c39a1f4fa5a696bd67c56c4.tar.bz2
Make generic caveats for launchd plist files.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb11
-rw-r--r--Library/Homebrew/formula_installer.rb51
-rw-r--r--Library/Homebrew/keg.rb6
3 files changed, 60 insertions, 8 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index b09dfb1c3..3f5f83ced 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -139,10 +139,13 @@ class Formula
def var; HOMEBREW_PREFIX+'var' end
# override this to provide a plist
- def startup_plist; nil; end
+ def plist; nil; end
+ alias :startup_plist :plist
# plist name, i.e. the name of the launchd service
def plist_name; 'homebrew.mxcl.'+name end
def plist_path; prefix+(plist_name+'.plist') end
+ def plist_manual; self.class.plist_manual end
+ def plist_startup; self.class.plist_startup end
def build
self.class.build
@@ -633,6 +636,7 @@ private
end
attr_rw :homepage, :keg_only_reason, :skip_clean_all, :cc_failures
+ attr_rw :plist_startup, :plist_manual
Checksum::TYPES.each do |cksum|
class_eval %Q{
@@ -717,6 +721,11 @@ private
build.add name, description
end
+ def plist_options options
+ @plist_startup = options[:startup]
+ @plist_manual = options[:manual]
+ end
+
def conflicts_with formula, opts={}
dependencies.add ConflictRequirement.new(formula, name, opts)
end
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 06c12ced6..4d25ead56 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -160,7 +160,6 @@ class FormulaInstaller
end
keg = Keg.new(f.prefix)
-
if keg.completion_installed? :bash
ohai 'Caveats', <<-EOS.undent
Bash completion has been installed to:
@@ -174,6 +173,45 @@ class FormulaInstaller
#{HOMEBREW_PREFIX}/share/zsh/site-functions
EOS
end
+
+ if f.plist or keg.plist_installed?
+ if f.plist_startup and false
+ destination = '/Library/LaunchDaemons'
+ else
+ destination = '~/Library/LaunchAgents'
+ end
+
+ plist_filename = f.plist_path.basename
+ plist_link = "#{destination}/#{plist_filename}"
+ plist_domain = f.plist_path.basename('.plist')
+ launchctl_load = "launchctl load -w #{plist_link}"
+ destination_path = Pathname.new File.expand_path destination
+ plist_path = destination_path/plist_filename
+ s = []
+
+ # we readlink because this path probably doesn't exist since caveats
+ # occurs before the link step of installation
+ if not (plist_path).file? and not (plist_path).symlink?
+ s << "To have launchd start #{f.name} at login:"
+ s << " mkdir -p #{destination}" unless destination_path.directory?
+ s << " ln -sfv #{HOMEBREW_PREFIX}/opt/#{f.name}/*.plist #{destination}" #sudo
+ s << "Then to load #{f.name} now:"
+ s << " #{launchctl_load}"
+ if f.plist_manual
+ s << "Or, if you don't want/need launchctl, you can just run:"
+ s << " #{f.plist_manual}"
+ end
+ elsif Kernel.system "/bin/launchctl list #{plist_domain} &>/dev/null"
+ s << "You should reload #{f.name}:"
+ s << " launchctl unload -w #{plist_link}"
+ s << " #{launchctl_load}"
+ else
+ s << "To load #{f.name}:"
+ s << " #{launchctl_load}"
+ end
+
+ ohai 'Caveats', s
+ end
end
def finish
@@ -288,12 +326,11 @@ class FormulaInstaller
end
def install_plist
- if f.startup_plist
- # A plist may already exist if we are installing from a bottle
- f.plist_path.unlink if f.plist_path.exist?
- f.plist_path.write f.startup_plist
- f.plist_path.chmod 0644
- end
+ return unless f.plist
+ # A plist may already exist if we are installing from a bottle
+ f.plist_path.unlink if f.plist_path.exist?
+ f.plist_path.write f.plist
+ f.plist_path.chmod 0644
end
def fix_install_names
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index d968a2fc4..0560b6f26 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -76,6 +76,12 @@ class Keg < Pathname
dir.directory? and not dir.children.length.zero?
end
+ def plist_installed?
+ Dir.chdir self do
+ not Dir.glob("*.plist").empty?
+ end
+ end
+
def version
require 'version'
Version.new(basename.to_s)