Compare commits

...

9 Commits

Author SHA1 Message Date
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
17 changed files with 2397 additions and 49 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"

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

@@ -0,0 +1,58 @@
#!/bin/sh
set -eux
. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env"
mkdir -p "$CI_PROJECT_DIR"/.local/bin
ecabal() {
cabal --store-dir="$(pwd)"/.store "$@"
}
# 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
ghcup numeric-version
ghcup -v -c install ${GHC_VERSION}
ghcup -v -c set ${GHC_VERSION}
ghcup -v -c install-cabal
cabal --version
ghcup -v -c debug-info
ghcup -v -c list
ghcup -v -c list -t ghc
ghcup -v -c list -t cabal
ghc --version
ghci --version
ghc-$(ghc --numeric-version) --version
ghci-$(ghc --numeric-version) --version
ghcup -v upgrade
ghcup -v upgrade -f
ghcup -v rm $(ghc --numeric-version)

View File

@@ -15,10 +15,11 @@ script: ".travis/build.sh"
deploy: deploy:
provider: releases provider: releases
api_key: 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 file: $ARTIFACT
on: on:
repo: hasufell/ghcup-hs repo: haskell/ghcup-hs
tags: true tags: true
skip_cleanup: true skip_cleanup: true
draft: true draft: true

View File

@@ -1,5 +1,11 @@
# Revision history for ghcup # Revision history for ghcup
## 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 ## 0.1.1 -- 2020-04-15
* fix awful fdopendir bug on mac bug by updating hpath-posix * fix awful fdopendir bug on mac bug by updating hpath-posix

View File

@@ -2,10 +2,7 @@
## Now ## Now
* ghcup migration * move out GHCup.Version module, bc it's not library-ish
* update static links
* releases, update download info and bootstrap-haskell
## Maybe ## Maybe

View File

@@ -984,32 +984,32 @@ cabal_3200_64_darwin = DownloadInfo
------------- -------------
ghcup_010_32_linux :: DownloadInfo ghcup_011_32_linux :: DownloadInfo
ghcup_010_32_linux = DownloadInfo ghcup_011_32_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/i386-linux-ghcup|] [uri|https://downloads.haskell.org/ghcup/0.1.1/i386-linux-ghcup-0.1.1|]
Nothing Nothing
"ce95fd3044ea249c2ea02e122112a787d710cc4be2dcf1e78d8c68b540a70920" "f576f22efdcf17fa18189b65d70e596d14f2347ef549a00592ef28d529c7d5a0"
ghcup_010_64_linux :: DownloadInfo ghcup_011_64_linux :: DownloadInfo
ghcup_010_64_linux = DownloadInfo ghcup_011_64_linux = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup|] [uri|https://downloads.haskell.org/ghcup/0.1.1/x86_64-linux-ghcup-0.1.1|]
Nothing Nothing
"9281da4d8db628bbfbf1d3f3b748a2556f828cc60308559bc87c5d657cb06bdf" "2789fbab2848e4dfd77406b9a710c925b3b9680ac0f8486caca190628646486f"
ghcup_010_64_freebsd :: DownloadInfo ghcup_011_64_freebsd :: DownloadInfo
ghcup_010_64_freebsd = DownloadInfo ghcup_011_64_freebsd = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/x86_64-portbld-freebsd-ghcup|] [uri|https://downloads.haskell.org/ghcup/0.1.1/x86_64-portbld-freebsd-ghcup-0.1.1|]
Nothing Nothing
"992a375cc4d296a9ceed3712b8bb329a0ac605a614b5a9b8a5f3dba05183d2a5" "1336585b15692d6458edf4d913fd585d9963a708e2c952a71ee1ad3400ed2163"
ghcup_010_64_darwin10_13 :: DownloadInfo ghcup_011_64_darwin10_13 :: DownloadInfo
ghcup_010_64_darwin10_13 = DownloadInfo ghcup_011_64_darwin10_13 = DownloadInfo
[uri|https://downloads.haskell.org/~ghcup/x86_64-apple-darwin-ghcup|] [uri|https://downloads.haskell.org/ghcup/0.1.1/x86_64-apple-darwin-ghcup-0.1.1|]
Nothing Nothing
"adeaa6943611cf68c0c8224037788eac2a84a9136c59685eaea28ed16f3953c7" "b9694de40134e3d17611749eba94d8e4d00a84e2a16bb2409eab1e87f810dacd"
@@ -1877,18 +1877,18 @@ ghcupDownloads = M.fromList
) )
, ( GHCup , ( GHCup
, M.fromList , M.fromList
[ ( [vver|0.1.0|] [ ( [vver|0.1.1|]
, VersionInfo [Recommended, Latest] Nothing $ M.fromList , VersionInfo [Recommended, Latest] Nothing $ M.fromList
[ ( A_64 [ ( A_64
, M.fromList , M.fromList
[ (Linux UnknownLinux, M.fromList [(Nothing, ghcup_010_64_linux)]) [ (Linux UnknownLinux, M.fromList [(Nothing, ghcup_011_64_linux)])
, (Darwin, M.fromList [(Nothing, ghcup_010_64_darwin10_13)]) , (Darwin, M.fromList [(Nothing, ghcup_011_64_darwin10_13)])
, (FreeBSD, M.fromList [(Nothing, ghcup_010_64_freebsd)]) , (FreeBSD, M.fromList [(Nothing, ghcup_011_64_freebsd)])
] ]
) )
, ( A_32 , ( A_32
, M.fromList , M.fromList
[(Linux UnknownLinux, M.fromList [(Nothing, ghcup_010_32_linux)])] [(Linux UnknownLinux, M.fromList [(Nothing, ghcup_011_32_linux)])]
) )
] ]
) )

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +1,13 @@
cabal-version: 3.0 cabal-version: 3.0
name: ghcup name: ghcup
version: 0.1.1 version: 0.1.2
synopsis: ghc toolchain installer as an exe/library synopsis: ghc toolchain installer as an exe/library
description: description:
A rewrite of the shell script ghcup, for providing A rewrite of the shell script ghcup, for providing
a more stable user experience and exposing an API. a more stable user experience and exposing an API.
homepage: https://github.com/hasufell/ghcup-hs homepage: https://gitlab.haskell.org/haskell/ghcup-hs
bug-reports: https://github.com/hasufell/ghcup-hs/issues bug-reports: https://gitlab.haskell.org/haskell/ghcup-hs/issues
license: LGPL-3.0-only license: LGPL-3.0-only
license-file: LICENSE license-file: LICENSE
author: Julian Ospald author: Julian Ospald
@@ -19,7 +19,7 @@ extra-source-files: CHANGELOG.md
source-repository head source-repository head
type: git type: git
location: https://github.com/hasufell/ghcup-hs location: https://gitlab.haskell.org/haskell/ghcup-hs.git
flag Curl flag Curl
description: Use curl instead of http-io-streams for download description: Use curl instead of http-io-streams for download

View File

@@ -376,6 +376,10 @@ rmGHCVer ver = do
if exists if exists
then do then do
-- this isn't atomic, order matters -- 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'}|] lift $ $(logInfo) [i|Removing directory recursively: #{d'}|]
liftIO $ deleteDirRecursive dir liftIO $ deleteDirRecursive dir
@@ -389,11 +393,6 @@ rmGHCVer ver = do
(mj, mi) <- getGHCMajor ver (mj, mi) <- getGHCMajor ver
getGHCForMajor mj mi >>= mapM_ (\v -> liftE $ setGHC v SetGHC_XY) getGHCForMajor mj mi >>= mapM_ (\v -> liftE $ setGHC v SetGHC_XY)
when isSetGHC $ do
lift $ $(logInfo) [i|Removing ghc symlinks|]
liftE $ rmPlain ver
liftIO liftIO
$ ghcupBaseDir $ ghcupBaseDir
>>= hideError doesNotExistErrorType >>= hideError doesNotExistErrorType
@@ -676,6 +675,8 @@ upgradeGHCup :: ( MonadMask m
) )
=> GHCupDownloads => GHCupDownloads
-> Maybe (Path Abs) -- ^ full file destination to write ghcup into -> Maybe (Path Abs) -- ^ full file destination to write ghcup into
-> Bool -- ^ whether to force update regardless
-- of currently installed version
-> Excepts -> Excepts
'[ CopyError '[ CopyError
, DigestError , DigestError
@@ -684,12 +685,14 @@ upgradeGHCup :: ( MonadMask m
, NoCompatibleArch , NoCompatibleArch
, NoCompatiblePlatform , NoCompatiblePlatform
, NoDownload , NoDownload
, NoUpdate
] ]
m m
Version Version
upgradeGHCup dls mtarget = do upgradeGHCup dls mtarget force = do
lift $ $(logInfo) [i|Upgrading GHCup...|] lift $ $(logInfo) [i|Upgrading GHCup...|]
let latestVer = fromJust $ getLatest dls GHCup let latestVer = fromJust $ getLatest dls GHCup
when (not force && (latestVer < pvpToVersion ghcUpVer)) $ throwE NoUpdate
pfreq <- liftE platformRequest pfreq <- liftE platformRequest
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
tmp <- lift withGHCupTmpDir tmp <- lift withGHCupTmpDir

View File

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

View File

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

View File

@@ -240,3 +240,7 @@ addToCurrentEnv :: MonadIO m
addToCurrentEnv adds = do addToCurrentEnv adds = do
cEnv <- liftIO $ getEnvironment cEnv <- liftIO $ getEnvironment
pure (adds ++ cEnv) 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|] ghcupURL = [uri|https://www.haskell.org/ghcup/data/ghcup-0.0.1.json|]
ghcUpVer :: PVP ghcUpVer :: PVP
ghcUpVer = [pver|0.1.0|] ghcUpVer = [pver|0.1.2|]