From b9c414a4d8abf5381c46478071e8dfb87ef3d214 Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Mon, 13 Apr 2020 21:15:11 +0200
Subject: [PATCH] Point to new ghcup

---
 ghcup | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/ghcup b/ghcup
index 4f82773..93acf81 100755
--- a/ghcup
+++ b/ghcup
@@ -1603,11 +1603,57 @@ upgrade() {
     status_message "Updating ${SCRIPT}"
 
     (
+        _plat="$(uname -s)"
+        _arch=$(uname -m)
+
+        case "${_plat}" in
+            "linux"|"Linux")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        _url=https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup
+                        ;;
+                    i*86)
+                        _url=https://downloads.haskell.org/~ghcup/i386-linux-ghcup
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                ;;
+            "FreeBSD"|"freebsd")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        ;;
+                    i*86)
+                        die "i386 currently not supported!"
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                _url=https://downloads.haskell.org/~ghcup/x86_64-portbld-freebsd-ghcup
+                ;;
+            "Darwin"|"darwin")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        ;;
+                    i*86)
+                        die "i386 currently not supported!"
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                _url=https://downloads.haskell.org/~ghcup/x86_64-apple-darwin-ghcup ;;
+            *) die "Unknown platform: ${_plat}"
+                ;;
+        esac
+
+
         edo cd "$(mktempdir)"
-        download "${SCRIPT_UPDATE_URL}"
+        download_to_stdout "${_url}" > ghcup
         edo chmod +x ghcup
         edo mv -f ghcup "${target_location}"/ghcup
 
+        unset _plat _arch _url
+
     ) || die "failed to install"
 
     status_message "Done"
@@ -2091,6 +2137,10 @@ fi
 
 
 
+>&2 warning_message "ghcup has been rewritten in haskell. Please upgrade again via 'ghcup upgrade'"
+
+
+
 
     ##############################################
     #--[ Command line parsing and entry point ]--#
-- 
GitLab