Compare commits

..

14 Commits

Author SHA1 Message Date
b5440fc7d2 Fix bug in installCabalBin 2020-07-21 23:10:47 +02:00
4b21adadf1 Release 0.1.8 2020-07-21 22:47:21 +02:00
78ae77780b Fix bug in logging thread
It would die on newlines due to empty String blindness.
Also make sure takeMVar does not block.
2020-07-21 22:43:09 +02:00
ccb95bcbee f custom 2020-07-21 22:42:39 +02:00
21ac670bbe Update FreeBSD bindist 2020-07-21 21:08:41 +02:00
8b54dee66c Merge branch 'CI-m' 2020-07-21 20:21:53 +02:00
dad926f3ba Allow to specify custom bindist, fixes #14 2020-07-21 20:19:33 +02:00
a298d949b5 Remove FreeBSD workaround in CI 2020-07-21 19:00:10 +02:00
e1cf11f9d4 Add Alpine GHC 8.4.4 for 64bit 2020-07-21 01:18:03 +02:00
97cd43792d Set 8.8.4 as recommended GHC version 2020-07-21 00:31:02 +02:00
08693e6d3a Add more alpine bindists 2020-07-21 00:29:46 +02:00
e2227da8d2 Update ghcup binaries 2020-07-21 00:02:14 +02:00
5f20e4c583 Bump versions in CI 2020-07-20 23:57:26 +02:00
f82f1a12dd Update version in bootstrap-script 2020-07-20 23:04:11 +02:00
11 changed files with 253 additions and 118 deletions

View File

@@ -113,7 +113,7 @@ test:linux:latest:
test:mac:recommended:
extends: .test_ghcup_version:darwin
variables:
GHC_VERSION: "8.8.3"
GHC_VERSION: "8.8.4"
CABAL_VERSION: "3.2.0.0"
test:mac:latest:
@@ -129,7 +129,7 @@ test:mac:latest:
test:freebsd:recommended:
extends: .test_ghcup_version:freebsd
variables:
GHC_VERSION: "8.8.3"
GHC_VERSION: "8.8.4"
CABAL_VERSION: "3.2.0.0"
test:freebsd:latest:
@@ -162,7 +162,7 @@ release:linux:32bit:
- ./.gitlab/before_script/linux/alpine/install_deps.sh
variables:
ARTIFACT: "i386-linux-ghcup"
GHC_VERSION: "8.6.5"
GHC_VERSION: "8.8.4"
CABAL_VERSION: "3.2.0.0"

View File

@@ -44,12 +44,6 @@ ghcup-gen check -f ghcup-${JSON_VERSION}.json
eghcup --numeric-version
# TODO: rm once we have tarballs
if [ "${OS}" = "FREEBSD" ] ; then
GHC_VERSION=8.6.3
CABAL_VERSION=2.4.1.0
fi
eghcup install ${GHC_VERSION}
eghcup set ${GHC_VERSION}
eghcup install-cabal ${CABAL_VERSION}

View File

@@ -1,5 +1,10 @@
# Revision history for ghcup
## 0.1.8 -- 2020-07-21
* Fix bug in logging thread dying on newlines
* Allow to install from arbitrary bindists: `ghcup -n install ghc -u '{"dlHash": "", "dlSubdir": "ghc-8.10.1", "dlUri": "https://github.com/commercialhaskell/ghc/releases/download/ghc-8.10.1-release/ghc-8.10.1-x86_64-deb9-linux.tar.xz"}' 8.10.1`
## 0.1.7 -- 2020-07-20
* Fix a bug in libarchive not unpacking some uncleanly packed bindists

View File

@@ -38,6 +38,7 @@ import Control.Monad.Fail ( MonadFail )
import Control.Monad.Logger
import Control.Monad.Reader
import Control.Monad.Trans.Resource
import Data.Aeson ( eitherDecode )
import Data.Bifunctor
import Data.Char
import Data.Either
@@ -68,6 +69,7 @@ import URI.ByteString
import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as UTF8
import qualified Data.ByteString.Lazy.UTF8 as BLU
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as E
@@ -119,6 +121,7 @@ data InstallCommand = InstallGHC InstallOptions
data InstallOptions = InstallOptions
{ instVer :: Maybe ToolVersion
, instPlatform :: Maybe PlatformRequest
, instBindist :: Maybe DownloadInfo
}
data SetCommand = SetGHC SetOptions
@@ -405,7 +408,7 @@ installParser =
installOpts :: Parser InstallOptions
installOpts =
(flip InstallOptions)
(\p u v -> InstallOptions v p u)
<$> (optional
(option
(eitherReader platformParser)
@@ -417,6 +420,17 @@ installOpts =
)
)
)
<*> (optional
(option
(eitherReader bindistParser)
( short 'u'
<> long "url"
<> metavar "BINDIST_URL"
<> help
"Provide DownloadInfo as json string, e.g.: '{ \"dlHash\": \"<sha256 hash>\", \"dlSubdir\": \"ghc-<ver>\", \"dlUri\": \"<uri>\" }'"
)
)
)
<*> optional toolVersionArgument
@@ -800,6 +814,8 @@ platformParser s' = case MP.parse (platformP <* MP.eof) "" (T.pack s') of
pure v
bindistParser :: String -> Either String DownloadInfo
bindistParser = eitherDecode . BLU.fromString
toSettings :: Options -> Settings
@@ -1047,7 +1063,9 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
let installGHC InstallOptions{..} =
(runInstTool $ do
v <- liftE $ fromVersion dls instVer GHC
liftE $ installGHCBin dls (_tvVersion v) (fromMaybe pfreq instPlatform) -- FIXME: ugly sharing of tool version
case instBindist of
Nothing -> liftE $ installGHCBin dls (_tvVersion v) (fromMaybe pfreq instPlatform)
Just uri -> liftE $ installGHCBindist uri (_tvVersion v) (fromMaybe pfreq instPlatform)
)
>>= \case
VRight _ -> do
@@ -1081,7 +1099,9 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
let installCabal InstallOptions{..} =
(runInstTool $ do
v <- liftE $ fromVersion dls instVer Cabal
liftE $ installCabalBin dls (_tvVersion v) (fromMaybe pfreq instPlatform) -- FIXME: ugly sharing of tool version
case instBindist of
Nothing -> liftE $ installCabalBin dls (_tvVersion v) (fromMaybe pfreq instPlatform)
Just uri -> liftE $ installCabalBindist uri (_tvVersion v) (fromMaybe pfreq instPlatform)
)
>>= \case
VRight _ -> do

View File

@@ -28,7 +28,7 @@ eghcup() {
download_ghcup() {
_plat="$(uname -s)"
_arch=$(uname -m)
_ghver="0.1.6"
_ghver="0.1.7"
_base_url="https://downloads.haskell.org/~ghcup"
case "${_plat}" in

View File

@@ -214,7 +214,7 @@
"A_64": {
"Linux_Alpine": {
"unknown_versioning": {
"dlHash": "325b48b2ea199b4f62c16dc9c3ff99b42ea6bb1dde5a74fa640dfeb8d63894d0",
"dlHash": "517783b660a27ebf95b2568d47292fd633d5f9a4de4c80ad1ccf05e1b9d7313f",
"dlSubdir": "ghc-8.0.2",
"dlUri": "https://files.hasufell.de/ghc/ghc-8.0.2-x86_64-alpine-linux.tar.xz"
}
@@ -744,6 +744,13 @@
}
},
"A_32": {
"Linux_Alpine": {
"unknown_versioning": {
"dlHash": "7360cc6b29e9b4ab08f6ea5bc3bcca6f5c216933e81ef1620dcdd700f1fdb289",
"dlSubdir": "ghc-8.10.1",
"dlUri": "https://files.hasufell.de/ghc/ghc-8.10.1-i386-alpine-linux.tar.xz"
}
},
"Linux_Debian": {
"unknown_versioning": {
"dlHash": "8b53eef2c827b5f634d72920a93c0c9dd66ea288691a2bfe28def45d3c686ee2",
@@ -1263,6 +1270,13 @@
}
},
"A_32": {
"Linux_Alpine": {
"unknown_versioning": {
"dlHash": "1d18e89ee031197e55c48683e78a7ffc67601ac5fd9f73aac555eb064b3859a2",
"dlSubdir": "ghc-8.8.4",
"dlUri": "https://files.hasufell.de/ghc/ghc-8.8.4-i386-alpine-linux.tar.xz"
}
},
"Linux_Debian": {
"unknown_versioning": {
"dlHash": "43dd954910c9027694312cef0aabc7774d102d0422b7172802cfb72f7d5da3a0",
@@ -1300,6 +1314,7 @@
},
"viChangeLog": "https://downloads.haskell.org/~ghc/8.8.4/docs/html/users_guide/8.8.4-notes.html",
"viTags": [
"Recommended",
"base-4.13.0.0"
]
},
@@ -1762,6 +1777,13 @@
"8.2.2": {
"viArch": {
"A_64": {
"Linux_Alpine": {
"unknown_versioning": {
"dlHash": "adcf3a320a3c402aba07ae9586990dc3c0b550e96aeffb1b9e194313d3ba716d",
"dlSubdir": "ghc-8.2.2",
"dlUri": "https://files.hasufell.de/ghc/ghc-8.2.2-x86_64-alpine-linux.tar.xz"
}
},
"FreeBSD": {
"unknown_versioning": {
"dlHash": "cd351c704b92b9af23994024df07de8ca7090ea7675d5c8b14b2be857a46d804",
@@ -1876,6 +1898,13 @@
"8.4.4": {
"viArch": {
"A_64": {
"Linux_Alpine": {
"unknown_versioning": {
"dlHash": "336affff8314d3dc5e85d9c09015ae2ba8a7658b459c8c8ae77ecaa551a56ae7",
"dlSubdir": "ghc-8.4.4",
"dlUri": "https://files.hasufell.de/ghc/ghc-8.4.4-x86_64-alpine-linux.tar.xz"
}
},
"FreeBSD": {
"unknown_versioning": {
"dlHash": "44fbd142d1c355d6110595c59c760e2c73866ff9259ec85ebf814edb244d1940",
@@ -2137,7 +2166,6 @@
},
"viChangeLog": "https://downloads.haskell.org/~ghc/8.8.3/docs/html/users_guide/8.8.3-notes.html",
"viTags": [
"Recommended",
"base-4.13.0.0"
]
}
@@ -2312,37 +2340,37 @@
}
},
"GHCup": {
"0.1.6": {
"0.1.7": {
"viArch": {
"A_64": {
"FreeBSD": {
"unknown_versioning": {
"dlHash": "6bbfb1047691ff3ae9249e8805cf9f37bab30a008dae130cb2a4b3aa5253e6e5",
"dlHash": "54b9b6f98908f6679dda6db025b4047dfe82e6b57ae82c547a9d611b9e4ff105",
"dlSubdir": null,
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.6/x86_64-portbld-freebsd-ghcup-0.1.6"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.7/x86_64-portbld-freebsd-ghcup-0.1.7"
}
},
"Darwin": {
"unknown_versioning": {
"dlHash": "1e025e66d7f7b75d94f17a7da6120efd7e2df918a8eac88c4711ed11d2aac4ec",
"dlHash": "00b2c04755d2b40e568afbfc2a485c36697fc55f210eae0d4cd80413c71032ed",
"dlSubdir": null,
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.6/x86_64-apple-darwin-ghcup-0.1.6"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.7/x86_64-apple-darwin-ghcup-0.1.7"
}
},
"Linux_UnknownLinux": {
"unknown_versioning": {
"dlHash": "bdbec0cdf4c8511c4082dd83993d15034c0fbcb5722ecf418c1cee40667da8af",
"dlHash": "a1d1e8b3c2b00186957c927d09f2cfb457bbfa65c1ab562ff5683963e205bdd5",
"dlSubdir": null,
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.6/x86_64-linux-ghcup-0.1.6"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.7/x86_64-linux-ghcup-0.1.7"
}
}
},
"A_32": {
"Linux_UnknownLinux": {
"unknown_versioning": {
"dlHash": "0366ed6c00862c3c002cdefc3e37523ad80e655387956c7ab58b268aaa6fae5d",
"dlHash": "1651cc196e4fdd18995054edebe109833535961f0e2b0d505f1714e83f3e8808",
"dlSubdir": null,
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.6/i386-linux-ghcup-0.1.6"
"dlUri": "https://downloads.haskell.org/~ghcup/0.1.7/i386-linux-ghcup-0.1.7"
}
}
}

View File

@@ -1,6 +1,6 @@
cabal-version: 3.0
name: ghcup
version: 0.1.7
version: 0.1.8
synopsis: ghc toolchain installer as an exe/library
description:
A rewrite of the shell script ghcup, for providing
@@ -341,6 +341,7 @@ executable ghcup
import:
config
, base
, aeson
, bytestring
, containers
, haskus-utils-variant

View File

@@ -77,7 +77,7 @@ import qualified Data.Text.Encoding as E
installGHCBin :: ( MonadFail m
installGHCBindist :: ( MonadFail m
, MonadMask m
, MonadCatch m
, MonadReader Settings m
@@ -85,7 +85,7 @@ installGHCBin :: ( MonadFail m
, MonadResource m
, MonadIO m
)
=> GHCupDownloads
=> DownloadInfo
-> Version
-> PlatformRequest
-> Excepts
@@ -102,14 +102,13 @@ installGHCBin :: ( MonadFail m
]
m
()
installGHCBin bDls ver pfreq@(PlatformRequest {..}) = do
installGHCBindist dlinfo ver (PlatformRequest {..}) = do
let tver = (mkTVer ver)
lift $ $(logDebug) [i|Requested to install GHC with #{ver}|]
whenM (liftIO $ ghcInstalled tver)
$ (throwE $ AlreadyInstalled GHC ver)
-- download (or use cached version)
dlinfo <- lE $ getDownloadInfo GHC ver pfreq bDls
dl <- liftE $ downloadCached dlinfo Nothing
-- unpack
@@ -150,32 +149,62 @@ installGHCBin bDls ver pfreq@(PlatformRequest {..}) = do
| otherwise = []
installCabalBin :: ( MonadMask m
, MonadCatch m
, MonadReader Settings m
, MonadLogger m
, MonadResource m
, MonadIO m
, MonadFail m
)
=> GHCupDownloads
-> Version
-> PlatformRequest
-> Excepts
'[ AlreadyInstalled
, CopyError
, DigestError
, DownloadFailed
, NoDownload
, NotInstalled
, UnknownArchive
installGHCBin :: ( MonadFail m
, MonadMask m
, MonadCatch m
, MonadReader Settings m
, MonadLogger m
, MonadResource m
, MonadIO m
)
=> GHCupDownloads
-> Version
-> PlatformRequest
-> Excepts
'[ AlreadyInstalled
, BuildFailed
, DigestError
, DownloadFailed
, NoDownload
, NotInstalled
, UnknownArchive
#if !defined(TAR)
, ArchiveResult
, ArchiveResult
#endif
]
m
()
installCabalBin bDls ver pfreq@(PlatformRequest {..}) = do
]
m
()
installGHCBin bDls ver pfreq = do
dlinfo <- lE $ getDownloadInfo GHC ver pfreq bDls
installGHCBindist dlinfo ver pfreq
installCabalBindist :: ( MonadMask m
, MonadCatch m
, MonadReader Settings m
, MonadLogger m
, MonadResource m
, MonadIO m
, MonadFail m
)
=> DownloadInfo
-> Version
-> PlatformRequest
-> Excepts
'[ AlreadyInstalled
, CopyError
, DigestError
, DownloadFailed
, NoDownload
, NotInstalled
, UnknownArchive
#if !defined(TAR)
, ArchiveResult
#endif
]
m
()
installCabalBindist dlinfo ver (PlatformRequest {..}) = do
lift $ $(logDebug) [i|Requested to install cabal version #{ver}|]
bindir <- liftIO ghcupBinDir
@@ -190,7 +219,6 @@ installCabalBin bDls ver pfreq@(PlatformRequest {..}) = do
$ (throwE $ AlreadyInstalled Cabal ver)
-- download (or use cached version)
dlinfo <- lE $ getDownloadInfo Cabal ver pfreq bDls
dl <- liftE $ downloadCached dlinfo Nothing
-- unpack
@@ -227,6 +255,37 @@ installCabalBin bDls ver pfreq@(PlatformRequest {..}) = do
Overwrite
installCabalBin :: ( MonadMask m
, MonadCatch m
, MonadReader Settings m
, MonadLogger m
, MonadResource m
, MonadIO m
, MonadFail m
)
=> GHCupDownloads
-> Version
-> PlatformRequest
-> Excepts
'[ AlreadyInstalled
, CopyError
, DigestError
, DownloadFailed
, NoDownload
, NotInstalled
, UnknownArchive
#if !defined(TAR)
, ArchiveResult
#endif
]
m
()
installCabalBin bDls ver pfreq = do
dlinfo <- lE $ getDownloadInfo Cabal ver pfreq bDls
installCabalBindist dlinfo ver pfreq
---------------------
--[ Set GHC/cabal ]--

View File

@@ -110,7 +110,7 @@ ghc_802_64_alpine :: DownloadInfo
ghc_802_64_alpine = DownloadInfo
[uri|https://files.hasufell.de/ghc/ghc-8.0.2-x86_64-alpine-linux.tar.xz|]
(Just [rel|ghc-8.0.2|])
"325b48b2ea199b4f62c16dc9c3ff99b42ea6bb1dde5a74fa640dfeb8d63894d0"
"517783b660a27ebf95b2568d47292fd633d5f9a4de4c80ad1ccf05e1b9d7313f"
ghc_802_32_alpine :: DownloadInfo
ghc_802_32_alpine = DownloadInfo
@@ -180,6 +180,13 @@ ghc_822_32_alpine = DownloadInfo
(Just [rel|ghc-8.2.2|])
"467534c32552cfd318753112dbc70af003693aad4b0081f2a07e61f5b5ea2c22"
ghc_822_64_alpine :: DownloadInfo
ghc_822_64_alpine = DownloadInfo
[uri|https://files.hasufell.de/ghc/ghc-8.2.2-x86_64-alpine-linux.tar.xz|]
(Just [rel|ghc-8.2.2|])
"adcf3a320a3c402aba07ae9586990dc3c0b550e96aeffb1b9e194313d3ba716d"
-----------------
@@ -358,6 +365,12 @@ ghc_844_32_alpine = DownloadInfo
(Just [rel|ghc-8.4.4|])
"892888d388ef5c9cadf5cfba1146d62237c25b9b066fb62fee940b2b285fd308"
ghc_844_64_alpine :: DownloadInfo
ghc_844_64_alpine = DownloadInfo
[uri|https://files.hasufell.de/ghc/ghc-8.4.4-x86_64-alpine-linux.tar.xz|]
(Just [rel|ghc-8.4.4|])
"336affff8314d3dc5e85d9c09015ae2ba8a7658b459c8c8ae77ecaa551a56ae7"
-----------------
@@ -782,6 +795,13 @@ ghc_884_64_alpine = DownloadInfo
(Just [rel|ghc-8.8.4|])
"90c6a1661de7f20c7d169cd6270125035b3332063e45103ce028df0beecf434e"
ghc_884_32_alpine :: DownloadInfo
ghc_884_32_alpine = DownloadInfo
[uri|https://files.hasufell.de/ghc/ghc-8.8.4-i386-alpine-linux.tar.xz|]
(Just [rel|ghc-8.8.4|])
"1d18e89ee031197e55c48683e78a7ffc67601ac5fd9f73aac555eb064b3859a2"
-----------------
@@ -838,12 +858,17 @@ ghc_8101_64_alpine = DownloadInfo
(Just [rel|ghc-8.10.1-x86_64-unknown-linux|])
"cb13b645d103e2fba2eb8dfcc4e5f2fbd9550c00c4df42f342b4210436dcb8a8"
ghc_8101_32_alpine :: DownloadInfo
ghc_8101_32_alpine = DownloadInfo
[uri|https://files.hasufell.de/ghc/ghc-8.10.1-i386-alpine-linux.tar.xz|]
(Just [rel|ghc-8.10.1|])
"7360cc6b29e9b4ab08f6ea5bc3bcca6f5c216933e81ef1620dcdd700f1fdb289"
ghc_8101_64_freebsd :: DownloadInfo
ghc_8101_64_freebsd = DownloadInfo
[uri|https://downloads.haskell.org/ghc/8.10.1/ghc-8.10.1-x86_64-portbld-freebsd.tar.xz|]
[uri|https://files.hasufell.de/ghc/ghc-8.10.1-x86_64-portbld-freebsd.tar.xz|]
(Just [rel|ghc-8.10.1|])
"52d27dbf9de82005dde9bfc521bff612e381b5228af194259c2306d2b75825c2"
"e8646ec9b60fd40aa9505ee055f22f04601290ab7a1342c2cf37c34de9d3f142"
@@ -977,32 +1002,32 @@ cabal_3200_64_alpine = DownloadInfo
-------------
ghcup_016_32_linux :: DownloadInfo
ghcup_016_32_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.6/i386-linux-ghcup-0.1.6|]
ghcup_017_32_linux :: DownloadInfo
ghcup_017_32_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.7/i386-linux-ghcup-0.1.7|]
Nothing
"0366ed6c00862c3c002cdefc3e37523ad80e655387956c7ab58b268aaa6fae5d"
"1651cc196e4fdd18995054edebe109833535961f0e2b0d505f1714e83f3e8808"
ghcup_016_64_linux :: DownloadInfo
ghcup_016_64_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.6/x86_64-linux-ghcup-0.1.6|]
ghcup_017_64_linux :: DownloadInfo
ghcup_017_64_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.7/x86_64-linux-ghcup-0.1.7|]
Nothing
"bdbec0cdf4c8511c4082dd83993d15034c0fbcb5722ecf418c1cee40667da8af"
"a1d1e8b3c2b00186957c927d09f2cfb457bbfa65c1ab562ff5683963e205bdd5"
ghcup_016_64_freebsd :: DownloadInfo
ghcup_016_64_freebsd = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.6/x86_64-portbld-freebsd-ghcup-0.1.6|]
ghcup_017_64_freebsd :: DownloadInfo
ghcup_017_64_freebsd = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.7/x86_64-portbld-freebsd-ghcup-0.1.7|]
Nothing
"6bbfb1047691ff3ae9249e8805cf9f37bab30a008dae130cb2a4b3aa5253e6e5"
"54b9b6f98908f6679dda6db025b4047dfe82e6b57ae82c547a9d611b9e4ff105"
ghcup_016_64_darwin10_13 :: DownloadInfo
ghcup_016_64_darwin10_13 = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.6/x86_64-apple-darwin-ghcup-0.1.6|]
ghcup_017_64_darwin10_13 :: DownloadInfo
ghcup_017_64_darwin10_13 = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/0.1.7/x86_64-apple-darwin-ghcup-0.1.7|]
Nothing
"1e025e66d7f7b75d94f17a7da6120efd7e2df918a8eac88c4711ed11d2aac4ec"
"00b2c04755d2b40e568afbfc2a485c36697fc55f210eae0d4cd80413c71032ed"
@@ -1141,6 +1166,7 @@ ghcupDownloads = M.fromList
, (Just [vers|11|], ghc_822_64_freebsd11)
]
)
, (Linux Alpine , M.fromList [(Nothing, ghc_822_64_alpine)])
]
)
, ( A_32
@@ -1332,6 +1358,7 @@ ghcupDownloads = M.fromList
)
, (Darwin , M.fromList [(Nothing, ghc_844_64_darwin)])
, (FreeBSD , M.fromList [(Nothing, ghc_844_64_freebsd)])
, (Linux Alpine, M.fromList [(Nothing, ghc_844_64_alpine)])
]
)
, ( A_32
@@ -1698,7 +1725,7 @@ ghcupDownloads = M.fromList
)
, ( [vver|8.8.3|]
, VersionInfo
[Recommended, Base [pver|4.13.0.0|]]
[Base [pver|4.13.0.0|]]
(Just
[uri|https://downloads.haskell.org/~ghc/8.8.3/docs/html/users_guide/8.8.3-notes.html|]
)
@@ -1751,7 +1778,7 @@ ghcupDownloads = M.fromList
)
, ( [vver|8.8.4|]
, VersionInfo
[Base [pver|4.13.0.0|]]
[Recommended, Base [pver|4.13.0.0|]]
(Just
[uri|https://downloads.haskell.org/~ghc/8.8.4/docs/html/users_guide/8.8.4-notes.html|]
)
@@ -1799,6 +1826,7 @@ ghcupDownloads = M.fromList
, (Linux Ubuntu, M.fromList [(Nothing, ghc_884_32_deb9)])
, (Linux Mint , M.fromList [(Nothing, ghc_884_32_deb9)])
, (Linux Debian, M.fromList [(Nothing, ghc_884_32_deb9)])
, (Linux Alpine, M.fromList [(Nothing, ghc_884_32_alpine)])
]
)
]
@@ -1869,6 +1897,7 @@ ghcupDownloads = M.fromList
, (Just [vers|9|], ghc_8101_32_deb9)
]
)
, (Linux Alpine, M.fromList [(Nothing, ghc_8101_32_alpine)])
]
)
]
@@ -1976,7 +2005,7 @@ ghcupDownloads = M.fromList
)
, ( GHCup
, M.fromList
[ ( [vver|0.1.6|]
[ ( [vver|0.1.7|]
, VersionInfo
[Recommended, Latest]
(Just
@@ -1987,16 +2016,16 @@ ghcupDownloads = M.fromList
[ ( A_64
, M.fromList
[ ( Linux UnknownLinux
, M.fromList [(Nothing, ghcup_016_64_linux)]
, M.fromList [(Nothing, ghcup_017_64_linux)]
)
, (Darwin , M.fromList [(Nothing, ghcup_016_64_darwin10_13)])
, (FreeBSD, M.fromList [(Nothing, ghcup_016_64_freebsd)])
, (Darwin , M.fromList [(Nothing, ghcup_017_64_darwin10_13)])
, (FreeBSD, M.fromList [(Nothing, ghcup_017_64_freebsd)])
]
)
, ( A_32
, M.fromList
[ ( Linux UnknownLinux
, M.fromList [(Nothing, ghcup_016_32_linux)]
, M.fromList [(Nothing, ghcup_017_32_linux)]
)
]
)

View File

@@ -10,6 +10,7 @@ import GHCup.Utils.Prelude
import GHCup.Types
import Control.Concurrent
import Control.Concurrent.Async
import Control.Exception ( evaluate )
import Control.Exception.Safe
import Control.Monad
@@ -57,14 +58,6 @@ import qualified "unix-bytestring" System.Posix.IO.ByteString
-- | Bool signals whether the regions should be cleaned.
data StopThread = StopThread Bool
deriving Show
instance Exception StopThread
data ProcessError = NonZeroExit Int ByteString [ByteString]
| PTerminated ByteString [ByteString]
| PStopped ByteString [ByteString]
@@ -131,10 +124,9 @@ execLogged exe spath args lfile chdir env = do
pState <- newEmptyMVar
done <- newEmptyMVar
void
$ forkOS
$ EX.handle (\(_ :: StopThread) -> pure ())
$ forkIO
$ EX.handle (\(_ :: IOException) -> pure ())
$ flip finally (putMVar done ())
$ flip EX.finally (putMVar done ())
$ (if verbose
then tee fd stdoutRead
else printToRegion fd stdoutRead 6 pState
@@ -157,7 +149,7 @@ execLogged exe spath args lfile chdir env = do
e <- toProcessError exe args <$!> SPPB.getProcessStatus True True pid
putMVar pState (either (const False) (const True) e)
takeMVar done
void $ race (takeMVar done) (threadDelay (1000000 * 3))
closeFd stdoutRead
pure e
@@ -225,33 +217,41 @@ execLogged exe spath args lfile chdir env = do
| BS.length bs > w && w > 5 -> BS.take (w - 4) bs <> "..."
| otherwise -> bs
-- read an entire line from the file descriptor (removes the newline char)
readLine :: MonadIO m => Fd -> ByteString -> m (ByteString, ByteString)
readLine fd = go
-- Consecutively read from Fd in 512 chunks until we hit
-- newline or EOF.
readLine :: MonadIO m
=> Fd -- ^ input file descriptor
-> ByteString -- ^ rest buffer (read across newline)
-> m (ByteString, ByteString, Bool) -- ^ (full line, rest, eof)
readLine fd = \inBs -> go inBs
where
go inBs = do
bs <-
liftIO
$ handleIO (\e -> if isEOFError e then pure "" else ioError e)
$ SPIB.fdRead fd 512
let nbs = BS.append inBs bs
(line, rest) = BS.span (/= _lf) nbs
if
| BS.length rest /= 0 -> pure (line, BS.tail rest)
| BS.length line == 0 -> pure (mempty, mempty)
| otherwise -> (\(l, r) -> (line <> l, r)) <$!> go mempty
-- if buffer is not empty, process it first
mbs <- if BS.length inBs == 0
-- otherwise attempt read
then liftIO
$ handleIO (\e -> if isEOFError e then pure Nothing else ioError e)
$ fmap Just
$ SPIB.fdRead fd 512
else pure $ Just inBs
case mbs of
Nothing -> pure ("", "", True)
Just bs -> do
-- split on newline
let (line, rest) = BS.span (/= _lf) bs
if
| BS.length rest /= 0 -> pure (line, BS.tail rest, False)
-- if rest is empty, then there was no newline, process further
| otherwise -> (\(l, r, b) -> (line <> l, r, b)) <$!> go mempty
readTilEOF :: MonadIO m => (ByteString -> m a) -> Fd -> m ()
readTilEOF ~action' fd' = go mempty
where
go bs' = do
(bs, rest) <- readLine fd' bs'
if
| BS.length bs == 0 -> liftIO
$ ioError (mkIOError eofErrorType "" Nothing Nothing)
| otherwise -> do
void $ action' bs
go rest
(bs, rest, eof) <- readLine fd' bs'
if eof
then liftIO $ ioError (mkIOError eofErrorType "" Nothing Nothing)
else (void $ action' bs) >> go rest
-- | Capture the stdout and stderr of the given action, which
@@ -288,13 +288,12 @@ captureOutStreams action = do
done <- newEmptyMVar
_ <-
forkIO
$ EX.handle (\(_ :: StopThread) -> pure ())
$ EX.handle (\(_ :: IOException) -> pure ())
$ flip finally (putMVar done ())
$ flip EX.finally (putMVar done ())
$ writeStds parentStdoutRead parentStderrRead refOut refErr
status <- SPPB.getProcessStatus True True pid
takeMVar done
void $ race (takeMVar done) (threadDelay (1000000 * 3))
case status of
-- readFd will take care of closing the fd
@@ -314,13 +313,13 @@ captureOutStreams action = do
void
$ forkIO
$ hideError eofErrorType
$ flip finally (putMVar doneOut ())
$ flip EX.finally (putMVar doneOut ())
$ readTilEOF (\x -> modifyIORef' rout (<> x)) pout
doneErr <- newEmptyMVar
void
$ forkIO
$ hideError eofErrorType
$ flip finally (putMVar doneErr ())
$ flip EX.finally (putMVar doneErr ())
$ readTilEOF (\x -> modifyIORef' rerr (<> x)) perr
takeMVar doneOut
takeMVar doneErr

View File

@@ -16,7 +16,7 @@ ghcupURL :: URI
ghcupURL = [uri|https://www.haskell.org/ghcup/data/ghcup-0.0.2.json|]
ghcUpVer :: PVP
ghcUpVer = [pver|0.1.7|]
ghcUpVer = [pver|0.1.8|]
numericVer :: String
numericVer = T.unpack . prettyPVP $ ghcUpVer