#!/bin/sh # Usage: ./docker.sh [GHC_VER] # Example: ./docker.sh 8.2.2 namespace="registry.gitlab.com/dxld/ghc-mod" target="$1" tmpdir=$(mktemp -p "${TMPDIR:-/tmp/}" -d ghc-mod-docker-XXXX) || exit 1 [ -z "$DEBUG" ] && trap 'rm -r '"$tmpdir" 0 2 15 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 ghc_url="https://downloads.haskell.org/~ghc/${ghc_rel}/ghc-${ghc}-${ghc_arch}.tar.${ghc_ext}" 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" # https://www.haskell.org/cabal/release/cabal-install-${cabal}/cabal-install-${cabal}.tar.gz #cabal_meta_url="https://hackage.haskell.org/package/cabal-install-${cabal}/revision/${cabal_rev}.cabal" ghc_file="$(basename "$ghc_url")" cabal_exe_file="cabal" cabal_file="$(basename "$cabal_url")" # cabal_meta_file=cabal-install-"${cabal}"-"${cabal_rev}".cabal ADDITIONAL_COMMANDS="" ADDITIONAL_BOOTSTRAP_SETUP="true" if [ x"$image" = x"debian:squeeze" ]; then ADDITIONAL_PACKAGES="realpath" ADDITIONAL_COMMANDS="${ADDITIONAL_COMMANDS}COPY sources.list /etc/apt/ COPY 10-no-check-valid-until /etc/apt/apt.conf.d/ " ADDITIONAL_BOOTSTRAP_SETUP="sed -i -e 's|^HACKAGE_URL=.*|HACKAGE_URL=http://hackage.haskell.org/package|' -e 's/^JOBS=.*/JOBS=/' bootstrap.sh" cat > "$tmpdir"/sources.list < "$tmpdir"/10-no-check-valid-until < "$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" ls -l "$tmpdir" cd "$d" || exit 1 ADDITIONAL_COMMANDS="${ADDITIONAL_COMMANDS}COPY $ghc_file $cabal_exe_file /root/ " cat > "$tmpdir"/Dockerfile <