Nov 4, 2011

Installing old formula on Homebrew(Homebrewで古いFormulaをインスール)

Since sbt is very diffrernt between 0.7.7 to 1.x, I needed to install old sbt(0.7.7), but it was not obvious how.
However, it turns out to be very easy.
To do that, simply put file sbt77.rb to /usr/local/Library/Formula as following content.

require 'formula'
class Sbt77 < Formula
  JAR = 'sbt-launch-0.7.7.jar'
  url "http://simple-build-tool.googlecode.com/files/#{JAR}"
  homepage 'http://code.google.com/p/simple-build-tool/'
  md5 '0cce0d5ade30a41b91e05705a9346b71'

  def install
    (bin+'sbt77').write <<-EOS.undent
      #!/bin/sh
      if test -f ~/.sbtconfig; then
        . ~/.sbtconfig
      fi
      exec java -Xmx512M ${SBT_OPTS} -jar #{libexec}/#{JAR} "$@"
    EOS

    libexec.install Dir['*']
  end

  def caveats
    <<-EOS.undent
      You can use $SBT_OPTS to pass additional JVM options to SBT.
      For convenience, this can specified in `~/.sbtconfig`.

      For example:
          SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
    EOS
  end
end

and then do
brew install sbt77

If you don't have to use newest sbt, it's also seems to be possible to download old formula from here. (Old files can be downloaded from "history" of each file.) and replace it with the latest. (I just changed names of the formula downloaded).

I'm sure I can do same with other formulas.

No comments: