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
|
def var; HOMEBREW_PREFIX+'var' end
|
||||||
|
|
||||||
# override this to provide a plist
|
# 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
|
# plist name, i.e. the name of the launchd service
|
||||||
def plist_name; 'homebrew.mxcl.'+name end
|
def plist_name; 'homebrew.mxcl.'+name end
|
||||||
def plist_path; prefix+(plist_name+'.plist') 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
|
def build
|
||||||
self.class.build
|
self.class.build
|
||||||
@ -633,6 +636,7 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_rw :homepage, :keg_only_reason, :skip_clean_all, :cc_failures
|
attr_rw :homepage, :keg_only_reason, :skip_clean_all, :cc_failures
|
||||||
|
attr_rw :plist_startup, :plist_manual
|
||||||
|
|
||||||
Checksum::TYPES.each do |cksum|
|
Checksum::TYPES.each do |cksum|
|
||||||
class_eval %Q{
|
class_eval %Q{
|
||||||
@ -717,6 +721,11 @@ private
|
|||||||
build.add name, description
|
build.add name, description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plist_options options
|
||||||
|
@plist_startup = options[:startup]
|
||||||
|
@plist_manual = options[:manual]
|
||||||
|
end
|
||||||
|
|
||||||
def conflicts_with formula, opts={}
|
def conflicts_with formula, opts={}
|
||||||
dependencies.add ConflictRequirement.new(formula, name, opts)
|
dependencies.add ConflictRequirement.new(formula, name, opts)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -160,7 +160,6 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
keg = Keg.new(f.prefix)
|
keg = Keg.new(f.prefix)
|
||||||
|
|
||||||
if keg.completion_installed? :bash
|
if keg.completion_installed? :bash
|
||||||
ohai 'Caveats', <<-EOS.undent
|
ohai 'Caveats', <<-EOS.undent
|
||||||
Bash completion has been installed to:
|
Bash completion has been installed to:
|
||||||
@ -174,6 +173,45 @@ class FormulaInstaller
|
|||||||
#{HOMEBREW_PREFIX}/share/zsh/site-functions
|
#{HOMEBREW_PREFIX}/share/zsh/site-functions
|
||||||
EOS
|
EOS
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def finish
|
def finish
|
||||||
@ -288,12 +326,11 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_plist
|
def install_plist
|
||||||
if f.startup_plist
|
return unless f.plist
|
||||||
# A plist may already exist if we are installing from a bottle
|
# A plist may already exist if we are installing from a bottle
|
||||||
f.plist_path.unlink if f.plist_path.exist?
|
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
|
f.plist_path.chmod 0644
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_install_names
|
def fix_install_names
|
||||||
|
|||||||
@ -76,6 +76,12 @@ class Keg < Pathname
|
|||||||
dir.directory? and not dir.children.length.zero?
|
dir.directory? and not dir.children.length.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def plist_installed?
|
||||||
|
Dir.chdir self do
|
||||||
|
not Dir.glob("*.plist").empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
require 'version'
|
require 'version'
|
||||||
Version.new(basename.to_s)
|
Version.new(basename.to_s)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user