Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created June 18, 2010 20:44
Show Gist options
  • Save mbklein/444203 to your computer and use it in GitHub Desktop.
Save mbklein/444203 to your computer and use it in GitHub Desktop.
require 'formula'
require 'fileutils'
SOLR_START_SCRIPT = <<-end_script
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $ solr path/to/config/dir"
else
cd %s/example && java -Dsolr.solr.home=$1 -jar start.jar
fi
end_script
class Solr <Formula
url 'http://apache.deathculture.net/lucene/solr/1.4.0/apache-solr-1.4.0.tgz'
head 'http://svn.apache.org/repos/asf/lucene/dev/trunk/'
homepage 'http://lucene.apache.org/solr/'
if ARGV.include? "--HEAD"
depends_on 'apache-ant'
else
md5 '1cc3783316aa1f95ba5e250a4c1d0451'
end
def download_strategy
if ARGV.include? "--HEAD"
SubversionDownloadStrategy
else
super()
end
end
def install
prefix.mkpath
old_dir = Dir.pwd
begin
if ARGV.include? "--HEAD"
Dir.chdir('solr')
system('ant dist')
Dir.mkdir('example/webapps') unless File.exists?('example/webapps')
warfile = Dir['dist/apache-solr-*.war'].first
FileUtils.copy(warfile,'example/webapps/solr.war')
end
Dir.mkdir('example/logs') unless File.exists?('example/logs')
system('touch example/logs/solr.log')
prefix.install Dir['*']
ensure
Dir.chdir(old_dir)
end
(bin+'solr').write(SOLR_START_SCRIPT % prefix)
end
def caveats
<<-END_CAVEATS
To start solr:
$ solr path/to/solr/config/dir
See the solr homepage for more setup information:
$ brew home solr
END_CAVEATS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment