Skip to content

Instantly share code, notes, and snippets.

@jbclements
Created April 6, 2012 05:37
Show Gist options
  • Save jbclements/2317297 to your computer and use it in GitHub Desktop.
Save jbclements/2317297 to your computer and use it in GitHub Desktop.
Excerpt from homebrew's formula_installer.rb
def link
if f.linked_keg.directory? and f.linked_keg.realpath == f.prefix
opoo "This keg was marked linked already, continuing anyway"
# otherwise Keg.link will bail
f.linked_keg.unlink
end
keg = Keg.new(f.prefix)
keg.link
rescue Exception => e
onoe "The linking step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts "You can try again using `brew link #{f.name}'"
keg.unlink
ohai e, e.backtrace if ARGV.debug?
@show_summary_heading = true
end
def fix_install_names
Keg.new(f.prefix).fix_install_names
rescue Exception => e
onoe "Failed to fix install names"
puts "The formula built, but you may encounter issues using it or linking other"
puts "formula against it."
ohai e, e.backtrace if ARGV.debug?
@show_summary_heading = true
end
def clean
require 'cleaner'
Cleaner.new f
rescue Exception => e
opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix"
ohai e, e.backtrace if ARGV.debug?
@show_summary_heading = true
end
def pour
fetched, downloader = f.fetch
f.verify_download_integrity fetched, f.bottle_sha1, "SHA1"
HOMEBREW_CELLAR.cd do
downloader.stage
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment