Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Auto-generate homebrew formulas #50

Open
dashed opened this issue Jul 5, 2016 · 3 comments
Open

Auto-generate homebrew formulas #50

dashed opened this issue Jul 5, 2016 · 3 comments

Comments

@dashed
Copy link

dashed commented Jul 5, 2016

Unsure if it's out of scope of rust-everywhere.

I'm wondering if it'll be useful if rust-everywhere would be able to generate homebrew formula scripts for osx binaries.

@japaric
Copy link
Contributor

japaric commented Jul 7, 2016

I have no idea of how to write a homebrew formula 😄. Is there any Rust program that has been packaged as a brew formula? That would give me a better idea of how complicated this would be.

@dashed
Copy link
Author

dashed commented Jul 13, 2016

I've been generating formulas manually using a template similar to this:

# hello.rb
#
# homebrew formula: https://github.com/Homebrew/brew
require  'formula'
class Hello < Formula
  _user = 'japaric'
  _repo_name = 'rust-everywhere'
  _bin_name = 'hello'
  homepage "https://github.com/#{_user}/#{_repo_name}"
  _ver = '0.1.0'
  version _ver

  if Hardware.is_64_bit?
    url "https://github.com/#{_user}/#{_repo_name}/releases/download/v#{_ver}/#{_bin_name}-v#{_ver}-x86_64-apple-darwin.tar.gz"
    sha256 '8ac8ef0758385a999787d94d28c0cbb34e4f67c7f3c5d779f3eb76fa48c9df10'
  else
    url "https://github.com/#{_user}/#{_repo_name}/releases/download/v#{_ver}/#{_bin_name}-v#{_ver}-i686-apple-darwin.tar.gz"
    sha256 '13339276e41251b29fcaa46de3a28ac42c0b7964ad5e92eff9a83ea6ee93a32d'
  end

  def install
    bin.install _bin_name
  end
end

Then the user would install as follows:

brew install https://raw.githubusercontent.com/japaric/rust-everywhere/master/hello.rb

It's a matter of pulling the hello.rb file from github, do sed magic to update the sha256 checksums, and then pushing back.

I'll see if I can update the appropriate bash scripts to be able to do this; and if you're interested in this change, I can open a PR.

@japaric
Copy link
Contributor

japaric commented Jul 16, 2016

Oh, I see. This is similar to this install.sh in the sense that it installs an existing GitHub release (tarball). Yeah, I'd be interested in merging the brew formula you posted above (but updated to the latest release) to have it serve as a starting template for people that want to write their own brew formulas. This formula would have to be updated on each release, right? So we should add some instructions about how to do that; this can be done as comments in the formula itself: # generate this checksum using this command: ....

I'll see if I can update the appropriate bash scripts to be able to do this; and if you're interested in this change, I can open a PR.

I'd be great if we had a (bash) script that updates the formula on each release but I would gladly accept a PR with just the formula template + instructions as I mentioned above. The bash script can be added later on as a follow up PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants