Make generic caveats for launchd plist files.
This commit is contained in:
parent
c3313d084c
commit
faf51f254d
@ -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
|
||||
|
||||
@ -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,13 +326,12 @@ class FormulaInstaller
|
||||
end
|
||||
|
||||
def install_plist
|
||||
if f.startup_plist
|
||||
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.startup_plist
|
||||
f.plist_path.write f.plist
|
||||
f.plist_path.chmod 0644
|
||||
end
|
||||
end
|
||||
|
||||
def fix_install_names
|
||||
Keg.new(f.prefix).fix_install_names
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user