diff options
| author | Gaëtan Lehmann | 2014-03-28 01:59:50 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-05-07 08:06:14 +0100 |
| commit | 8539ec407f1f66922853298d1c48092f42f869f0 (patch) | |
| tree | ad7d07f0e151f29537fe1c006b08c60515e6fca0 /Library | |
| parent | 9414af689010548a8fff8d068eeea4707f2ce229 (diff) | |
| download | homebrew-8539ec407f1f66922853298d1c48092f42f869f0.tar.bz2 | |
git-annex: 5.20140421
installing git-annex with cabal-install is quite long and requires to install
some heavy packages. It also has several external lib dependencies and needs a
few configuration flags to build so it is quite difficult to install too.
This formula should make it easy and quick to install with a bottle.
The huge number of haskell dependencies is built within the formula and statically
linked to git-annex. The haskell libraries built are discarded - cabal-install
should be used instead of this package in order to keep them.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/git-annex.rb | 53 | ||||
| -rw-r--r-- | Library/Homebrew/language/haskell.rb | 68 |
2 files changed, 121 insertions, 0 deletions
diff --git a/Library/Formula/git-annex.rb b/Library/Formula/git-annex.rb new file mode 100644 index 000000000..c6bdb4314 --- /dev/null +++ b/Library/Formula/git-annex.rb @@ -0,0 +1,53 @@ +require "formula" +require "language/haskell" + +class GitAnnex < Formula + include Language::Haskell::Cabal + + homepage "https://git-annex.branchable.com/" + url "http://hackage.haskell.org/package/git-annex-5.20140421/git-annex-5.20140421.tar.gz" + sha1 "f818164eaddf2887a15c0c4c745a1cb8174152dc" + + depends_on "gcc" => :build + depends_on "ghc" => :build + depends_on "cabal-install" => :build + depends_on "pkg-config" => :build + depends_on "gsasl" + depends_on "libidn" + depends_on "gnutls" + depends_on "gmp" + + def install + cabal_sandbox do + cabal_install_tools "alex", "happy", "c2hs" + # gcc required to build gnuidn + cabal_install "--with-gcc=#{Formula["gcc"].bin}/gcc-4.8", "--only-dependencies" + cabal_install "--prefix=#{prefix}" + end + system "make", "git-annex.1", "git-annex-shell.1" + man1.install "git-annex.1", "git-annex-shell.1" + end + + test do + # make sure git can find git-annex + ENV.prepend_path 'PATH', bin + # create a first git repository with an annex + mkdir "my_annex" do + system "git", "init" + system "git", "annex", "init", "my_annex" + cp bin/"git-annex", "bigfile" + system "git", "annex", "add", "bigfile" + system "git", "commit", "-am", "big file added" + assert File.symlink? "bigfile" + end + # and propagate its content to another + system "git", "clone", "my_annex", "my_annex_clone" + Dir.chdir "my_annex_clone" do + assert (not File.file? "bigfile") + system "git", "annex", "get", "bigfile" + assert File.file? "bigfile" + end + # make test files writable so homebrew can drop them + chmod_R 0777, testpath + end +end diff --git a/Library/Homebrew/language/haskell.rb b/Library/Homebrew/language/haskell.rb new file mode 100644 index 000000000..c4d964682 --- /dev/null +++ b/Library/Homebrew/language/haskell.rb @@ -0,0 +1,68 @@ +module Language + module Haskell + # module for formulas using cabal-install as build tool + module Cabal + def cabal_sandbox + pwd = Pathname.pwd + # force cabal to put its stuff here instead of the home directory by + # pretending the home is here. This also avoid to deal with many options + # to configure cabal. Note this is also useful with cabal sandbox to + # avoid touching ~/.cabal + home = ENV["HOME"] + ENV["HOME"] = pwd + # use cabal's sandbox feature if available + cabal_version = `cabal --version`[/[0-9.]+/].split('.').collect(&:to_i) + if (cabal_version <=> [1, 20]) > -1 + system "cabal", "sandbox", "init" + cabal_sandbox_bin = pwd/".cabal-sandbox/bin" + else + # no or broken sandbox feature - just use the HOME trick + cabal_sandbox_bin = pwd/".cabal/bin" + end + # cabal may build useful tools that should be found in the PATH + mkdir_p cabal_sandbox_bin + path = ENV["PATH"] + ENV.prepend_path 'PATH', cabal_sandbox_bin + # update cabal package database + system "cabal", "update" + yield + # restore the environment + if (cabal_version <=> [1, 20]) > -1 + system "cabal", "sandbox", "delete" + end + ENV["HOME"] = home + ENV["PATH"] = path + end + + def cabal_install(*opts) + system "cabal", "install", "--jobs=#{ENV.make_jobs}", *opts + end + + # install the tools passed in parameter and remove the packages that where + # used so they won't be in the way of the dependency solver for the main + # package. The tools are installed sequentially in order to make possible + # to install several tools that depends on each other + def cabal_install_tools(*opts) + opts.each {|t| cabal_install t} + rm_rf Dir[".cabal*/*packages.conf.d/"] + end + + # remove the development files from the lib directory. cabal-install should + # be used instead to install haskell packages + def cabal_clean_lib + # a better approach may be needed here + rm_rf lib + end + + def install_cabal_package + cabal_sandbox do + # the dependencies are built first and installed locally, and only the + # current package is actually installed in the destination dir + cabal_install "--only-dependencies" + cabal_install "--prefix=#{prefix}" + end + cabal_clean_lib + end + end + end +end |
