Adding a variant to an existing homebrew formula

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I d like to modify the dtc formula to build a specialized version of dtc used with the Beaglebone Black (and other device-tree ARM boards). The problem is multi-fold. The dtc formula provides bottled versions, and installed 1.4.0. I want to install a version that comes from newer sources, but not the absolute latest, and applies a patch available elsewhere. I can build this manually on OS X, but I don t know the best way to make it available in homebrew.

I d like to make it a variant. Either an entirely separate formula, or something within the current formula that can be selected with a command-line parameter. But I m not well-versed enough in brew to know how best to do this.

I tried creating new formula called "dtc-dyn" but it doesn t like dashes in the name.

I d also like to make it a bottle, for others convenience, but that seems more complicated.

I tried just modifying the current dtc and removing all the bottle stuff, then modifying the URL, version, and adding system steps. But some of the operations fail (that seem to work when run from the original build script):

def install
    git_sha = "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"

    system "git checkout master -f"
    system "git pull"
    system "git checkout #{git_sha} -b #{git_sha}-build"
    system "git pull --no-edit https://github.com/pantoniou/dtc dt-overlays5"
    system "make clean"
    system "make all"
end

Sadly, this doesn t work:

$ brew install dtc
==> Cloning git://git.kernel.org/pub/scm/utils/dtc/dtc.git
Updating /Library/Caches/Homebrew/dtc--git
==> Checking out branch master
==> git checkout master -f
==> git pull
==> git checkout f6dbc6ca9618391e4f30c415a0a09b7af35f7647 -b f6dbc6ca9618391e4f30c415a0a09b7af35f7647-build
2015-09-21 00:22:37 -0700

git checkout f6dbc6ca9618391e4f30c415a0a09b7af35f7647 -b f6dbc6ca9618391e4f30c415a0a09b7af35f7647-build

fatal: reference is not a tree: f6dbc6ca9618391e4f30c415a0a09b7af35f7647

READ THIS: https://git.io/brew-troubleshooting

https://github.com/beagleboard/bb.org-overlays/blob/master/dtc-overlay.sh https://github.com/beagleboard/bb.org-overlays/blob/master/dtc-overlay.sh

Anyway, what s the best way to approach this? I think some kind of with-option, based on some of the example scripts, but I m not sure how to avoid the bottle business. Thanks!

Second Approach

Okay, after more doc reading and experimenting, I m trying this:

class Dtc < Formula
  desc "Device tree compiler"
  homepage "http://www.devicetree.org/"
  url "https://mirrors.kernel.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg.orig.tar.gz"
  mirror "https://mirrors.ocf.berkeley.edu/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg.orig.tar.gz"
  sha256 "f5f9a1aea478ee6dbcece8907fd4551058fe72fc2c2a7be972e3d0b7eec4fa43"
  version "1.4.0"

  option "with-symbols", "Add symbols/fixup support (-@ option)."

  bottle…

  if build.with? "symbols"
    url "http://git.kernel.org/pub/scm/utils/dtc/dtc.git", :revision => "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"
    system "git", "pull", "--no-edit", "https://github.com/pantoniou/dtc", "dt-overlays5"
  end

  def install
    system "make"
    system "make", "DESTDIR=#{prefix}", "PREFIX=", "install"
    mv lib/"libfdt.dylib.1", lib/"libfdt.1.dylib"
  end
end

Unfortunately, the git pull fails because it does that before cloning the git repo, and it s not in the right directory. I first considered patch do…, but it wasn t clear how to apply the patch via git pull. I tried this:

  if build.with? "symbols"
    url "http://git.kernel.org/pub/scm/utils/dtc/dtc.git", :revision => "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"
    patch do
        system "git", "pull", "--no-edit", "https://github.com/pantoniou/dtc", "dt-overlays5"
    end
  end

But it still tries to do the git pull before cloning the repo and cding to it.

Answers

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/32689567/adding-a-variant-to-an-existing-homebrew-formula

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils