Commits

Brian McKenna committed 28d1750

Initial commit

  • Participants

Comments (0)

Files changed (4)

+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant::Config.run do |config|
+  config.vm.box = "lucid64"
+  config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
+
+  config.vm.customize do |vm|
+    vm.name = "Haskell on Heroku"
+    vm.memory_size = 768
+  end
+
+  config.vm.provision :chef_solo do |chef|
+    chef.cookbooks_path = "cookbooks"
+    chef.add_recipe "haskell-platform"
+    chef.json.merge!({ :ghc_version => '7.0.4',
+                       :haskell_platform_version => '2011.4.0.0'})
+  end
+end

File cookbooks/haskell-platform/attributes/default.rb

+set_unless[:ghc_version] = '7.0.4'
+set_unless[:haskell_platform_version] = '2011.4.0.0'

File cookbooks/haskell-platform/definitions/get_and_build.rb

+define( :get_and_build,
+        :package_url => '!!unspecified',
+        :package_output => '!!unspecified',
+        :working_dir => '!!unspecified',
+        :untar_dir => '!!unspecified',
+        :untar_flags => 'zxvf',
+        :not_if => "" ) do
+
+  log "Downloading package..."
+  execute "download package" do
+    command "wget #{params[:package_url]} -O #{params[:package_output]}"
+    cwd params[:working_dir]
+    action :run
+    not_if params[:not_if]
+  end
+
+  log "Untarring package..."
+  execute "untar package" do
+    command "tar --overwrite -#{params[:untar_flags]} #{params[:package_output]}"
+    cwd params[:working_dir]
+    action :run
+    not_if params[:not_if]
+  end
+
+  log "Build and install..."
+  execute "make and install" do
+    command "./configure; make; make install"
+    cwd (params[:working_dir] + params[:untar_dir])
+    action :run
+    not_if params[:not_if]
+  end
+end

File cookbooks/haskell-platform/recipes/default.rb

+#packages required for haskell platform to build
+package "libgmp3-dev"
+package "zlib1g-dev"
+package "libglc-dev"
+package "libglut3-dev"
+
+#ghc binary package names
+ghc = "ghc-#{node[:ghc_version]}"
+ghc_tar = "#{ghc}.tar.bz"
+
+#platform package names
+platform = "haskell-platform-#{node[:haskell_platform_version]}"
+platform_tar = "#{platform}.tar.gz"
+
+# working directory
+dir = "/tmp/haskell-platform-work/"
+
+log "Create working directory..."
+directory dir do
+  action :create
+  recursive true
+end
+
+
+get_and_build "ghc binary" do
+  package_url "http://www.haskell.org/ghc/dist/#{node[:ghc_version]}/ghc-#{node[:ghc_version]}-x86_64-unknown-linux.tar.bz2
+  package_output ghc_tar
+  working_dir dir
+  untar_dir ghc
+  untar_flags 'jxvf'
+  not_if "ghci --version | grep #{node[:ghc_version]}"
+end
+
+get_and_build "haskell platform" do
+  package_url "http://lambda.haskell.org/platform/download/#{node[:haskell_platform_version]}/#{platform_tar}"
+  package_output platform_tar
+  working_dir dir
+  untar_dir platform
+  # install the haskell platform when we install the binary
+  not_if "cabal --version | grep version"
+end
+
+log "Cleaning up..."
+directory dir do
+  action :delete
+  recursive true
+end