Allow to overwrite the distro used, wrt #116
This commit is contained in:
parent
2458f5e9db
commit
02e356663f
22
ghcup
22
ghcup
@ -225,7 +225,7 @@ USAGE:
|
|||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-f, --force Overwrite already existing installation
|
-f, --force Overwrite already existing installation$(${VERBOSE} && printf "\n -o, --os Overwrite OS detection with the given string (must be a correct OS alias, e.g. 'alpine')")
|
||||||
|
|
||||||
ARGS:
|
ARGS:
|
||||||
[VERSION|TAG] E.g. \"8.4.3\" or \"8.6.1\" or
|
[VERSION|TAG] E.g. \"8.4.3\" or \"8.6.1\" or
|
||||||
@ -807,7 +807,7 @@ check_meta_file_version() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: get_download_url
|
# @FUNCTION: get_download_url
|
||||||
# @USAGE: <tool> <version>
|
# @USAGE: <tool> <version> [os-overwrite]
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Gets the download url for the given tool and version
|
# Gets the download url for the given tool and version
|
||||||
# and the current distro and architecture (which it tries to discover).
|
# and the current distro and architecture (which it tries to discover).
|
||||||
@ -820,7 +820,11 @@ get_download_url() {
|
|||||||
myver=$2
|
myver=$2
|
||||||
myarch=$(get_arch)
|
myarch=$(get_arch)
|
||||||
[ -z "${myarch}" ] && die "failed to get architecture"
|
[ -z "${myarch}" ] && die "failed to get architecture"
|
||||||
|
if [ -n "$3" ] ; then
|
||||||
|
mydistro=$(get_distro_alias "$3")
|
||||||
|
else
|
||||||
mydistro=$(get_distro_alias "$(get_distro_name)")
|
mydistro=$(get_distro_alias "$(get_distro_name)")
|
||||||
|
fi
|
||||||
mydistrover=$(get_distro_ver)
|
mydistrover=$(get_distro_ver)
|
||||||
meta_file="$(get_meta_download_file)"
|
meta_file="$(get_meta_download_file)"
|
||||||
[ -z "${meta_file}" ] && die "failed to get meta file"
|
[ -z "${meta_file}" ] && die "failed to get meta file"
|
||||||
@ -1402,7 +1406,7 @@ set_ghc_major() {
|
|||||||
|
|
||||||
|
|
||||||
# @FUNCTION: install_ghc
|
# @FUNCTION: install_ghc
|
||||||
# @USAGE: <ghcversion>
|
# @USAGE: <ghcversion> [os-overwrite]
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Installs the given ghc version with a lot of side effects.
|
# Installs the given ghc version with a lot of side effects.
|
||||||
install_ghc() {
|
install_ghc() {
|
||||||
@ -1411,7 +1415,7 @@ install_ghc() {
|
|||||||
myghcver=$1
|
myghcver=$1
|
||||||
inst_location=$(get_ghc_location "$1")
|
inst_location=$(get_ghc_location "$1")
|
||||||
[ -z "${inst_location}" ] && die "failed to get install location"
|
[ -z "${inst_location}" ] && die "failed to get install location"
|
||||||
download_url=$(get_download_url "ghc" "${myghcver}")
|
download_url=$(get_download_url "ghc" "${myghcver}" "$2")
|
||||||
if [ -z "${download_url}" ] ; then
|
if [ -z "${download_url}" ] ; then
|
||||||
die "Could not find an appropriate download for the requested GHC-${myghcver} on your system! Please report a bug at ${BUG_URL}"
|
die "Could not find an appropriate download for the requested GHC-${myghcver} on your system! Please report a bug at ${BUG_URL}"
|
||||||
fi
|
fi
|
||||||
@ -1419,7 +1423,7 @@ install_ghc() {
|
|||||||
first_install=true
|
first_install=true
|
||||||
|
|
||||||
|
|
||||||
status_message "Installing GHC-${myghcver} for $(get_distro_name) on architecture $(get_arch)"
|
status_message "Installing GHC-${myghcver} for $(if [ -n "$2" ] ; then echo "$2" ; else get_distro_name ; fi) on architecture $(get_arch)"
|
||||||
|
|
||||||
if ghc_already_installed "${myghcver}" ; then
|
if ghc_already_installed "${myghcver}" ; then
|
||||||
if ${FORCE} ; then
|
if ${FORCE} ; then
|
||||||
@ -2128,6 +2132,8 @@ upgrade"
|
|||||||
-h|--help) install_usage;;
|
-h|--help) install_usage;;
|
||||||
-f|--force) FORCE=true
|
-f|--force) FORCE=true
|
||||||
shift 1;;
|
shift 1;;
|
||||||
|
-o|--os) MY_OS=$2
|
||||||
|
shift 2;;
|
||||||
*) GHC_VER=$1
|
*) GHC_VER=$1
|
||||||
break;;
|
break;;
|
||||||
esac
|
esac
|
||||||
@ -2137,13 +2143,13 @@ upgrade"
|
|||||||
if [ -z "${_tool_ver}" ] ; then
|
if [ -z "${_tool_ver}" ] ; then
|
||||||
die "Could not find a recommended GHC version, please report a bug at ${BUG_URL}!"
|
die "Could not find a recommended GHC version, please report a bug at ${BUG_URL}!"
|
||||||
fi
|
fi
|
||||||
install_ghc "${_tool_ver}"
|
install_ghc "${_tool_ver}" "${MY_OS}"
|
||||||
else
|
else
|
||||||
# could be a version or a tag, let's check
|
# could be a version or a tag, let's check
|
||||||
if array_contains "${GHC_VER}" "$(known_tool_versions "ghc")" ; then
|
if array_contains "${GHC_VER}" "$(known_tool_versions "ghc")" ; then
|
||||||
install_ghc "${GHC_VER}"
|
install_ghc "${GHC_VER}" "${MY_OS}"
|
||||||
elif array_contains "${GHC_VER}" "$(known_tool_tags "ghc")" ; then
|
elif array_contains "${GHC_VER}" "$(known_tool_tags "ghc")" ; then
|
||||||
install_ghc "$(get_tool_ver_from_tag "ghc" "${GHC_VER}")"
|
install_ghc "$(get_tool_ver_from_tag "ghc" "${GHC_VER}")" "${MY_OS}"
|
||||||
else
|
else
|
||||||
die "\"${GHC_VER}\" is not a known version or tag!"
|
die "\"${GHC_VER}\" is not a known version or tag!"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user