diff --git a/.requirements/ghc/default b/.requirements/ghc/default new file mode 100644 index 0000000..2a7dc60 --- /dev/null +++ b/.requirements/ghc/default @@ -0,0 +1 @@ +curl g++ gcc gmp make ncurses python3 realpath xz-utils diff --git a/.requirements/ghc/ubuntu b/.requirements/ghc/ubuntu new file mode 100644 index 0000000..5c20956 --- /dev/null +++ b/.requirements/ghc/ubuntu @@ -0,0 +1 @@ +curl g++ gcc libgmp-dev libtinfo-dev make ncurses-dev python3 realpath xz-utils diff --git a/bootstrap-haskell b/bootstrap-haskell index ac15b4d..d93f513 100755 --- a/bootstrap-haskell +++ b/bootstrap-haskell @@ -33,10 +33,9 @@ echo "PATH components." echo if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then - echo "To proceed with the installation press enter, to cancel press ctrl-c." + echo "To proceed with the ghcup installation press enter, to cancel press ctrl-c." echo "Note that this script can be re-run at any given time." echo - # Wait for user input to continue. # shellcheck disable=SC2034 read -r answer &2 echo "ghcup-changelog @@ -431,6 +442,30 @@ DISCUSSION: exit 1 } +# @FUNCTION: print_system_reqs_usage +# @DESCRIPTION: +# Print the help message for 'ghcup print-system-reqs' to STDERR +# and exit the script with status code 1. +print_system_reqs_usage() { + (>&2 echo "ghcup-print-system-reqs +Print an approximation of system requirements + +USAGE: + ${SCRIPT} print-system-reqs + +FLAGS: + -h, --help Prints help information + +DISCUSSION: + Just prints an approximation of the system requirements + for the 'recommended' GHC version and the 'latest' distro version + you are on. + + Review this output carefully! +") + exit 1 +} + @@ -967,6 +1002,16 @@ download_silent() { fi } +# @FUNCTION: download_to_stdout +# @USAGE: +# @DESCRIPTION: +# Downloads the given url to stdout. +download_to_stdout() { + [ -z "$1" ] && die "Internal error: no argument given to download" + # shellcheck disable=SC2086 + edo ${DOWNLOADER} ${DOWNLOADER_STDOUT_OPTS} "$1" +} + # @FUNCTION: unpack # @USAGE: # @DESCRIPTION: @@ -1807,6 +1852,42 @@ changelog() { } + ###################################### + #--[ Subcommand print-system-reqs ]--# + ###################################### + + +# @FUNCTION: system_reqs_url +# @USAGE: +# @DESCRIPTION: +# Mapping of distro-alias to system requirements URL. +system_reqs_url() { + [ -z "$1" ] && die "Internal error: no argument given to system_reqs_url" + + case "$1" in + "debian"|"ubuntu") + printf "%s/.requirements/ghc/ubuntu" "${BASE_DOWNLOAD_URL}" + ;; + *) + printf "%s/.requirements/ghc/default" "${BASE_DOWNLOAD_URL}" + ;; + esac +} + + +# @FUNCTION: print_system_reqs +# @DESCRIPTION: +# Print the system requirements (approximation). +print_system_reqs() { + mydistro=$(get_distro_alias "$(get_distro_name)") + reqs_url=$(system_reqs_url "${mydistro}") + + download_to_stdout "${reqs_url}" + + unset mydistro reqs_url +} + + ####################### @@ -1848,6 +1929,7 @@ while [ $# -gt 0 ] ; do -w|--wget) DOWNLOADER="wget" DOWNLOADER_OPTS="" + DOWNLOADER_STDOUT_OPTS="-qO-" shift 1 if [ $# -lt 1 ] ; then usage @@ -2075,6 +2157,16 @@ while [ $# -gt 0 ] ; do fi fi break;; + print-system-reqs) + shift 1 + while [ $# -gt 0 ] ; do + case $1 in + -h|--help) print_system_reqs_usage;; + *) print_system_reqs_usage;; + esac + done + print_system_reqs + break;; *) usage;; esac break;;