Skip to content
Snippets Groups Projects
Commit b7e59f50 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

WIP do a two-stage haskell bootstrap

parent 22b866fb
No related branches found
No related tags found
1 merge request!1WIP Install Haskell
Loading
Loading
@@ -2,12 +2,18 @@
#
# We (try to) install ghc and cabal
 
nproc = node['cpu']['total']
package 'bzip2'
 
case node['platform_family']
when 'debian'
package 'libgmp-dev'
package 'libncurses5-dev'
ghc_flavour = 'deb7'
when 'rhel'
package 'gmp-devel'
package 'ncurses-devel'
case node['platform_version']
when /^6\./
ghc_flavour = 'centos65'
Loading
Loading
@@ -17,42 +23,62 @@ when 'rhel'
end
 
ghc_build_dir = '/var/cache/ghc-7.8.4'
ghc_tarball = "#{ghc_build_dir}.tar.bz2"
ghc_bin_tarball = "#{ghc_build_dir}-bin.tar.bz2"
Chef::Log.warn ghc_flavour
 
case ghc_flavour
when 'deb7'
remote_file ghc_tarball do
remote_file ghc_bin_tarball do
source 'https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.bz2'
checksum '20b5731d268613bbf6e977dbb192a3a3b7b78d954c35edbfca4fb36b652e24f7'
notifies :run, "execute[rm -rf #{ghc_build_dir}]", :immediately
end
when 'centos65'
remote_file ghc_tarball do
remote_file ghc_bin_tarball do
source 'https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-centos65.tar.bz2'
checksum '344572b5d866f70f2b9c8b4598e7eb25af1f18900852b21fdda23d8f525a1e69'
notifies :run, "execute[rm -rf #{ghc_build_dir}]", :immediately
end
end
 
execute "rm -rf #{ghc_build_dir}" do
action :nothing
ghc_bootstrap_dir = '/var/cache/ghc-bootstrap'
bash 'install ghc bootstrap' do
code <<-EOH
set -e
set -x
rm -rf #{ghc_build_dir}
cd /var/cache
tar -xjf #{ghc_bin_tarball}
cd #{ghc_build_dir}
./configure --prefix=#{ghc_bootstrap_dir}
make -j #{nproc + 1} install
EOH
env 'PATH' => '/usr/bin:/bin'
not_if "#{ghc_bootstrap_dir}/bin/ghc --version | grep ' 7\.8\.4$'"
end
 
execute 'extract ghc' do
command "tar -xjf #{ghc_tarball}"
cwd '/var/cache'
not_if { File.directory?(ghc_build_dir) }
ghc_tarball = ghc_build_dir + "-src.tar.bz2"
remote_file ghc_tarball do
source 'https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-src.tar.bz2'
checksum '59e3bd514a1820cc1c03e1808282205c0b8518369acae12645ceaf839e6f114b'
end
 
bash 'compile ghc' do
bash 'compile ghc using bootstrap' do
code <<-EOH
set -e
set -x
mkdir -p /var/cache
cd /var/cache
rm -rf #{ghc_build_dir}
tar -xjf #{ghc_tarball}
cd #{ghc_build_dir}
export HADDOCK_DOCS=no
export INTEGER_LIBRARY=integer-simple
./configure --prefix=/usr/local
make -j $(($(nproc) + 1 )) install
make -j #{nproc +1} install
EOH
env 'PATH' => '/usr/bin:/bin'
cwd ghc_build_dir
not_if '/usr/local/bin/ghc --version | grep " 7\.8\.4$"'
env 'PATH' => "#{ghc_bootstrap_dir}/bin:/usr/bin:/bin"
not_if "/usr/local/bin/ghc --version | grep ' 7\.8\.4$'"
end
 
cabal_build_dir = '/var/cache/Cabal-1.22.0.0'
Loading
Loading
@@ -60,27 +86,21 @@ cabal_tarball = "#{cabal_build_dir}.tar.gz"
remote_file cabal_tarball do
source 'https://www.haskell.org/cabal/release/cabal-1.22.0.0/Cabal-1.22.0.0.tar.gz'
checksum '8515668ba4a3e8eb0009d549608ab7b667d60aa8f3fda8e51e908b944d08cd99'
notifies :run, "execute[rm -rf #{cabal_build_dir}]", :immediately
end
execute "rm -rf #{cabal_build_dir}" do
action :nothing
end
execute 'extract cabal' do
command "tar -xzf #{cabal_tarball}"
cwd '/var/cache'
not_if { File.directory?(cabal_build_dir) }
end
 
bash 'compile cabal' do
code <<-EOH
set -e
ghc --make Setup
set -x
mkdir -p /var/cache
cd /var/cache
tar -xzf #{cabal_tarball}
cd #{cabal_build_dir}
ghc -threaded --make Setup
./Setup configure --global --prefix=/usr/local
./Setup build
./Setup install
EOH
cwd cabal_build_dir
env 'PATH' => '/usr/local/bin:/usr/bin:/bin'
creates '/usr/local/lib/ghc-7.8.4/Cabal-1.22.0.0'
end
Loading
Loading
@@ -90,22 +110,17 @@ cabal_install_tarball = "#{cabal_install_build_dir}.tar.gz"
remote_file cabal_install_tarball do
source 'http://hackage.haskell.org/package/cabal-install-1.22.0.0/cabal-install-1.22.0.0.tar.gz'
checksum '5f9a8d4cb4d75ac8c350eed09fe7c35dace3e8a71f123c61a392ab9ee7128e9d'
notifies :run, "execute[rm -rf #{cabal_install_build_dir}]", :immediately
end
execute "rm -rf #{cabal_install_build_dir}" do
action :nothing
end
 
execute 'extract cabal-install' do
command "tar -xzf #{cabal_install_tarball}"
cwd '/var/cache'
not_if { File.directory?(cabal_install_build_dir) }
end
execute 'compile cabal-install' do
command './bootstrap.sh --global'
cwd cabal_install_build_dir
bash 'compile cabal-install' do
code <<-EOH
set -e
cd /var/cache
rm -rf #{cabal_install_build_dir}
tar -xzf #{cabal_install_tarball}
cd #{cabal_install_build_dir}
./bootstrap.sh --global
EOH
env 'PATH' => '/usr/local/bin:/usr/bin:/bin'
not_if '/usr/local/bin/cabal --version | grep " 1\.22\.0\.0$"'
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment