How do I have different scripts for --head and regular installs?


#1

When my formula is installed using --head, I want to run a build script, but otherwise I want to download a file and use that as the executable.

Are there any examples of formulas doing this?

My binary script:

def install
  libexec.install "buckaroo-cli.jar"
  bin.write_jar_script libexec/"buckaroo-cli.jar", "buckaroo"
end

My build-from-source script:

def install
  system "buck", "build", ":buckaroo-cli"
  libexec.install Dir["buck-out/gen/*"]
  bin.write_jar_script "#{libexec}/buckaroo-cli.jar", "buckaroo"
end

#2

I think I figured it out:

def install
  if head? then
    system "buck", "build", ":buckaroo-cli"
    libexec.install Dir["buck-out/gen/*"]
    bin.write_jar_script "#{libexec}/buckaroo-cli.jar", "buckaroo"
  else
    libexec.install "buckaroo-cli.jar"
    bin.write_jar_script libexec/"buckaroo-cli.jar", "buckaroo"
  end
end

Is this the best way?


(Joshua McKinney) #3

Most places I’ve seen check build.head? not head? not sure the difference.
https://github.com/Homebrew/homebrew-core/search?utf8=✓&q=head&type=