@@ -17,114 +17,6 @@ stack_resolver() {
17
17
return 0
18
18
}
19
19
20
- setup_haskell () {
21
- local HVN_DEST=$1
22
- local GENERATE_HOOGLE_DB=$2
23
- local DRY_RUN=$3
24
- local RETCODE
25
-
26
- if ! check_exist stack > /dev/null ; then
27
- err " Installer requires Stack."
28
- msg " Installation instructions: http://docs.haskellstack.org/en/stable/README/#how-to-install"
29
- exit 1
30
- fi
31
-
32
- msg " Setting up GHC if needed..."
33
- stack setup --verbosity warning ; RETCODE=$?
34
- [ ${RETCODE} -ne 0 ] && exit_err " Stack setup failed with error ${RETCODE} ."
35
-
36
- if [ $( stack --verbosity 0 path --local-bin 2> /dev/null) ]
37
- then
38
- local STACK_BIN_PATH=$( fix_path $( stack --verbosity 0 path --local-bin) )
39
- local STACK_GLOBAL_DIR=$( fix_path $( stack --verbosity 0 path --stack-root) )
40
- local STACK_GLOBAL_CONFIG=$( fix_path $( stack --verbosity 0 path --config-location) )
41
- else
42
- local STACK_BIN_PATH=$( fix_path $( stack --verbosity 0 path --local-bin-path) )
43
- local STACK_GLOBAL_DIR=$( fix_path $( stack --verbosity 0 path --global-stack-root) )
44
- local STACK_GLOBAL_CONFIG=$( fix_path $( stack --verbosity 0 path --config-location) )
45
- fi
46
- local STACK_RESOLVER=$( stack_resolver $STACK_GLOBAL_CONFIG )
47
-
48
- detail " Stack bin path: ${STACK_BIN_PATH} "
49
- detail " Stack global path: ${STACK_GLOBAL_DIR} "
50
- detail " Stack global config location: ${STACK_GLOBAL_CONFIG} "
51
- detail " Stack resolver: ${STACK_RESOLVER} "
52
-
53
- if [ -z ${STACK_BIN_PATH} ] || [ -z ${STACK_GLOBAL_DIR} ] || [ -z ${STACK_GLOBAL_CONFIG} ] ; then
54
- exit_err_report " Incorrect stack paths."
55
- fi
56
-
57
- detail " ${HVN_DEST} /.stack-bin -> ${STACK_BIN_PATH} "
58
- ln -sf ${STACK_BIN_PATH} ${HVN_DEST} /.stack-bin
59
-
60
- msg " Installing helper binaries..."
61
-
62
- # Install ghc-mod via active stack resolver for maximum out-of-the-box compatibility.
63
- # Stack dependency solving requires cabal to be on the PATH.
64
- stack --resolver ${STACK_RESOLVER} install ghc-mod cabal-install --verbosity warning ; RETCODE=$?
65
- [ ${RETCODE} -ne 0 ] && exit_err " Installing ghc-mod/cabal-install failed with error ${RETCODE} ."
66
-
67
- # Install hindent via pinned LTS to ensure we have version 5.
68
- if [ " $DRY_RUN " == false ]
69
- then
70
- stack --resolver lts-8.6 install hindent --install-ghc --verbosity warning ; RETCODE=$?
71
- else
72
- stack --resolver lts-8.6 install hindent --install-ghc --verbosity warning --dry-run ; RETCODE=$?
73
- fi
74
- [ ${RETCODE} -ne 0 ] && exit_err " Installing hindent failed with error ${RETCODE} ."
75
-
76
- # Create a temporary directory for helper binary dependency solving.
77
- local HELPER_BINARIES_TEMP_DIR=$( mktemp -d)
78
- cp ${HVN_DEST} /dependencies.cabal $HELPER_BINARIES_TEMP_DIR
79
- pushd $HELPER_BINARIES_TEMP_DIR
80
-
81
- # Solve the versions of all helper binaries listed in dependencies.cabal.
82
- stack init --solver --install-ghc ; RETCODE=$?
83
- [ ${RETCODE} -ne 0 ] && exit_err " Solving dependencies for helper binaries failed with error ${RETCODE} ."
84
-
85
- # Clean up the comments and blank lines from stack.yaml.
86
- sed -i.bak1 -e ' s/^#.*$//' -e ' /^$/d' stack.yaml
87
-
88
- # Remove warning message from generated stack.yaml.
89
- sed -i.bak2 -e ' /user-message/,+3d' stack.yaml
90
-
91
- # Install all solved dependency versions for the helper binaries, while skipping local dependencies package and GHC.
92
- # Also skipping bogus 'invalid-cabal-flag-settings' dependency from base: https://github.com/commercialhaskell/stack/issues/2969
93
- local HELPER_BINARIES_DEPENDENCY_LIST=$( stack list-dependencies --separator - | grep -vE " ^dependencies-|^ghc-[0-9]\.[0-9]\.[0-9]$|^invalid-cabal-flag-settings-|^rts-" )
94
-
95
- for dep in $HELPER_BINARIES_DEPENDENCY_LIST
96
- do
97
- if [ " $DRY_RUN " == false ]
98
- then
99
- stack install $dep ; RETCODE=$?
100
- else
101
- stack install $dep --dry-run ; RETCODE=$?
102
- fi
103
- [ ${RETCODE} -ne 0 ] && exit_err " Installing helper binary dependency $dep failed with error ${RETCODE} ."
104
- done
105
-
106
- # Clean up temporary directory.
107
- popd
108
- rm -rf $HELPER_BINARIES_TEMP_DIR
109
-
110
- msg " Installing git-hscope..."
111
- cp ${HVN_DEST} /git-hscope ${STACK_BIN_PATH}
112
-
113
- if [ " $GENERATE_HOOGLE_DB " == true ]
114
- then
115
- msg " Building Hoogle database..."
116
- ${STACK_BIN_PATH} /hoogle generate
117
- fi
118
-
119
- msg " Configuring codex to search in stack..."
120
- cat > $HOME /.codex << EOF
121
- hackagePath: $STACK_GLOBAL_DIR /indices/Hackage/
122
- tagsFileHeader: false
123
- tagsFileSorted: false
124
- tagsCmd: hasktags --extendedctag --ignore-close-implementation --ctags --tags-absolute --output='\$ TAGS' '\$ SOURCES'
125
- EOF
126
- }
127
-
128
20
# Print package name to install if command is not found
129
21
# $1: command name
130
22
# $2: package name
0 commit comments