2017-03-01 02:39:23 +00:00
#!/bin/sh
2017-12-10 15:42:15 +00:00
# Usage: ./docker.sh [GHC_VER]
# Example: ./docker.sh 8.2.2
2017-03-01 02:39:23 +00:00
namespace = "registry.gitlab.com/dxld/ghc-mod"
target = " $1 "
tmpdir = $( mktemp -p " ${ TMPDIR :- /tmp/ } " -d ghc-mod-docker-XXXX) || exit 1
2017-08-20 21:49:16 +00:00
[ -z " $DEBUG " ] && trap 'rm -r ' " $tmpdir " 0 2 15
2017-03-01 02:39:23 +00:00
2017-08-20 21:49:16 +00:00
dldir = "/tmp/ghc-mod-docker-dl"
while read -r ghc_rel ghc ghc_arch ghc_ext cabal cabal_rev image; do
[ -n " $target " ] && [ x" $ghc_rel " != x" $target " ] && continue
2017-03-01 02:39:23 +00:00
2017-04-16 22:19:48 +00:00
ghc_url = " https://downloads.haskell.org/~ghc/ ${ ghc_rel } /ghc- ${ ghc } - ${ ghc_arch } .tar. ${ ghc_ext } "
2018-02-10 14:11:05 +00:00
cabal_url = " https://www.haskell.org/cabal/release/cabal-install- ${ cabal } /cabal-install- ${ cabal } -x86_64-unknown-linux.tar.gz "
## To build cabal from source:
#cabal_url="https://hackage.haskell.org/package/cabal-install-${cabal}/cabal-install-${cabal}.tar.gz"
2017-08-20 21:49:16 +00:00
# https://www.haskell.org/cabal/release/cabal-install-${cabal}/cabal-install-${cabal}.tar.gz
2018-02-10 14:11:05 +00:00
#cabal_meta_url="https://hackage.haskell.org/package/cabal-install-${cabal}/revision/${cabal_rev}.cabal"
2017-08-20 21:49:16 +00:00
ghc_file = " $( basename " $ghc_url " ) "
2018-02-10 14:11:05 +00:00
cabal_exe_file = "cabal"
2017-08-20 21:49:16 +00:00
cabal_file = " $( basename " $cabal_url " ) "
2018-02-10 14:11:05 +00:00
# cabal_meta_file=cabal-install-"${cabal}"-"${cabal_rev}".cabal
2017-03-01 02:39:23 +00:00
ADDITIONAL_COMMANDS = ""
2017-09-26 10:37:53 +00:00
ADDITIONAL_BOOTSTRAP_SETUP = "true"
2017-03-01 02:39:23 +00:00
if [ x" $image " = x"debian:squeeze" ] ; then
2018-02-10 14:11:05 +00:00
ADDITIONAL_PACKAGES = "realpath"
2017-08-20 21:49:16 +00:00
ADDITIONAL_COMMANDS = " ${ ADDITIONAL_COMMANDS } COPY sources.list /etc/apt/
2017-03-01 02:39:23 +00:00
COPY 10-no-check-valid-until /etc/apt/apt.conf.d/
2017-08-20 21:49:16 +00:00
"
2017-09-26 10:37:53 +00:00
ADDITIONAL_BOOTSTRAP_SETUP = "sed -i -e 's|^HACKAGE_URL=.*|HACKAGE_URL=http://hackage.haskell.org/package|' -e 's/^JOBS=.*/JOBS=/' bootstrap.sh"
2017-03-01 02:39:23 +00:00
cat > " $tmpdir " /sources.list <<EOF
deb http://archive.debian.org/debian-archive/debian/ squeeze main
deb http://archive.debian.org/debian-archive/debian/ squeeze-lts main
#deb http://snapshot.debian.org/archive/debian-security/20160216T165545Z/ squeeze/updates main
EOF
cat > " $tmpdir " /10-no-check-valid-until <<EOF
Acquire::Check-Valid-Until "0" ;
EOF
2018-02-10 14:11:05 +00:00
elif [ x" $image " = x"debian:jessie" ] ; then
:
2017-03-01 02:39:23 +00:00
fi
2017-08-20 21:49:16 +00:00
mkdir -p " $dldir "
d = " $( pwd ) " ; cd " $dldir " || exit 1
2018-02-10 14:11:05 +00:00
wget -nv -nc -c " $ghc_url " && cp -l " $ghc_file " " $tmpdir "
wget -nv -nc -c " $cabal_url " && tar -xzOf " $cabal_file " cabal \
> " $tmpdir / $cabal_exe_file "
#wget -nv -nc -c "$cabal_url" && cp -l "$cabal_file" "$tmpdir"
# if [ ! -e "$dldir"/"${cabal_meta_file}" ]; then
# wget -nv "$cabal_meta_url" -O "$dldir"/"${cabal_meta_file}"
# fi && cp -l "$dldir"/"${cabal_meta_file}" "$tmpdir"
2017-08-20 21:49:16 +00:00
ls -l " $tmpdir "
cd " $d " || exit 1
2018-02-10 14:11:05 +00:00
ADDITIONAL_COMMANDS = " ${ ADDITIONAL_COMMANDS } COPY $ghc_file $cabal_exe_file /root/
2017-08-20 21:49:16 +00:00
"
2017-03-01 02:39:23 +00:00
cat > " $tmpdir " /Dockerfile <<EOF
FROM $image
## ensure locale is set during build
ENV LANG C.UTF-8
WORKDIR /root
$ADDITIONAL_COMMANDS
2017-12-10 15:42:15 +00:00
RUN apt-get update && apt-get upgrade -y && \
2017-03-01 02:39:23 +00:00
apt-get install -y --no-install-recommends \
2018-02-10 14:11:05 +00:00
alex happy wget git xz-utils gpgv ca-certificates build-essential libgmp3-dev zlib1g-dev libncurses5-dev libncursesw5-dev $ADDITIONAL_PACKAGES && \
2017-03-01 02:39:23 +00:00
apt-get clean
2017-08-20 21:49:16 +00:00
RUN tar -xf ghc-*.tar.* && \
2017-03-01 02:39:23 +00:00
cd ghc-* && ./configure --prefix= /usr/local && make install && cd .. && \
rm -r ghc-*
2018-02-10 14:11:05 +00:00
RUN chmod +x cabal; mv cabal /usr/local/bin
2017-03-01 02:39:23 +00:00
EOF
2017-08-20 21:49:16 +00:00
docker build -t " ${ namespace } :ghc ${ ghc } -cabal-install ${ cabal } " " $tmpdir "
2018-02-10 14:11:05 +00:00
docker run " ${ namespace } :ghc ${ ghc } -cabal-install ${ cabal } " sh -c 'cabal update; git clone -bghc802 https://github.com/DanielG/ghc-mod.git; cd ghc-mod; cabal new-build'
2017-03-01 02:39:23 +00:00
done <<EOF
2018-02-10 14:11:05 +00:00
8.2.2 8.2.2 x86_64-deb8-linux xz 2.0.0.1 0 debian:jessie
8.0.2 8.0.2 x86_64-deb8-linux xz 2.0.0.1 0 debian:jessie
7.10.3 7.10.3 x86_64-deb8-linux xz 2.0.0.1 0 debian:jessie
7.8.4 7.8.4 x86_64-unknown-linux-deb7 xz 2.0.0.1 0 debian:jessie
2017-03-01 02:39:23 +00:00
EOF
2017-09-18 16:35:09 +00:00
2018-02-10 14:11:05 +00:00
# 7.6.3 7.6.3 x86_64-unknown-linux bz2 1.24.0.2 0 debian:squeeze
# 7.4.2 7.4.2 x86_64-unknown-linux bz2 1.24.0.2 0 debian:squeeze
2017-09-26 10:37:53 +00:00
# 7.2.2 7.2.2 x86_64-unknown-linux bz2 1.24.0.2 0 debian:squeeze
# 7.0.4 7.0.4 x86_64-unknown-linux bz2 1.24.0.2 0 debian:squeeze
2017-09-18 16:35:09 +00:00
# 7.10.3 7.10.3 x86_64-deb8-linux xz 1.22.9.0 0 debian:jessie
# 7.8.4 7.8.4 x86_64-unknown-linux-deb7 xz 1.18.2.0 0 debian:jessie
# 7.6.3 7.6.3 x86_64-unknown-linux bz2 1.18.2.0 0 debian:squeeze
# 7.4.2 7.4.2 x86_64-unknown-linux bz2 1.18.2.0 0 debian:squeeze
# 7.2.2 7.2.2 x86_64-unknown-linux bz2 1.18.2.0 0 debian:squeeze
# 7.0.4 7.0.4 x86_64-unknown-linux bz2 1.18.2.0 0 debian:squeeze