Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 3144ba3878f1d96e1057b3c3e85a75681863d66b @michaelklishin committed Jul 21, 2012
Showing with 312 additions and 0 deletions.
  1. +48 −0 README.md
  2. +4 −0 attributes/ghc.rb
  3. +5 −0 attributes/platform.rb
  4. +3 −0 files/default/cabal.sh
  5. +30 −0 recipes/default.rb
  6. +67 −0 recipes/ghc.rb
  7. +68 −0 recipes/package.rb
  8. +62 −0 recipes/platform.rb
  9. +25 −0 recipes/source.rb
48 README.md
@@ -0,0 +1,48 @@
+# Haskell Platform Chef Cookbook
+
+This is an OpsCode Chef cookbook that provisions GHC 7.4 and Haskell Platform 2012.02
+from source.
+
+All executables are installed under `/usr/local/bin`. Cabal executables path under `~/.cabal/bin`
+is prepended to PATH via a shell script installed under `/etc/profile.d/`.
+
+
+## GHC and Haskell Platform Versions
+
+This cookbook currently provides
+
+ * GHC 7.4 with Platform 2012.02
+ * GHC 7.0 with Platform 2011.02.
+
+but no other combinations, in part due to Platform requirements on the GHC version used to
+compile it.
+
+
+## Supported OSes
+
+Recent Debian or Ubuntu releases (10.04+) should work.
+
+
+## Recipes
+
+ * `haskell::source` provisions the most recent GHC (7.4) and Haskell Platform (2012.02) releases from source.
+ * `haskell::package` provisions older GHC (7.0) and Haskell Platform (2011.02) releases from apt packages.
+
+Main recipe includes `haskell::source`.
+
+
+## Attributes
+
+* `node[:ghc]:version`: GHC version. `"7.4.1"` by default. Keep in mind that Haskell Platform currently stringly checks GHC version to be equal to `7.4.1` and thus fails to build with GHC 7.4.2.
+
+
+## Dependencies
+
+None.
+
+
+## Copyright & License
+
+Michael S. Klishin, 2012.
+
+Released under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html).
4 attributes/ghc.rb
@@ -0,0 +1,4 @@
+default[:ghc] = {
+ :version => "7.4.1",
+ :arch => kernel['machine'] =~ /x86_64/ ? "amd64" : "i386"
+}
5 attributes/platform.rb
@@ -0,0 +1,5 @@
+default[:haskell] = {
+ :platform => {
+ :version => "2012.2.0.0"
+ }
+}
3 files/default/cabal.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+export PATH=$HOME/.cabal/bin:$PATH
30 recipes/default.rb
@@ -0,0 +1,30 @@
+#
+# Cookbook Name:: haskell
+# Recipe:: default
+# Copyright 2012, Travis CI development team
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+cookbook_file "/etc/profile.d/cabal.sh" do
+ owner node.travis_build_environment.user
+ group node.travis_build_environment.group
+ mode 0755
+end
+
+include_recipe "haskell::source"
67 recipes/ghc.rb
@@ -0,0 +1,67 @@
+#
+# Cookbook Name:: haskell
+# Recipe:: ghc
+# Copyright 2012, Travis CI development team
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+%w(libgmp3-dev freeglut3 freeglut3-dev).each do |pkg|
+ package(pkg) do
+ action :install
+ end
+end
+
+link "/usr/lib/libgmp.so.3" do
+ to "/usr/lib/libgmp.so"
+
+ not_if "test -L /usr/lib/libgmp.so.3"
+end
+
+
+require "tmpdir"
+
+td = Dir.tmpdir
+local_tarball = File.join(td, "ghc-#{node.ghc.version}-i386-unknown-linux.tar.bz2")
+
+remote_file(local_tarball) do
+ source "http://www.haskell.org/ghc/dist/#{node.ghc.version}/ghc-#{node.ghc.version}-#{node.ghc.arch}-unknown-linux.tar.bz2"
+
+ not_if "test -f #{local_tarball}"
+end
+
+# 2. Extract it
+# 3. configure, make install
+bash "build and install GHC" do
+ user "root"
+ cwd "/tmp"
+
+ code <<-EOS
+ tar jfx #{local_tarball}
+ cd ghc-#{node.ghc.version}
+
+ ./configure
+ sudo make install
+ cd ../
+ rm -rf ghc-#{node.ghc.version}
+ rm #{local_tarball}
+ EOS
+
+ creates "/usr/local/bin/ghc"
+ not_if "ghc --version | grep #{node.ghc.version}"
+end
68 recipes/package.rb
@@ -0,0 +1,68 @@
+#
+# Cookbook Name:: haskell
+# Recipe:: ppa
+# Copyright 2012, Travis CI development team
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+case node['platform']
+when "ubuntu"
+ if node[:platform_version].to_f < 11.10
+ apt_repository "mbeloborodiy_haskell_platform" do
+ uri "http://ppa.launchpad.net/mbeloborodiy/ppa/ubuntu/"
+ distribution node['lsb']['codename']
+ components ['main']
+
+ key "F6B6FC93"
+ keyserver "keyserver.ubuntu.com"
+
+ action :add
+ end
+ end
+end
+
+script "initialize cabal" do
+ interpreter "bash"
+ user node.travis_build_environment.user
+ cwd node.travis_build_environment.home
+
+ environment Hash['HOME' => node.travis_build_environment.home]
+
+ code <<-SH
+ cabal update
+ cabal install c2hs
+ SH
+
+ # triggered by haskell-platform installation
+ action :nothing
+ # until http://haskell.1045720.n5.nabble.com/Cabal-install-fails-due-to-recent-HUnit-tt5715081.html#none is resolved :( MK.
+ ignore_failure true
+end
+
+package "haskell-platform" do
+ action :install
+
+ notifies :run, resources(:script => "initialize cabal")
+end
+
+cookbook_file "/etc/profile.d/cabal.sh" do
+ owner node.travis_build_environment.user
+ group node.travis_build_environment.group
+ mode 0755
+end
62 recipes/platform.rb
@@ -0,0 +1,62 @@
+#
+# Cookbook Name:: haskell
+# Recipe:: platform
+# Copyright 2012, Travis CI development team
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+include_recipe "haskell::ghc"
+
+require "tmpdir"
+
+td = Dir.tmpdir
+local_tarball = File.join(td, "haskell-platform-#{node.haskell.platform.version}.tar.gz")
+
+remote_file(local_tarball) do
+ source "http://lambda.haskell.org/platform/download/#{node.haskell.platform.version}/haskell-platform-#{node.haskell.platform.version}.tar.gz"
+
+ not_if "test -f #{local_tarball}"
+end
+
+# 2. Extract it
+# 3. configure, make install
+bash "build and install Haskell Platform" do
+ user "root"
+ cwd "/tmp"
+
+ code <<-EOS
+ tar zfx #{local_tarball}
+ cd `tar -tf #{local_tarball} | head -n 1`
+
+ which ghc
+ ghc --version
+
+ ./configure
+ make
+ make install
+ cd ../
+ rm -rf `tar -tf #{local_tarball} | head -n 1`
+ rm #{local_tarball}
+
+ cabal update
+ cabal install hunit c2hs
+ EOS
+
+ creates "/usr/local/bin/cabal"
+end
25 recipes/source.rb
@@ -0,0 +1,25 @@
+#
+# Cookbook Name:: haskell
+# Recipe:: source
+# Copyright 2012, Travis CI development team
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+include_recipe "haskell::ghc"
+include_recipe "haskell::platform"

0 comments on commit 3144ba3

Please sign in to comment.