Compare commits

..

31 Commits

Author SHA1 Message Date
3d10f964c6 Bump version to 0.1.3 2020-04-15 15:42:09 +02:00
404038edcb Fix boolean check in upgradeGHCup :) 2020-04-15 15:37:29 +02:00
ea4f9ceab1 Update download info 2020-04-15 15:37:01 +02:00
5c481ea94e Small travis adjustment 2020-04-15 15:36:03 +02:00
1ccaf4ba91 Update ghcup downloads 2020-04-15 15:12:21 +02:00
b532511cd5 Use local ghcup-*.json in travis 2020-04-15 15:07:37 +02:00
b3105b439c Bump version to 0.1.2 2020-04-15 13:58:53 +02:00
2b6cb5f1a8 Enable gitlab travis 2020-04-15 13:58:53 +02:00
f4242b10e7 Don't update ghcup if already latest version
Fixes #2
2020-04-15 13:58:52 +02:00
ad4d185ead Fix GHCUP_INSTALL_BASE_PREFIX
This should be the *parent* dir of '.ghcup', not
the full destination.
2020-04-15 13:55:32 +02:00
b18aafe2c4 Fix bug with removing set GHC version 2020-04-15 13:55:28 +02:00
340196bf9d Update ghcup tarballs 2020-04-15 08:31:01 +02:00
883226aa70 Update secret 2020-04-15 01:05:18 +02:00
0d393612a7 Update git repo links 2020-04-15 01:04:58 +02:00
5635f6cc4e Bump version 2020-04-15 00:25:34 +02:00
a7fd36beeb Release 0.1.1 and fix bugs on mac 2020-04-15 00:08:47 +02:00
baee1d5b85 Update link 2020-04-13 22:20:10 +02:00
68df6b8e50 Update ghcup URIs 2020-04-13 21:11:26 +02:00
ac73090784 Improve HACKING.md 2020-04-13 21:11:00 +02:00
faf4f3b7ca Rm foo 2020-04-13 17:13:47 +02:00
d888d11d59 Allow to control prettiness of JSON output 2020-04-13 15:25:50 +02:00
28a1077833 Add i386 ghcup binary 2020-04-13 15:25:43 +02:00
c40b9dbc0b Fix darwin 10.14 tarball, thanks to carter 2020-04-13 15:21:47 +02:00
6bbd262818 Update TODO 2020-04-13 15:21:16 +02:00
78d36bce24 Update hacking doc 2020-04-13 15:20:56 +02:00
aedfc19220 Remove homebrew trash 2020-04-12 21:50:07 +02:00
2f34fc7bef Update downloads 2020-04-12 21:32:07 +02:00
de66b92631 Fix upgradeGHCup 2020-04-12 20:22:16 +02:00
fee3984bf7 Update Downloads 2020-04-12 20:12:36 +02:00
b953c8fd30 Add RELEASING.md 2020-04-12 20:01:42 +02:00
24e4c3a19b Add HACKING.md 2020-04-12 19:48:26 +02:00
23 changed files with 387 additions and 144 deletions

78
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,78 @@
variables:
GIT_SSL_NO_VERIFY: "1"
# Commit of ghc/ci-images repository from which to pull Docker images
DOCKER_REV: cefaee3c742af193e0f7783f87edb0d35374515c
############################################################
# CI Step
############################################################
.debian:
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
tags:
- x86_64-linux
.darwin:
tags:
- x86_64-darwin
.test_ghcup_version:
script:
- ./.gitlab/script/ghcup_version.sh
variables:
JSON_VERSION: "0.0.1"
.test_ghcup_version:linux:
extends:
- .test_ghcup_version
- .debian
before_script:
- ./.gitlab/before_script/linux/install_deps.sh
variables:
OS: "LINUX"
.test_ghcup_version:darwin:
extends:
- .test_ghcup_version
- .darwin
before_script:
- ./.gitlab/before_script/darwin/install_deps.sh
variables:
OS: "DARWIN"
after_script:
- BUILD_DIR=$CI_PROJECT_DIR
- echo "Cleaning $BUILD_DIR"
- cd $HOME
- rm -Rf "$BUILD_DIR"/*
- exit 0
######## linux ########
test:linux:recommended:
extends: .test_ghcup_version:linux
variables:
GHC_VERSION: "recommended"
test:linux:latest:
extends: .test_ghcup_version:linux
variables:
GHC_VERSION: "latest"
allow_failure: true
######## darwin ########
test:mac:recommended:
extends: .test_ghcup_version:darwin
variables:
GHC_VERSION: "recommended"
test:mac:latest:
extends: .test_ghcup_version:darwin
variables:
GHC_VERSION: "latest"
allow_failure: true

View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -eux
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
curl -sSfL https://gitlab.haskell.org/haskell/ghcup/-/raw/master/ghcup > ./ghcup-legacy
chmod +x ghcup-legacy
./ghcup-legacy install ${GHC_VERSION}
./ghcup-legacy set ${GHC_VERSION}
./ghcup-legacy install-cabal
exit 0

View File

@@ -0,0 +1,16 @@
#!/bin/sh
set -eux
sudo apt-get update -y
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
curl -sSfL https://gitlab.haskell.org/haskell/ghcup/-/raw/master/ghcup > ./ghcup-legacy
chmod +x ghcup-legacy
./ghcup-legacy install ${GHC_VERSION}
./ghcup-legacy set ${GHC_VERSION}
./ghcup-legacy install-cabal

3
.gitlab/ghcup_env Normal file
View File

@@ -0,0 +1,3 @@
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
export PATH="$CI_PROJECT_DIR/.ghcup/bin:$CI_PROJECT_DIR/.local/bin:$PATH"

61
.gitlab/script/ghcup_version.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/sh
set -eux
. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env"
mkdir -p "$CI_PROJECT_DIR"/.local/bin
ecabal() {
cabal --store-dir="$(pwd)"/.store "$@"
}
eghcup() {
ghcup -v -c -s file://$(pwd)/ghcup-${JSON_VERSION}.json "$@"
}
# build
ecabal update
if [ "${OS}" = "DARWIN" ] ; then
ecabal build -fcurl
else
ecabal build
fi
cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup')" .
cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup-gen')" .
# testing
cp ./ghcup "$CI_PROJECT_DIR"/.local/bin/ghcup
cp ./ghcup-gen "$CI_PROJECT_DIR"/.local/bin/ghcup-gen
rm -rf "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup
ghcup-gen check -f ghcup-${JSON_VERSION}.json
eghcup numeric-version
eghcup install ${GHC_VERSION}
eghcup set ${GHC_VERSION}
eghcup install-cabal
cabal --version
eghcup debug-info
eghcup list
eghcup list -t ghc
eghcup list -t cabal
ghc --version
ghci --version
ghc-$(ghc --numeric-version) --version
ghci-$(ghc --numeric-version) --version
eghcup rm $(ghc --numeric-version)
eghcup upgrade
eghcup upgrade -f

View File

@@ -4,39 +4,22 @@ jobs:
osx_image: xcode10.1
language: generic
env: ARTIFACT=x86_64-apple-darwin-10.13-ghcup
addons:
homebrew:
packages:
- curl
- libffi
- libiconv
- make
- ncurses
- xz
- os: osx
osx_image: xcode11.3
language: generic
env: ARTIFACT=x86_64-apple-darwin-10.14-ghcup
addons:
homebrew:
packages:
- curl
- libffi
- libiconv
- make
- ncurses
- xz
script: ".travis/build.sh"
deploy:
provider: releases
api_key:
secure: GEQR+HIwMUql+tFU0LoKCCzG+IG1s5XVA4yp8xMFk0IPsNjHEMh6djYgNqsS6MnujzRulinZe69RyJMZHW3UbtVKWd1D5nsCKmAVfnU8VRbubaL55Bz7C2WI9UCYtKY0isVIQu3KkY+0a6LhdjSkbatO2hl9v0nFmN28q/RpEzsJTI4kyVhmCBflH4fL/QvXzfLuyOae7qsiZBVQXEhmySYktKifNMANSI1aU+kyZ3JgykqZogMK+g/fmcxxTe9MPYMsRQxae/xqdf87IQpmK8v9BRShvF0wq1gO8NY+/fEemAVIHi5CYhPgiLntUD/HFr6AT04LcHnaGryDn/PhkvHuDuZ4INYgBrdNMeGVTjT93N7OtXyh7c+AP3/51E8nM0SkSWCeP4P2fMMksdeOnKtPbhzlqgEM9tbRMILOj1LcjcqurU5ku+WEwZ7d1osTyNug7FVCO5Vb0q3NYnDF4UPXc/d5/2SB+SjJSMxRc52+BiKskHmOa96TXirL3eo6KVNaokQRKvbLw1fEjZvqYJuhPWBRDMalyYjc77poj4kzfVL9CYjtP7h6N5wFR7AtPsMz2n2fQf7J3N4+oqHK+83fOPGyy4FYPZojKNw+L2X/XYrfVscsY/1KbBjULgGIrdr4euYz+rRrTHixUYIvGclKOx+g3SHAOXFWhXlldvI=
secure: GQESg4TcYf3PQJRRaZV/kWS0hsF+OFnH2+EcwpgnIcfx4+aogMyprdh745KtBXe1FlFN1luKHksFjqceqhcg/xcNyeCJiSnLWMn4D/i4WUperEHseRBi5yZZCB1AvOjIlHrE4DS3a8pyEm1GV3G7CKY5Fu8jBjof2SnyENfd7fofhjtNHWmeFS+jBn8HRDf1YaSRYxzTw6uHLrPLsybfgQZVl7babMu/38Ghin0f5pz5OlNokzDxaubIYQHOZ7st7YndHJtBWWql/KualBWbMILy88dUVQBnbqQLP2P8d1ME8ILUjJVqz33HiRU0JzlEJyWfbvEjcJ6iD8M6n4nXTaxfu3i2UhhGsQ6SSBNKssMP4tji8nkNpMqG59wLQ/zhcetEm71fKkgJNrIMNllkqlWSo5K74IqqP9kiLg/qm8ipOJjui0gPk8tZXKcV+ztX1d1OVCapoLfiDM5l/0LLQXaTOXOV1x3e5LLQ/w2doNiH3eh5CV4II9dRu7owpaiiMBHMssmT0pH99jEeF6giHLKtt3y7l2GWoRLPdhsZZ54gxsaBxZt9GuypmkbNcr97CEnAVaWij5v0CF3w4rAWqy/tAxQpIDJOIOQBgmwG5WrBAKyKrFvEpBL5a8BPcRWJDvqKC83QeWpvPrEVdgJevC6ZN1MKzrb2SiPOwC2Kerc=
file: $ARTIFACT
on:
repo: hasufell/ghcup-hs
repo: haskell/ghcup-hs
tags: true
skip_cleanup: true
draft: true

View File

@@ -1,5 +1,19 @@
# Revision history for ghcup
## 0.1.0.0 -- YYYY-mm-dd
## 0.1.3 -- 2020-04-15
* Fix lesser bug when skipping ghcup update
## 0.1.2 -- 2020-04-15
* Fix bug when removing the set GHC version
* Fix use of undocumented `GHCUP_INSTALL_BASE_PREFIX` variable
* skip upgrade if ghcup is already latest version
## 0.1.1 -- 2020-04-15
* fix awful fdopendir bug on mac bug by updating hpath-posix
## 0.1.0
* First version. Released on an unsuspecting world.

45
HACKING.md Normal file
View File

@@ -0,0 +1,45 @@
# HACKING
## Design decisions
### Using [Excepts](https://hackage.haskell.org/package/haskus-utils-variant-3.0/docs/Haskus-Utils-Variant-Excepts.html) as a beefed up ExceptT
This is an open variant, similar to [plucky](https://hackage.haskell.org/package/plucky) or [oops](https://github.com/i-am-tom/oops) and allows us to combine different error types. Maybe it is too much and it's a little bit [unergonomic](https://github.com/haskus/packages/issues/32) at times. If it really hurts maintenance, it will be removed. It was more of an experiment.
### No use of filepath or directory
Filepath and directory have two fundamental problems: 1. they use String as filepath (see [AFPP](https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/abstract-file-path) as to why this is wrong) and 2. they try very hard to be cross-platform at the expense of low-level correctness. Instead, we use the [hpath](https://github.com/hasufell/hpath) libraries for file and filepath related stuff, which also gives us stronger filepath types.
### No use of haskell-TLS
I consider haskell-TLS an interesting experiment, but not a battle-tested and peer-reviewed crypto implementation. There is little to no research about what the intricacies of using haskell for low-level crypto are and how vulnerable such binaries are. Instead, we use either curl the binary (for FreeBSD and mac) or http-io-streams, which works with OpenSSL bindings.
### Optics instead of lens
They're a little safer (less Monoid weirdness with view) and have better error messages. Consider the following wit lens
```
> view (_Just . to (++ "abc")) Nothing
""
```
vs optics
```
> view (_Just % to (++ "abc")) Nothing
<interactive>:2:1: error:
• An_AffineFold cannot be used as A_Getter
• In the expression: view (_Just % to (++ "abc")) Nothing
In an equation for it: it = view (_Just % to (++ "abc")) Nothing
```
### Strict and StrictData on by default
Kazu Yamamoto [explained it in his PR](https://github.com/yesodweb/wai/pull/752#issuecomment-501531386) very well. I like to agree with him. The instances where we need non-strict behavior, we annotate it.
## Code style and formatting
1. Brittany
2. mtl-style preferred
3. no overly pointfree style

View File

@@ -25,7 +25,7 @@ Follow the instructions at [https://www.haskell.org/ghcup/](https://www.haskell.
### Manual install
Download the binary for your platform at [https://github.com/hasufell/ghcup-hs/releases](https://github.com/hasufell/ghcup-hs/releases)
Download the binary for your platform at [https://downloads.haskell.org/~ghcup/](https://downloads.haskell.org/~ghcup/)
and place it into your `PATH` anywhere.
Then adjust your `PATH` in `~/.bashrc` (or similar, depending on your shell) like so:

11
RELEASING.md Normal file
View File

@@ -0,0 +1,11 @@
# RELEASING
1. update `GHCup.Version` module. `ghcupURL` must only be updated if we change the `_toolRequirements` type or the JSON representation of it. The version of the json represents the change increments. `ghcUpVer` is the current application version.
2. Add/fix downloads to `GHCupDownloads` module, then run `ghcup-gen gen` to generate the new json and validate it via `ghcup-gen check`.
3. Commit and git push with tag. Wait for tests to succeed.
4. Upload the new `ghcup-<ver>.json` to `webhost.haskell.org/ghcup/data/`.
5. Build ghcup releases for Linux (fully static), mac (with `-fcurl`) and FreeBSD (with `-fcurl`). Upload to `webhost.haskell.org/ghcup/bin/` and update symlinks.

21
TODO.md
View File

@@ -2,23 +2,7 @@
## Now
* travis
* requirements
* for ghcup (bootstrap script)
* per tool
* mac build: xattr -cr .
* static binaries
* upgrade plan from old ghcup
* bootstrap-haskell with new ghcup
* add warning to ghcup script about new binary
* make sure smart-dl is not broken
* handle SIGINT better (remove dirs)
* review symlink handling (maybe fixed set of tools?)
* move out GHCup.Version module, bc it's not library-ish
## Maybe
@@ -28,16 +12,17 @@
## Later
* i386 support
* add support for RC/alpha/HEAD versions
## Cleanups
* too many decodeutf8
* avoid alternative for IO
* use plucky or oops instead of Excepts
## Questions
* fully static musl builds for linux?
* mirror support
* interactive handling when distro doesn't exist and we know the tarball is incompatible?
* ghcup-with wrapper to execute a command with a given ghc in PATH?

View File

@@ -984,32 +984,33 @@ cabal_3200_64_darwin = DownloadInfo
-------------
ghcup_010_64_linux :: DownloadInfo
ghcup_010_64_linux = DownloadInfo
[uri|https://www.haskell.org/ghcup/bin/0.1.0/x86_64-linux-ghcup-0.1.0|]
ghcup_012_32_linux :: DownloadInfo
ghcup_012_32_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.2/i386-linux-ghcup-0.1.2|]
Nothing
"e2e124903193551df84679887a5741021f0d67df45442c9d3d2429e83b95aad1"
"a1b3f1b62798a2b1162e7433530e697292b87a9255516d8a08e07f0708a72550"
ghcup_010_64_freebsd :: DownloadInfo
ghcup_010_64_freebsd = DownloadInfo
[uri|https://www.haskell.org/ghcup/bin/0.1.0/x86_64-portbld-freebsd-ghcup-0.1.0|]
ghcup_012_64_linux :: DownloadInfo
ghcup_012_64_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.2/x86_64-linux-ghcup-0.1.2|]
Nothing
"c6024c7f2849b6ed83cd683bb0a0e3d5b559aee3fba2ee78ada4f0c9804dbe36"
"ef8b39bacce3661efc63d43d0a926b6803497e01c13afbea3947a6d320ecacbf"
ghcup_010_64_darwin10_13 :: DownloadInfo
ghcup_010_64_darwin10_13 = DownloadInfo
[uri|https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.13-ghcup-0.1.0|]
ghcup_012_64_freebsd :: DownloadInfo
ghcup_012_64_freebsd = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.2/x86_64-portbld-freebsd-ghcup-0.1.2|]
Nothing
"39b96cd984b6e8393bcb93eaeab2f4648e7ef4e4547afe623283774643eede58"
"03407b869a860c5f6fb0b94436a4dd17f0d2937a3b6fa348f2a71f64b1daba82"
ghcup_010_64_darwin10_14 :: DownloadInfo
ghcup_010_64_darwin10_14 = DownloadInfo
[uri|https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.14-ghcup-0.1.0|]
ghcup_012_64_darwin10_13 :: DownloadInfo
ghcup_012_64_darwin10_13 = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.2/x86_64-apple-darwin-ghcup-0.1.2|]
Nothing
"adfcf500f0414951685e53f72bbc9c1e3b2f41c06e562ed3f63fbd645bf61e54"
"bea293d4a0475f853284d3bf4790565fa270922c8dae60730490dd3753a6ad63"
@@ -1876,22 +1877,19 @@ ghcupDownloads = M.fromList
)
, ( GHCup
, M.fromList
[ ( [vver|0.1.0|]
[ ( [vver|0.1.2|]
, VersionInfo [Recommended, Latest] Nothing $ M.fromList
[ ( A_64
, M.fromList
[ (Linux UnknownLinux, M.fromList [(Nothing, ghcup_010_64_linux)])
, ( Darwin
, M.fromList
[ (Nothing , ghcup_010_64_darwin10_13)
, (Just [vers|10.13|], ghcup_010_64_darwin10_13)
, (Just [vers|10.14|], ghcup_010_64_darwin10_14)
, (Just [vers|10.15|], ghcup_010_64_darwin10_14)
]
)
, (FreeBSD, M.fromList [(Nothing, ghcup_010_64_freebsd)])
[ (Linux UnknownLinux, M.fromList [(Nothing, ghcup_012_64_linux)])
, (Darwin, M.fromList [(Nothing, ghcup_012_64_darwin10_13)])
, (FreeBSD, M.fromList [(Nothing, ghcup_012_64_freebsd)])
]
)
, ( A_32
, M.fromList
[(Linux UnknownLinux, M.fromList [(Nothing, ghcup_012_32_linux)])]
)
]
)
]

View File

@@ -1,10 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
module Main where
@@ -14,7 +15,7 @@ import GHCup.Types.JSON ( )
import GHCup.Utils.Logger
import GHCupInfo
import Data.Aeson ( eitherDecode )
import Data.Aeson ( eitherDecode, encode )
import Data.Aeson.Encode.Pretty
#if !MIN_VERSION_base(4,13,0)
import Data.Semigroup ( (<>) )
@@ -61,10 +62,13 @@ outputP = fileOutput <|> stdOutput
data GenJSONOpts = GenJSONOpts
{ output :: Maybe Output
, pretty :: Bool
}
genJSONOpts :: Parser GenJSONOpts
genJSONOpts = GenJSONOpts <$> optional outputP
genJSONOpts = GenJSONOpts <$> optional outputP <*> switch
(short 'p' <> long "pretty" <> help "Make JSON output pretty (human readable)"
)
data Input
@@ -134,14 +138,16 @@ main = do
customExecParser (prefs showHelpOnError) (info (opts <**> helper) idm)
>>= \Options {..} -> case optCommand of
GenJSON gopts -> do
let
bs = encodePretty' (defConfig { confIndent = Spaces 2 })
ghcupInfo
let bs True =
encodePretty' (defConfig { confIndent = Spaces 2 }) ghcupInfo
bs False = encode ghcupInfo
case gopts of
GenJSONOpts { output = Nothing } -> L.hPutStr stdout bs
GenJSONOpts { output = Just StdOutput } -> L.hPutStr stdout bs
GenJSONOpts { output = Just (FileOutput file) } ->
L.writeFile file bs
GenJSONOpts { output = Nothing, pretty } ->
L.hPutStr stdout (bs pretty)
GenJSONOpts { output = Just StdOutput, pretty } ->
L.hPutStr stdout (bs pretty)
GenJSONOpts { output = Just (FileOutput file), pretty } ->
L.writeFile file (bs pretty)
ValidateJSON vopts -> case vopts of
ValidateJSONOpts { input = Nothing } ->
L.getContents >>= valAndExit validate
@@ -165,4 +171,3 @@ main = do
Left e -> die (color Red $ show e)
myLoggerT (LoggerConfig True (B.hPut stdout) (\_ -> pure ())) (f av)
>>= exitWith

View File

@@ -80,7 +80,7 @@ data Command
| Rm RmOptions
| DInfo
| Compile CompileCommand
| Upgrade UpgradeOpts
| Upgrade UpgradeOpts Bool
| NumericVersion
| ToolRequirements
@@ -194,9 +194,12 @@ com =
)
<> command
"upgrade"
( Upgrade
<$> (info (upgradeOptsP <**> helper) (progDesc "Upgrade ghcup"))
)
(info ((Upgrade <$> upgradeOptsP <*>
switch
(short 'f' <> long "force" <> help
"Force update"
)
) <**> helper) (progDesc "Upgrade ghcup"))
<> command
"compile"
( Compile
@@ -626,6 +629,7 @@ main = do
, NoCompatiblePlatform
, NoCompatibleArch
, NoDownload
, NoUpdate
, FileDoesNotExistError
, CopyError
, DownloadFailed
@@ -770,7 +774,7 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues
VLeft e ->
runLogger ($(logError) [i|#{e}|]) >> exitFailure
Upgrade (uOpts) -> do
Upgrade (uOpts) force -> do
target <- case uOpts of
UpgradeInplace -> do
efp <- liftIO $ getExecutablePath
@@ -783,7 +787,7 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues
void
$ (runUpgrade $ do
liftE $ upgradeGHCup dls target
liftE $ upgradeGHCup dls target force
)
>>= \case
VRight v' -> do
@@ -791,6 +795,9 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues
runLogger
$ $(logInfo)
[i|Successfully upgraded GHCup to version #{pretty_v}|]
VLeft (V NoUpdate) ->
runLogger $ $(logWarn)
[i|No GHCup update available|]
VLeft e ->
runLogger ($(logError) [i|#{e}|]) >> exitFailure

View File

@@ -27,31 +27,42 @@ download_ghcup() {
_plat="$(uname -s)"
_arch=$(uname -m)
case "${_arch}" in
x86_64|amd64)
;;
i*86)
die "i386 currently not supported!"
;;
*) die "Unknown architecture: ${_arch}"
;;
esac
case "${_plat}" in
"linux"|"Linux")
_url=https://www.haskell.org/ghcup/bin/x86_64-linux-ghcup
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")
_url=https://www.haskell.org/ghcup/bin/x86_64-portbld-freebsd-ghcup
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 "$(sw_vers -productVersion || echo "none")" in
10.15.*) _url=https://www.haskell.org/ghcup/bin/x86_64-apple-darwin-10.14-ghcup ;;
10.14.*) _url=https://www.haskell.org/ghcup/bin/x86_64-apple-darwin-10.14-ghcup ;;
10.13.*) _url=https://www.haskell.org/ghcup/bin/x86_64-apple-darwin-10.13-ghcup ;;
*) _url=https://www.haskell.org/ghcup/bin/x86_64-apple-darwin-10.13-ghcup ;;
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

0
foo
View File

View File

@@ -2113,43 +2113,37 @@
}
},
"GHCup": {
"0.1.0": {
"0.1.2": {
"viArch": {
"A_64": {
"FreeBSD": {
"unknown_versioning": {
"dlHash": "c6024c7f2849b6ed83cd683bb0a0e3d5b559aee3fba2ee78ada4f0c9804dbe36",
"dlHash": "03407b869a860c5f6fb0b94436a4dd17f0d2937a3b6fa348f2a71f64b1daba82",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-portbld-freebsd-ghcup-0.1.0"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.2/x86_64-portbld-freebsd-ghcup-0.1.2"
}
},
"Darwin": {
"unknown_versioning": {
"dlHash": "39b96cd984b6e8393bcb93eaeab2f4648e7ef4e4547afe623283774643eede58",
"dlHash": "bea293d4a0475f853284d3bf4790565fa270922c8dae60730490dd3753a6ad63",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.13-ghcup-0.1.0"
},
"10.14": {
"dlHash": "adfcf500f0414951685e53f72bbc9c1e3b2f41c06e562ed3f63fbd645bf61e54",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.14-ghcup-0.1.0"
},
"10.13": {
"dlHash": "39b96cd984b6e8393bcb93eaeab2f4648e7ef4e4547afe623283774643eede58",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.13-ghcup-0.1.0"
},
"10.15": {
"dlHash": "adfcf500f0414951685e53f72bbc9c1e3b2f41c06e562ed3f63fbd645bf61e54",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-apple-darwin-10.14-ghcup-0.1.0"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.2/x86_64-apple-darwin-ghcup-0.1.2"
}
},
"Linux_UnknownLinux": {
"unknown_versioning": {
"dlHash": "e2e124903193551df84679887a5741021f0d67df45442c9d3d2429e83b95aad1",
"dlHash": "ef8b39bacce3661efc63d43d0a926b6803497e01c13afbea3947a6d320ecacbf",
"dlSubdir": null,
"dlUri": "https://www.haskell.org/ghcup/bin/0.1.0/x86_64-linux-ghcup-0.1.0"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.2/x86_64-linux-ghcup-0.1.2"
}
}
},
"A_32": {
"Linux_UnknownLinux": {
"unknown_versioning": {
"dlHash": "a1b3f1b62798a2b1162e7433530e697292b87a9255516d8a08e07f0708a72550",
"dlSubdir": null,
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.2/i386-linux-ghcup-0.1.2"
}
}
}

View File

@@ -1,13 +1,13 @@
cabal-version: 3.0
name: ghcup
version: 0.1.0
version: 0.1.3
synopsis: ghc toolchain installer as an exe/library
description:
A rewrite of the shell script ghcup, for providing
a more stable user experience and exposing an API.
homepage: https://github.com/hasufell/ghcup-hs
bug-reports: https://github.com/hasufell/ghcup-hs/issues
homepage: https://gitlab.haskell.org/haskell/ghcup-hs
bug-reports: https://gitlab.haskell.org/haskell/ghcup-hs/issues
license: LGPL-3.0-only
license-file: LICENSE
author: Julian Ospald
@@ -19,7 +19,7 @@ extra-source-files: CHANGELOG.md
source-repository head
type: git
location: https://github.com/hasufell/ghcup-hs
location: https://gitlab.haskell.org/haskell/ghcup-hs.git
flag Curl
description: Use curl instead of http-io-streams for download
@@ -84,7 +84,7 @@ common hpath
build-depends: hpath >=0.11
common hpath-directory
build-depends: hpath-directory >=0.13.2
build-depends: hpath-directory >=0.13.3
common hpath-filepath
build-depends: hpath-filepath >=0.10.3
@@ -93,7 +93,7 @@ common hpath-io
build-depends: hpath-io >=0.13.1
common hpath-posix
build-depends: hpath-posix >=0.11.1
build-depends: hpath-posix >=0.13.2
common http-io-streams
build-depends: http-io-streams >=0.1.2.0

View File

@@ -53,6 +53,7 @@ import Prelude hiding ( abs
)
import System.IO.Error
import System.Posix.FilePath ( getSearchPath )
import System.Posix.Files.ByteString
import qualified Data.ByteString as B
import qualified Data.Map.Strict as Map
@@ -375,6 +376,10 @@ rmGHCVer ver = do
if exists
then do
-- this isn't atomic, order matters
when isSetGHC $ do
lift $ $(logInfo) [i|Removing ghc symlinks|]
liftE $ rmPlain ver
lift $ $(logInfo) [i|Removing directory recursively: #{d'}|]
liftIO $ deleteDirRecursive dir
@@ -388,11 +393,6 @@ rmGHCVer ver = do
(mj, mi) <- getGHCMajor ver
getGHCForMajor mj mi >>= mapM_ (\v -> liftE $ setGHC v SetGHC_XY)
when isSetGHC $ do
lift $ $(logInfo) [i|Removing ghc symlinks|]
liftE $ rmPlain ver
liftIO
$ ghcupBaseDir
>>= hideError doesNotExistErrorType
@@ -675,6 +675,8 @@ upgradeGHCup :: ( MonadMask m
)
=> GHCupDownloads
-> Maybe (Path Abs) -- ^ full file destination to write ghcup into
-> Bool -- ^ whether to force update regardless
-- of currently installed version
-> Excepts
'[ CopyError
, DigestError
@@ -683,17 +685,24 @@ upgradeGHCup :: ( MonadMask m
, NoCompatibleArch
, NoCompatiblePlatform
, NoDownload
, NoUpdate
]
m
Version
upgradeGHCup dls mtarget = do
upgradeGHCup dls mtarget force = do
lift $ $(logInfo) [i|Upgrading GHCup...|]
let latestVer = fromJust $ getLatest dls GHCup
when (not force && (latestVer <= pvpToVersion ghcUpVer)) $ throwE NoUpdate
pfreq <- liftE platformRequest
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
tmp <- lift withGHCupTmpDir
let fn = [rel|ghcup|]
p <- liftE $ download dli tmp (Just fn)
let fileMode' =
newFilePerms
`unionFileModes` ownerExecuteMode
`unionFileModes` groupExecuteMode
`unionFileModes` otherExecuteMode
case mtarget of
Nothing -> do
dest <- liftIO $ ghcupBinDir
@@ -701,11 +710,13 @@ upgradeGHCup dls mtarget = do
handleIO (throwE . CopyError . show) $ liftIO $ copyFile p
(dest </> fn)
Overwrite
liftIO $ setFileMode (toFilePath (dest </> fn)) fileMode'
Just fullDest -> do
liftIO $ hideError NoSuchThing $ deleteFile fullDest
handleIO (throwE . CopyError . show) $ liftIO $ copyFile p
fullDest
Overwrite
liftIO $ setFileMode (toFilePath fullDest) fileMode'
pure latestVer

View File

@@ -30,6 +30,10 @@ data NoCompatiblePlatform = NoCompatiblePlatform String -- the platform we got
data NoDownload = NoDownload
deriving Show
-- | No update available or necessary.
data NoUpdate = NoUpdate
deriving Show
-- | The Architecture is unknown and unsupported.
data NoCompatibleArch = NoCompatibleArch String
deriving Show

View File

@@ -39,11 +39,10 @@ import qualified System.Posix.User as PU
ghcupBaseDir :: IO (Path Abs)
ghcupBaseDir = do
getEnv "GHCUP_INSTALL_BASE_PREFIX" >>= \case
bdir <- getEnv "GHCUP_INSTALL_BASE_PREFIX" >>= \case
Just r -> parseAbs r
Nothing -> do
home <- liftIO getHomeDirectory
pure (home </> [rel|.ghcup|])
Nothing -> liftIO getHomeDirectory
pure (bdir </> [rel|.ghcup|])
ghcupGHCBaseDir :: IO (Path Abs)
ghcupGHCBaseDir = ghcupBaseDir <&> (</> [rel|ghc|])

View File

@@ -240,3 +240,7 @@ addToCurrentEnv :: MonadIO m
addToCurrentEnv adds = do
cEnv <- liftIO $ getEnvironment
pure (adds ++ cEnv)
pvpToVersion :: PVP -> Version
pvpToVersion = either (\_ -> error "Couldn't convert PVP to Version") id . version . prettyPVP

View File

@@ -14,4 +14,4 @@ ghcupURL :: URI
ghcupURL = [uri|https://www.haskell.org/ghcup/data/ghcup-0.0.1.json|]
ghcUpVer :: PVP
ghcUpVer = [pver|0.1.0|]
ghcUpVer = [pver|0.1.3|]