From 34f9eb41c6fa06d86bed90056f29901c0231e1be Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 3 Sep 2017 12:13:44 -0700 Subject: [PATCH] install: cleanup --- hledger-install/hledger-install.sh | 58 ++++++++++-------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/hledger-install/hledger-install.sh b/hledger-install/hledger-install.sh index 1f1ed0515..bf77bea39 100755 --- a/hledger-install/hledger-install.sh +++ b/hledger-install/hledger-install.sh @@ -775,6 +775,25 @@ quietly_run() { $@ 2>/dev/null || true } +# Try to install the executables of the given package(s) to $HOME/.local/bin, +# trying several methods, generally from quickest to most reliable, continuing on failure. +# Current the installation methods are: +# - if stack is not installed and cabal is, try cabal install +# - otherwise install stack if needed and try stack install with specific resolver and ghc +# For the stack method, it's necessary to provide not only the package(s) you want to +# install but also all dependencies which are not in the specified stackage $RESOLVER. +try_install() { + (cd # avoid any project-specific stack/cabal config, install at user level + (! has_cmd stack && has_cmd cabal && try_info cabal install "$@" --verbose=$CABAL_VERBOSITY ) || + (ensure_stack && ( + #(try_info stack install --install-ghc "$@" --verbosity=$STACK_VERBOSITY ) || # existing resolver + (try_info stack install --install-ghc $RESOLVER "$@" --verbosity=$STACK_VERBOSITY ) # specific resolver + ) + ) || + echo Failed to install "$@" + ) +} + # start # process command-line flags @@ -857,46 +876,7 @@ if [[ $STATUSFLAG ]] ; then exit 0 fi -# select main hledger packages to install -#TOOLS_TO_INSTALL="" -## packages of main tools which are missing or older than latest version -#for t in $HLEDGER_MAIN_TOOLS; do -# if [[ $(cmd_version $t) < $HLEDGER_VERSION ]]; then -# TOOLS_TO_INSTALL="$TOOLS_TO_INSTALL $t-$HLEDGER_VERSION" -# fi -#done -## any depended-on hledger packages so that stack can pull those too from hackage when needed -#PACKAGES_TO_INSTALL=$TOOLS_TO_INSTALL -#if [[ $PACKAGES_TO_INSTALL ]]; then -# # most packages depend on hledger, add it if not already added -# if [[ ! $PACKAGES_TO_INSTALL =~ hledger-$HLEDGER_VERSION ]]; then -# PACKAGES_TO_INSTALL="hledger-$HLEDGER_VERSION $PACKAGES_TO_INSTALL" -# fi -# # and most depend on hledger-lib -# PACKAGES_TO_INSTALL="hledger-lib-$HLEDGER_VERSION $PACKAGES_TO_INSTALL" -#fi - # try installing each package that needs installing, in turn - -# Try to install the executables of the given package(s) to $HOME/.local/bin, -# trying several methods, generally from quickest to most reliable, continuing on failure. -# Current the installation methods are: -# - if stack is not installed and cabal is, try cabal install -# - otherwise install stack if needed and try stack install with specific resolver and ghc -# For the stack method, it's necessary to provide not only the package(s) you want to -# install but also all dependencies which are not in the specified stackage $RESOLVER. -try_install() { - (cd # avoid any project-specific stack/cabal config, install at user level - (! has_cmd stack && has_cmd cabal && try_info cabal install "$@" --verbose=$CABAL_VERBOSITY ) || - (ensure_stack && ( - #(try_info stack install --install-ghc "$@" --verbosity=$STACK_VERBOSITY ) || # existing resolver - (try_info stack install --install-ghc $RESOLVER "$@" --verbosity=$STACK_VERBOSITY ) # specific resolver - ) - ) || - echo Failed to install "$@" - ) -} - echo ---------- if [[ $(cmd_version hledger) < $HLEDGER_VERSION ]]; then echo Installing hledger