Merge branch 'system-reqs'

This commit is contained in:
Julian Ospald 2019-04-11 10:15:15 +08:00
commit f8abcb7d08
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
4 changed files with 128 additions and 16 deletions

View File

@ -0,0 +1 @@
curl g++ gcc gmp make ncurses python3 realpath xz-utils

1
.requirements/ghc/ubuntu Normal file
View File

@ -0,0 +1 @@
curl g++ gcc libgmp-dev libtinfo-dev make ncurses-dev python3 realpath xz-utils

View File

@ -33,10 +33,9 @@ echo "PATH components."
echo echo
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then 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 "Note that this script can be re-run at any given time."
echo echo
# Wait for user input to continue. # Wait for user input to continue.
# shellcheck disable=SC2034 # shellcheck disable=SC2034
read -r answer </dev/tty read -r answer </dev/tty
@ -59,6 +58,22 @@ else
edo . "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/env edo . "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup/env
fi fi
echo
echo "To install and run GHC you need the following dependencies:"
echo " $(ghcup print-system-reqs)"
echo
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
echo "You may want to install these now, then press enter to proceed"
echo "or press ctrl-c to abort."
echo "Installation may take a while."
echo
# Wait for user input to continue.
# shellcheck disable=SC2034
read -r answer </dev/tty
fi
edo ghcup install edo ghcup install
edo ghcup set edo ghcup set
@ -74,3 +89,6 @@ printf "\\033[0;35m%s\\033[0m\\n" ""
) )
# vim: tabstop=4 shiftwidth=4 expandtab

120
ghcup
View File

@ -100,10 +100,10 @@ DOWNLOADER="curl"
# Options passed to the download program. # Options passed to the download program.
DOWNLOADER_OPTS="--fail -O" DOWNLOADER_OPTS="--fail -O"
# @VARIABLE: SCRIPT_UPDATE_URL # @VARIABLE: DOWNLOADER_STDOUT_OPTS
# @DESCRIPTION: # @DESCRIPTION:
# Location to update this script from. # Options passed to the download program when printing the content to stdout.
SCRIPT_UPDATE_URL="https://raw.githubusercontent.com/haskell/ghcup/master/ghcup" DOWNLOADER_STDOUT_OPTS="--fail"
# @VARIABLE: GHC_DOWNLOAD_BASEURL # @VARIABLE: GHC_DOWNLOAD_BASEURL
# @DESCRIPTION: # @DESCRIPTION:
@ -121,11 +121,21 @@ JOBS="1"
# the script name. # the script name.
SOURCE="$0" SOURCE="$0"
# @VARIABLE: BASE_DOWNLOAD_URL
# DESCRIPTION:
# The base url for downloading stuff like meta files, requirements files etc.
BASE_DOWNLOAD_URL="https://raw.githubusercontent.com/haskell/ghcup/master/"
# @VARIABLE: SCRIPT_UPDATE_URL
# @DESCRIPTION:
# Location to update this script from.
SCRIPT_UPDATE_URL="${BASE_DOWNLOAD_URL}/ghcup"
# @VARIABLE: META_DOWNLOAD_URL # @VARIABLE: META_DOWNLOAD_URL
# DESCRIPTION: # DESCRIPTION:
# The url of the meta file for getting # The url of the meta file for getting
# download information for ghc/cabal-install etc. # download information for ghc/cabal-install etc.
META_DOWNLOAD_URL="https://raw.githubusercontent.com/haskell/ghcup/master/.download-urls" META_DOWNLOAD_URL="${BASE_DOWNLOAD_URL}/.download-urls"
# @VARIABLE: META_DOWNLOAD_FORMAT # @VARIABLE: META_DOWNLOAD_FORMAT
# DESCRIPTION: # DESCRIPTION:
@ -138,7 +148,7 @@ META_DOWNLOAD_FORMAT="1"
# DESCRIPTION: # DESCRIPTION:
# The url of the meta file for getting # The url of the meta file for getting
# available versions for ghc/cabal-install etc. # available versions for ghc/cabal-install etc.
META_VERSION_URL="https://raw.githubusercontent.com/haskell/ghcup/master/.available-versions" META_VERSION_URL="${BASE_DOWNLOAD_URL}/.available-versions"
# @VARIABLE: META_VERSION_FORMAT # @VARIABLE: META_VERSION_FORMAT
# DESCRIPTION: # DESCRIPTION:
@ -184,14 +194,15 @@ FLAGS:
(these will not be removed by ghcup) (these will not be removed by ghcup)
SUBCOMMANDS: SUBCOMMANDS:
install Install GHC$(${VERBOSE} && printf "\n compile Compile and install GHC from source (UNSTABLE!!!)") install Install GHC$(${VERBOSE} && printf "\n compile Compile and install GHC from source (UNSTABLE!!!)")
set Set currently active GHC version set Set currently active GHC version
list Show available GHCs and other tools list Show available GHCs and other tools
upgrade Upgrade this script in-place upgrade Upgrade this script in-place
rm Remove an already installed GHC rm Remove an already installed GHC
install-cabal Install cabal-install install-cabal Install cabal-install
debug-info Print debug info (e.g. detected system/distro) debug-info Print debug info (e.g. detected system/distro)
changelog Show the changelog of a GHC release (online) changelog Show the changelog of a GHC release (online)
print-system-reqs Print an approximation of system requirements
DISCUSSION: DISCUSSION:
ghcup installs the Glasgow Haskell Compiler from the official ghcup installs the Glasgow Haskell Compiler from the official
@ -407,7 +418,7 @@ DISCUSSION:
# @FUNCTION: changelog_usage # @FUNCTION: changelog_usage
# @DESCRIPTION: # @DESCRIPTION:
# Print the help message for 'ghcup set' to STDERR # Print the help message for 'ghcup changelog' to STDERR
# and exit the script with status code 1. # and exit the script with status code 1.
changelog_usage() { changelog_usage() {
(>&2 echo "ghcup-changelog (>&2 echo "ghcup-changelog
@ -431,6 +442,30 @@ DISCUSSION:
exit 1 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 fi
} }
# @FUNCTION: download_to_stdout
# @USAGE: <url>
# @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 # @FUNCTION: unpack
# @USAGE: <tarball> # @USAGE: <tarball>
# @DESCRIPTION: # @DESCRIPTION:
@ -1807,6 +1852,42 @@ changelog() {
} }
######################################
#--[ Subcommand print-system-reqs ]--#
######################################
# @FUNCTION: system_reqs_url
# @USAGE: <distro-alias>
# @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) -w|--wget)
DOWNLOADER="wget" DOWNLOADER="wget"
DOWNLOADER_OPTS="" DOWNLOADER_OPTS=""
DOWNLOADER_STDOUT_OPTS="-qO-"
shift 1 shift 1
if [ $# -lt 1 ] ; then if [ $# -lt 1 ] ; then
usage usage
@ -2075,6 +2157,16 @@ while [ $# -gt 0 ] ; do
fi fi
fi fi
break;; 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;; *) usage;;
esac esac
break;; break;;