Permalink
Switch branches/tags
production_RELEASE_RELEASE_CANDIDATE_STABLE_34 production_RELEASE_RELEASE_CANDIDATE_STABLE_32 production_RELEASE_RELEASE_CANDIDATE_STABLE_31 production_RELEASE_RELEASE_CANDIDATE_STABLE_30 production_RELEASE_RELEASE_CANDIDATE_STABLE_28 production_RELEASE_RELEASE_CANDIDATE_STABLE_27 production_RELEASE_RELEASE_CANDIDATE_STABLE_26 production_RELEASE_RELEASE_CANDIDATE_STABLE_25 production_RELEASE_RELEASE_CANDIDATE_STABLE_24 production_RELEASE_RELEASE_CANDIDATE_STABLE_23 production_RELEASE_RELEASE_CANDIDATE_STABLE_22 production_RELEASE_RELEASE_CANDIDATE_STABLE_21 production_RELEASE_RELEASE_CANDIDATE_STABLE_20 production_RELEASE_RELEASE_CANDIDATE_STABLE_19 production_RELEASE_RELEASE_CANDIDATE_STABLE_18 production_RELEASE_RELEASE_CANDIDATE_STABLE_17 production_RELEASE_RELEASE_CANDIDATE_STABLE_16 production_RELEASE_RELEASE_CANDIDATE_STABLE_15 production_RELEASE_RELEASE_CANDIDATE_STABLE_14 production_RELEASE_RELEASE_CANDIDATE_STABLE_13 production_RELEASE_RELEASE_CANDIDATE_STABLE_12 production_RELEASE_RELEASE_CANDIDATE_STABLE_11 production_RELEASE_RELEASE_CANDIDATE_STABLE_10 production_RELEASE_RELEASE_CANDIDATE_STABLE_8 production_RELEASE_RELEASE_CANDIDATE_STABLE_6 production_RELEASE_RELEASE_CANDIDATE_STABLE_5 production_RELEASE_RELEASE_CANDIDATE_STABLE_2 production_RELEASE_RELEASE_CANDIDATE_BETA_1 production_RELEASE_DEV_597 production_RELEASE_DEV_596 production_RELEASE_DEV_595 production_RELEASE_DEV_594 production_RELEASE_DEV_593 production_RELEASE_DEV_592 production_RELEASE_DEV_591 production_RELEASE_DEV_590 production_RELEASE_DEV_589 production_RELEASE_DEV_588 production_RELEASE_DEV_587 production_RELEASE_DEV_586 production_RELEASE_DEV_585 production_RELEASE_DEV_584 production_RELEASE_DEV_583 production_RELEASE_DEV_582 production_RELEASE_DEV_581 production_RELEASE_DEV_580 production_RELEASE_DEV_579 production_RELEASE_DEV_578 production_RELEASE_DEV_577 production_RELEASE_DEV_576 production_RELEASE_DEV_575 production_RELEASE_DEV_574 production_RELEASE_DEV_573 production_RELEASE_DEV_572 production_RELEASE_DEV_571 production_RELEASE_DEV_570 production_RELEASE_DEV_569 production_RELEASE_DEV_568 production_RELEASE_DEV_567 production_RELEASE_DEV_566 production_RELEASE_DEV_565 production_RELEASE_DEV_564 production_RELEASE_DEV_563 production_RELEASE_DEV_562 production_RELEASE_DEV_561 production_RELEASE_DEV_560 production_RELEASE_DEV_559 production_RELEASE_DEV_558 production_RELEASE_DEV_557 production_RELEASE_DEV_556 production_RELEASE_DEV_555 production_RELEASE_DEV_554 production_RELEASE_DEV_553 production_RELEASE_DEV_552 production_RELEASE_DEV_551 production_RELEASE_DEV_550 production_RELEASE_DEV_549 production_RELEASE_DEV_548 production_RELEASE_DEV_547 production_RELEASE_DEV_546 production_RELEASE_DEV_545 production_RELEASE_DEV_544 production_RELEASE_DEV_543 production_RELEASE_DEV_542 production_RELEASE_DEV_541 production_RELEASE_DEV_540 production_RELEASE_DEV_539 production_RELEASE_DEV_538 production_RELEASE_DEV_537 production_RELEASE_DEV_536 production_RELEASE_DEV_535 production_RELEASE_DEV_534 production_RELEASE_DEV_533 production_RELEASE_DEV_532 production_RELEASE_DEV_531 production_RELEASE_DEV_530 production_RELEASE_DEV_529 production_RELEASE_DEV_528 production_RELEASE_DEV_527 production_RELEASE_DEV_526
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (74 sloc) 2.41 KB
meta :homebrew_mirror do
def urls
script = %Q{
#!/usr/bin/env ruby
prefix = `brew --prefix`.chomp
$LOAD_PATH << File.join(prefix, 'Library', 'Homebrew')
require 'extend/ARGV'
require 'global'
ARGV.extend HomebrewArgvExtension
require 'formula'
before = Class.constants
Dir[File.join(prefix, 'Library/Formula/*')].each {|f| load f }
classes_to_skip = %w[AspellLang COREUTILS_ALIASES DICT_CONF Rational SOLR_START_SCRIPT]
urls = (Class.constants - before - classes_to_skip).reject {|k|
k =~ /DownloadStrategy$/
}.map {|k|
eval(k.to_s)
}.select {|k|
k.respond_to? :url
}.map {|k|
k.url
}
puts urls * "\n"
}
shell("ruby", :input => script).split("\n").select {|url| url[/^(https?|ftp):/] }.uniq
end
end
dep 'mirrored.homebrew_mirror' do
define_var :homebrew_downloads, :default => '/srv/http/files'
define_var :homebrew_vhost_root, :default => '/srv/http/homebrew'
def missing_urls
urls.tap {|urls| log "#{urls.length} URLs in the homebrew database." }.reject {|url|
path = var(:homebrew_downloads) / File.basename(url)
path.exists? && !path.empty?
}.tap {|urls| log "Of those, #{urls.length} aren't present locally." }
end
met? { missing_urls.empty? }
meet {
cd var(:homebrew_downloads) do
missing_urls.each {|url|
begin
Babushka::Resource.download url
rescue StandardError => ex
log_error ex.inspect
end
}
end
}
end
dep 'linked.homebrew_mirror' do
requires 'mirrored.homebrew_mirror'
def unlinked_urls
urls.tap {|urls| log "#{urls.length} URLs in the homebrew download pool." }.select {|url|
path = var(:homebrew_downloads) / File.basename(url)
link = var(:homebrew_vhost_root) / url.sub(/^[a-z]+:\/\/[^\/]+\//, '')
path.exists? && !(link.exists? && link.readlink)
}.tap {|urls| log "Of those, #{urls.length} aren't symlinked into the vhost." }
end
met? { unlinked_urls.empty? }
meet {
unlinked_urls.each {|url|
shell "mkdir -p '#{var(:homebrew_vhost_root) / File.dirname(url.sub(/^[a-z]+:\/\/[^\/]+\//, ''))}'"
log_shell "Linking #{url}", "ln -sf '#{var(:homebrew_downloads) / File.basename(url)}' '#{var(:homebrew_vhost_root) / url.sub(/^[a-z]+:\/\/[^\/]+\//, '')}'"
}
}
after {
log urls.map {|url|
url.scan(/^[a-z]+:\/\/([^\/]+)\//).flatten.first
}.uniq.reject {|url|
url[/[:]/]
}.join(' ')
log "Those are the domains you should alias the host to."
}
end