Compare commits
59 Commits
update-lol
...
debug-CI
| Author | SHA1 | Date | |
|---|---|---|---|
|
0ad5dc4583
|
|||
|
7189998f3b
|
|||
|
b6b24b8e0b
|
|||
|
8e820c6e89
|
|||
|
c74784a37c
|
|||
|
3d940cffcf
|
|||
|
0df044b284
|
|||
|
f576b9fb20
|
|||
|
5e00264119
|
|||
|
|
05eeba32fa | ||
|
|
61019ecd49 | ||
|
|
bed06d1334 | ||
|
|
f09f4bd1b7 | ||
|
|
a3b11f21bb | ||
|
|
69a461d9c3 | ||
|
|
1dfe5cfecf | ||
|
|
8e4550657e | ||
|
|
aee7fa52c3 | ||
|
|
d166cc84a1 | ||
|
|
bb7229d224 | ||
|
|
708cd5ead9 | ||
|
|
f7986cb4da | ||
|
|
395aeb415d | ||
|
|
830fb70492 | ||
|
|
6379a26afb | ||
|
|
2277013c76 | ||
|
|
8934e0e6bd | ||
|
|
59519febbc | ||
|
|
46fcdd356c | ||
|
|
9f343c45e8 | ||
|
|
931904f388 | ||
|
|
a40d0cbb5c | ||
|
|
9f5df9db10 | ||
|
|
d26ddf7015 | ||
|
|
9515065407 | ||
|
|
82a8c61cf6 | ||
|
|
3fae516ce4 | ||
|
|
33eaa765d7 | ||
|
|
3b3dde8413 | ||
|
|
118a2744fe | ||
|
|
2e3dceecf8 | ||
|
|
07fb04bb74 | ||
|
|
8a1dbe9dbb | ||
|
|
4ef3622616 | ||
|
|
82a704ab44 | ||
|
|
0cb22945fe | ||
|
|
d09adf9159 | ||
|
|
0b959c56fb | ||
|
|
ec29332657 | ||
|
|
0f6381e67b | ||
|
|
877b55e21d | ||
|
|
fa11ca665f | ||
|
d9d196439f
|
|||
|
a34fc4ad4f
|
|||
|
b4d52b88c1
|
|||
|
3fc3d27361
|
|||
|
56b86add38
|
|||
|
a608a105e3
|
|||
|
2e3e413f6c
|
@@ -7,7 +7,7 @@ variables:
|
|||||||
GIT_SSL_NO_VERIFY: "1"
|
GIT_SSL_NO_VERIFY: "1"
|
||||||
|
|
||||||
# Commit of ghc/ci-images repository from which to pull Docker images
|
# Commit of ghc/ci-images repository from which to pull Docker images
|
||||||
DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a
|
DOCKER_REV: 8d0224e6b2a08157649651e69302380b2bd24e11
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# CI Step
|
# CI Step
|
||||||
@@ -149,17 +149,19 @@ variables:
|
|||||||
script: |
|
script: |
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
function runInNixShell() {
|
function runInNixShell() {
|
||||||
time nix-shell .gitlab/shell.nix \
|
time nix-shell $CI_PROJECT_DIR/.gitlab/shell.nix \
|
||||||
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
|
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
|
||||||
--argstr system "x86_64-darwin" \
|
--argstr system "aarch64-darwin" \
|
||||||
--pure \
|
--pure \
|
||||||
--keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \
|
--keep CI_PROJECT_DIR \
|
||||||
--keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \
|
--keep MACOSX_DEPLOYMENT_TARGET \
|
||||||
--keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS --keep CABAL_CACHE \
|
--keep JSON_VERSION \
|
||||||
--keep LANG --keep CONFIGURE_ARGS --keep TEST_ENV --keep BIN_DIST_NAME \
|
--keep ARTIFACT \
|
||||||
--keep MACOSX_DEPLOYMENT_TARGET --keep ac_cv_func_clock_gettime --keep HACKAGE_INDEX_STATE \
|
--keep OS \
|
||||||
--keep CABAL_DIR --keep ARCH --keep OS --keep CABAL_VERSION --keep GHC_VERSION \
|
--keep ARCH \
|
||||||
--keep JSON_VERSION --ARTIFACT \
|
--keep CABAL_DIR \
|
||||||
|
--keep GHC_VERSION \
|
||||||
|
--keep CABAL_VERSION \
|
||||||
--run "$1" 2>&1
|
--run "$1" 2>&1
|
||||||
}
|
}
|
||||||
runInNixShell ./.gitlab/before_script/darwin/install_deps.sh 2>&1
|
runInNixShell ./.gitlab/before_script/darwin/install_deps.sh 2>&1
|
||||||
@@ -398,8 +400,20 @@ release:darwin:aarch64:
|
|||||||
- .darwin:aarch64
|
- .darwin:aarch64
|
||||||
- .release_ghcup
|
- .release_ghcup
|
||||||
- .root_cleanup
|
- .root_cleanup
|
||||||
before_script:
|
script: |
|
||||||
- ./.gitlab/before_script/darwin/install_deps.sh
|
set -Eeuo pipefail
|
||||||
|
function runInNixShell() {
|
||||||
|
time nix-shell .gitlab/shell.nix \
|
||||||
|
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
|
||||||
|
--argstr system "aarch64-darwin" \
|
||||||
|
--pure \
|
||||||
|
--keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS --keep CABAL_CACHE \
|
||||||
|
--keep MACOSX_DEPLOYMENT_TARGET \
|
||||||
|
--keep JSON_VERSION --keep ARTIFACT \
|
||||||
|
--run "$1" 2>&1
|
||||||
|
}
|
||||||
|
runInNixShell ./.gitlab/before_script/darwin/install_deps.sh 2>&1
|
||||||
|
runInNixShell ./.gitlab/script/ghcup_release.sh 2>&1
|
||||||
variables:
|
variables:
|
||||||
ARTIFACT: "aarch64-apple-darwin-ghcup"
|
ARTIFACT: "aarch64-apple-darwin-ghcup"
|
||||||
GHC_VERSION: "8.10.5"
|
GHC_VERSION: "8.10.5"
|
||||||
@@ -417,24 +431,8 @@ release:freebsd:
|
|||||||
- .freebsd
|
- .freebsd
|
||||||
- .release_ghcup
|
- .release_ghcup
|
||||||
- .root_cleanup
|
- .root_cleanup
|
||||||
script: |
|
before_script:
|
||||||
set -Eeuo pipefail
|
- ./.gitlab/before_script/freebsd/install_deps.sh
|
||||||
function runInNixShell() {
|
|
||||||
time nix-shell .gitlab/shell.nix \
|
|
||||||
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
|
|
||||||
--argstr system "x86_64-darwin" \
|
|
||||||
--pure \
|
|
||||||
--keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \
|
|
||||||
--keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \
|
|
||||||
--keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS --keep CABAL_CACHE \
|
|
||||||
--keep LANG --keep CONFIGURE_ARGS --keep TEST_ENV --keep BIN_DIST_NAME \
|
|
||||||
--keep MACOSX_DEPLOYMENT_TARGET --keep ac_cv_func_clock_gettime --keep HACKAGE_INDEX_STATE \
|
|
||||||
--keep CABAL_DIR --keep ARCH --keep OS --keep CABAL_VERSION --keep GHC_VERSION \
|
|
||||||
--keep JSON_VERSION --ARTIFACT \
|
|
||||||
--run "$1" 2>&1
|
|
||||||
}
|
|
||||||
runInNixShell ./.gitlab/before_script/freebsd/install_deps.sh 2>&1
|
|
||||||
runInNixShell ./.gitlab/script/ghcup_release.sh 2>&1
|
|
||||||
variables:
|
variables:
|
||||||
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
|
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
|
||||||
GHC_VERSION: "8.10.5"
|
GHC_VERSION: "8.10.5"
|
||||||
|
|||||||
@@ -19,4 +19,14 @@ fi
|
|||||||
./ghcup-bin set ${GHC_VERSION}
|
./ghcup-bin set ${GHC_VERSION}
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
./ghcup-bin install-cabal ${CABAL_VERSION}
|
||||||
|
|
||||||
|
if [ $ARCH = 'ARM64' ] ; then
|
||||||
|
cabal update
|
||||||
|
mkdir vendored
|
||||||
|
cd vendored
|
||||||
|
cabal unpack network-3.1.2.1
|
||||||
|
cd network*
|
||||||
|
autoreconf -fi
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -104,35 +104,39 @@ if [ "${OS}" != "WINDOWS" ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# test installing new ghc doesn't mess with currently set GHC
|
if [ "${OS}" = "DARWIN" ] && [ "${ARCH}" = "ARM64" ] ; then
|
||||||
# https://gitlab.haskell.org/haskell/ghcup-hs/issues/7
|
echo
|
||||||
if [ "${OS}" = "LINUX" ] ; then
|
else
|
||||||
eghcup --downloader=wget install 8.10.3
|
# test installing new ghc doesn't mess with currently set GHC
|
||||||
else # test wget a bit
|
# https://gitlab.haskell.org/haskell/ghcup-hs/issues/7
|
||||||
eghcup install 8.10.3
|
if [ "${OS}" = "LINUX" ] ; then
|
||||||
fi
|
eghcup --downloader=wget install 8.10.3
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
else # test wget a bit
|
||||||
eghcup set 8.10.3
|
eghcup install 8.10.3
|
||||||
eghcup set 8.10.3
|
fi
|
||||||
[ "$(ghc --numeric-version)" = "8.10.3" ]
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
eghcup set ${GHC_VERSION}
|
eghcup set 8.10.3
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
eghcup set 8.10.3
|
||||||
eghcup rm 8.10.3
|
[ "$(ghc --numeric-version)" = "8.10.3" ]
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
eghcup set ${GHC_VERSION}
|
||||||
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
|
eghcup rm 8.10.3
|
||||||
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
|
|
||||||
if [ "${OS}" = "DARWIN" ] ; then
|
if [ "${OS}" = "DARWIN" ] ; then
|
||||||
eghcup install hls
|
|
||||||
haskell-language-server-wrapper --version
|
|
||||||
|
|
||||||
eghcup install stack
|
|
||||||
stack --version
|
|
||||||
elif [ "${OS}" = "LINUX" ] ; then
|
|
||||||
if [ "${ARCH}" = "64" ] ; then
|
|
||||||
eghcup install hls
|
eghcup install hls
|
||||||
haskell-language-server-wrapper --version
|
haskell-language-server-wrapper --version
|
||||||
|
|
||||||
eghcup install stack
|
eghcup install stack
|
||||||
stack --version
|
stack --version
|
||||||
|
elif [ "${OS}" = "LINUX" ] ; then
|
||||||
|
if [ "${ARCH}" = "64" ] ; then
|
||||||
|
eghcup install hls
|
||||||
|
haskell-language-server-wrapper --version
|
||||||
|
|
||||||
|
eghcup install stack
|
||||||
|
stack --version
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -150,3 +154,11 @@ fi
|
|||||||
eghcup upgrade
|
eghcup upgrade
|
||||||
eghcup upgrade -f
|
eghcup upgrade -f
|
||||||
|
|
||||||
|
|
||||||
|
# nuke
|
||||||
|
eghcup nuke
|
||||||
|
if [ "${OS}" = "WINDOWS" ] ; then
|
||||||
|
[ ! -e "${GHCUP_INSTALL_BASE_PREFIX}/ghcup" ]
|
||||||
|
else
|
||||||
|
[ ! -e "${GHCUP_INSTALL_BASE_PREFIX}/.ghcup" ]
|
||||||
|
fi
|
||||||
|
|||||||
@@ -44,9 +44,6 @@
|
|||||||
# unconditionally add the MacOSX.sdk and TargetConditional.h
|
# unconditionally add the MacOSX.sdk and TargetConditional.h
|
||||||
export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||||
|
|
||||||
# Use an architecture specific home, so cabal for different architectures don't confuse each other.
|
|
||||||
export HOME="$HOME/$(uname -m)-home"
|
|
||||||
mkdir -p $HOME
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = (with pkgs; [
|
nativeBuildInputs = (with pkgs; [
|
||||||
@@ -81,6 +78,7 @@
|
|||||||
|
|
||||||
which
|
which
|
||||||
wget
|
wget
|
||||||
|
curl
|
||||||
file
|
file
|
||||||
|
|
||||||
xz
|
xz
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
|||||||
# Revision history for ghcup
|
# Revision history for ghcup
|
||||||
|
|
||||||
|
## 0.1.16 -- ????-??-??
|
||||||
|
|
||||||
|
* Add 'nuke' subcommand wrt [#135](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/135), implemented by Arjun Kathuria
|
||||||
|
|
||||||
|
## 0.1.15.2 -- 2021-06-13
|
||||||
|
|
||||||
|
* Remove legacy handling of cabal binary and be more graceful about binaries not installed by ghcup (e.g. stack)
|
||||||
|
* Fix GHC compilation from git
|
||||||
|
* Fix 'ghcup upgrade' on windows
|
||||||
|
* Allow to skip update checks via `GHCUP_SKIP_UPDATE_CHECK`
|
||||||
|
* Use libarchive on windows as well, fixing unpack errors wrt [#147](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/147)
|
||||||
|
|
||||||
## 0.1.15.1 -- 2021-06-11
|
## 0.1.15.1 -- 2021-06-11
|
||||||
|
|
||||||
* Add Apple Silicon support
|
* Add Apple Silicon support
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
`ghcup` makes it easy to install specific versions of `ghc` on GNU/Linux,
|
`ghcup` makes it easy to install specific versions of `ghc` on GNU/Linux,
|
||||||
macOS (aka Darwin) and FreeBSD and can also bootstrap a fresh Haskell developer environment from scratch.
|
macOS (aka Darwin), FreeBSD and Windows and can also bootstrap a fresh Haskell developer environment from scratch.
|
||||||
It follows the unix UNIX philosophy of [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well).
|
It follows the unix UNIX philosophy of [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well).
|
||||||
|
|
||||||
Similar in scope to [rustup](https://github.com/rust-lang-nursery/rustup.rs), [pyenv](https://github.com/pyenv/pyenv) and [jenv](http://www.jenv.be).
|
Similar in scope to [rustup](https://github.com/rust-lang-nursery/rustup.rs), [pyenv](https://github.com/pyenv/pyenv) and [jenv](http://www.jenv.be).
|
||||||
@@ -85,7 +85,7 @@ handles your haskell packages and can demand that [a specific version](https://c
|
|||||||
A configuration file can be put in `~/.ghcup/config.yaml`. The default config file
|
A configuration file can be put in `~/.ghcup/config.yaml`. The default config file
|
||||||
explaining all possible configurations can be found in this repo: [config.yaml](./config.yaml).
|
explaining all possible configurations can be found in this repo: [config.yaml](./config.yaml).
|
||||||
|
|
||||||
Partial configuration is fine. Command line options always overwrite the config file settings.
|
Partial configuration is fine. Command line options always override the config file settings.
|
||||||
|
|
||||||
### Manpages
|
### Manpages
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ data Command
|
|||||||
| Upgrade UpgradeOpts Bool
|
| Upgrade UpgradeOpts Bool
|
||||||
| ToolRequirements
|
| ToolRequirements
|
||||||
| ChangeLog ChangeLogOptions
|
| ChangeLog ChangeLogOptions
|
||||||
|
| Nuke
|
||||||
#if defined(BRICK)
|
#if defined(BRICK)
|
||||||
| Interactive
|
| Interactive
|
||||||
#endif
|
#endif
|
||||||
@@ -219,7 +220,7 @@ invertableSwitch'
|
|||||||
-> Mod FlagFields Bool -- ^ option modifier for --no-foo
|
-> Mod FlagFields Bool -- ^ option modifier for --no-foo
|
||||||
-> Parser (Maybe Bool)
|
-> Parser (Maybe Bool)
|
||||||
invertableSwitch' longopt shortopt defv enmod dismod = optional
|
invertableSwitch' longopt shortopt defv enmod dismod = optional
|
||||||
( flag' True (enmod <> long longopt <> if defv then mempty else short shortopt)
|
( flag' True ( enmod <> long longopt <> if defv then mempty else short shortopt)
|
||||||
<|> flag' False (dismod <> long nolongopt <> if defv then short shortopt else mempty)
|
<|> flag' False (dismod <> long nolongopt <> if defv then short shortopt else mempty)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@@ -368,6 +369,14 @@ com =
|
|||||||
)
|
)
|
||||||
<> internal
|
<> internal
|
||||||
)
|
)
|
||||||
|
<|> subparser
|
||||||
|
(command
|
||||||
|
"nuke"
|
||||||
|
(info (pure Nuke <**> helper)
|
||||||
|
(progDesc "Completely remove ghcup from your system"))
|
||||||
|
<> commandGroup "Nuclear Commands:"
|
||||||
|
)
|
||||||
|
|
||||||
where
|
where
|
||||||
installToolFooter :: String
|
installToolFooter :: String
|
||||||
installToolFooter = [s|Discussion:
|
installToolFooter = [s|Discussion:
|
||||||
@@ -393,7 +402,6 @@ com =
|
|||||||
By default returns the URI of the ChangeLog of the latest GHC release.
|
By default returns the URI of the ChangeLog of the latest GHC release.
|
||||||
Pass '-o' to automatically open via xdg-open.|]
|
Pass '-o' to automatically open via xdg-open.|]
|
||||||
|
|
||||||
|
|
||||||
installCabalFooter :: String
|
installCabalFooter :: String
|
||||||
installCabalFooter = [s|Discussion:
|
installCabalFooter = [s|Discussion:
|
||||||
Installs the specified cabal-install version (or a recommended default one)
|
Installs the specified cabal-install version (or a recommended default one)
|
||||||
@@ -1105,7 +1113,10 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
let loggerConfig = LoggerConfig
|
let loggerConfig = LoggerConfig
|
||||||
{ lcPrintDebug = verbose settings
|
{ lcPrintDebug = verbose settings
|
||||||
, colorOutter = B.hPut stderr
|
, colorOutter = B.hPut stderr
|
||||||
, rawOutter = B.appendFile logfile
|
, rawOutter =
|
||||||
|
case optCommand of
|
||||||
|
Nuke -> \_ -> pure ()
|
||||||
|
_ -> B.appendFile logfile
|
||||||
}
|
}
|
||||||
let runLogger = myLoggerT loggerConfig
|
let runLogger = myLoggerT loggerConfig
|
||||||
let siletRunLogger = myLoggerT loggerConfig { colorOutter = \_ -> pure () }
|
let siletRunLogger = myLoggerT loggerConfig { colorOutter = \_ -> pure () }
|
||||||
@@ -1693,9 +1704,41 @@ Make sure to clean up #{tmpdir} afterwards.|])
|
|||||||
>> pure (ExitFailure 13)
|
>> pure (ExitFailure 13)
|
||||||
else putStrLn uri' >> pure ExitSuccess
|
else putStrLn uri' >> pure ExitSuccess
|
||||||
|
|
||||||
|
Nuke ->
|
||||||
|
runRm (do
|
||||||
|
lift $ $logWarn "WARNING: This will remove GHCup and all installed components from your system."
|
||||||
|
lift $ $logWarn "Waiting 10 seconds before commencing, if you want to cancel it, now would be the time."
|
||||||
|
liftIO $ threadDelay 10000000 -- wait 10s
|
||||||
|
|
||||||
|
lift $ $logInfo "Initiating Nuclear Sequence 🚀🚀🚀"
|
||||||
|
lift $ $logInfo "Nuking in 3...2...1"
|
||||||
|
|
||||||
|
lInstalled <- lift $ listVersions Nothing (Just ListInstalled)
|
||||||
|
|
||||||
|
forM_ lInstalled (liftE . rmTool)
|
||||||
|
|
||||||
|
lift rmGhcupDirs
|
||||||
|
|
||||||
|
) >>= \case
|
||||||
|
VRight leftOverFiles
|
||||||
|
| null leftOverFiles -> do
|
||||||
|
runLogger $ $logInfo "Nuclear Annihilation complete!"
|
||||||
|
pure ExitSuccess
|
||||||
|
| otherwise -> do
|
||||||
|
runLogger $ $logWarn "These Files have survived Nuclear Annihilation, you may remove them manually."
|
||||||
|
forM_ leftOverFiles putStrLn
|
||||||
|
pure ExitSuccess
|
||||||
|
|
||||||
|
VLeft e -> do
|
||||||
|
runLogger $ $(logError) $ T.pack $ prettyShow e
|
||||||
|
pure $ ExitFailure 15
|
||||||
|
|
||||||
|
|
||||||
case res of
|
case res of
|
||||||
ExitSuccess -> pure ()
|
ExitSuccess -> pure ()
|
||||||
ef@(ExitFailure _) -> exitWith ef
|
ef@(ExitFailure _) -> exitWith ef
|
||||||
|
|
||||||
|
|
||||||
pure ()
|
pure ()
|
||||||
|
|
||||||
fromVersion :: (MonadLogger m, MonadFail m, MonadReader AppState m, MonadThrow m, MonadIO m, MonadCatch m)
|
fromVersion :: (MonadLogger m, MonadFail m, MonadReader AppState m, MonadThrow m, MonadIO m, MonadCatch m)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
plat="$(uname -s)"
|
plat="$(uname -s)"
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
ghver="0.1.15.1"
|
ghver="0.1.15.2"
|
||||||
base_url="https://downloads.haskell.org/~ghcup"
|
base_url="https://downloads.haskell.org/~ghcup"
|
||||||
|
|
||||||
case "${plat}" in
|
case "${plat}" in
|
||||||
|
|||||||
@@ -319,8 +319,9 @@ if (!(Test-Path -Path ('{0}' -f $MsysDir))) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Print-Msg -msg 'Creating shortcuts...'
|
Print-Msg -msg 'Creating shortcuts...'
|
||||||
Create-Shortcut -SourceExe ('{0}\msys2_shell.cmd' -f $MsysDir) -ArgumentsToSourceExe '-mingw64' -DestinationPath ('{0}\Desktop\Mingw haskell shell.lnk' -f $HOME)
|
$DesktopDir = [Environment]::GetFolderPath("Desktop")
|
||||||
Create-Shortcut -SourceExe 'https://www.msys2.org/docs/package-management' -ArgumentsToSourceExe '' -DestinationPath ('{0}\Desktop\Mingw package management docs.url' -f $HOME)
|
Create-Shortcut -SourceExe ('{0}\msys2_shell.cmd' -f $MsysDir) -ArgumentsToSourceExe '-mingw64' -DestinationPath ('{0}\Mingw haskell shell.lnk' -f $DesktopDir)
|
||||||
|
Create-Shortcut -SourceExe 'https://www.msys2.org/docs/package-management' -ArgumentsToSourceExe '' -DestinationPath ('{0}\Mingw package management docs.url' -f $DesktopDir)
|
||||||
|
|
||||||
Print-Msg -msg ('Adding {0}\bin to Users Path...' -f $GhcupDir)
|
Print-Msg -msg ('Adding {0}\bin to Users Path...' -f $GhcupDir)
|
||||||
Add-EnvPath -Path ('{0}\bin' -f ([System.IO.Path]::GetFullPath("$GhcupDir"))) -Container 'User'
|
Add-EnvPath -Path ('{0}\bin' -f ([System.IO.Path]::GetFullPath("$GhcupDir"))) -Container 'User'
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
packages: ./ghcup.cabal
|
packages: ./ghcup.cabal
|
||||||
|
|
||||||
|
optional-packages: ./vendored/*/*.cabal
|
||||||
|
|
||||||
optimization: 2
|
optimization: 2
|
||||||
|
|
||||||
package ghcup
|
package ghcup
|
||||||
|
|||||||
@@ -1868,7 +1868,7 @@ ghcupDownloads:
|
|||||||
dlUri: https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.4.0.0/cabal-install-3.4.0.0-armv7-linux-bootstrapped.tar.xz
|
dlUri: https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.4.0.0/cabal-install-3.4.0.0-armv7-linux-bootstrapped.tar.xz
|
||||||
dlHash: 16c0d1eaba24bed14f3e152970179a45d9f9bb5cc839b2c210ad06eb7d4826ed
|
dlHash: 16c0d1eaba24bed14f3e152970179a45d9f9bb5cc839b2c210ad06eb7d4826ed
|
||||||
GHCup:
|
GHCup:
|
||||||
0.1.15.1:
|
0.1.15.2:
|
||||||
viTags:
|
viTags:
|
||||||
- Recommended
|
- Recommended
|
||||||
- Latest
|
- Latest
|
||||||
@@ -1878,39 +1878,39 @@ ghcupDownloads:
|
|||||||
A_64:
|
A_64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning: &ghcup-64
|
unknown_versioning: &ghcup-64
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-linux-ghcup-0.1.15.2
|
||||||
dlHash: 871c9dc1bfbf7df6fe3b9b7250c20a3dae8a7aee171712a3e63689ab75bc9439
|
dlHash: 1eb1bb318a327754f42eaa2245bc81fe53be7c791160d28a186893ded3004ed7
|
||||||
Darwin:
|
Darwin:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-apple-darwin-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-apple-darwin-ghcup-0.1.15.2
|
||||||
dlHash: 7cd67b554fc58c4ffb224b73e369c5dd27c5276c01f102f6423230b34cc635bc
|
dlHash: c2a6436a49f19f108493954d4a3efcb27503e343dd6288c2641784d32320b1ea
|
||||||
FreeBSD:
|
FreeBSD:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-portbld-freebsd-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-portbld-freebsd-ghcup-0.1.15.2
|
||||||
dlHash: b4ad9c9f1a878560e8f770d985d53b8fb70582baf99e40e53ec9ee97dc47ae64
|
dlHash: 7e0c17dd78ebd9fd03e6ecea278c192bac31ca333721bde5b0ef99438b847a20
|
||||||
Linux_Alpine:
|
Linux_Alpine:
|
||||||
unknown_versioning: *ghcup-64
|
unknown_versioning: *ghcup-64
|
||||||
A_32:
|
A_32:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning: &ghcup-32
|
unknown_versioning: &ghcup-32
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/i386-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/i386-linux-ghcup-0.1.15.2
|
||||||
dlHash: 0c1dcbdd7cfa8accdfbe14c623924f3ca29a35d32a2ac3e61f0eb322855e2cb1
|
dlHash: 3b1fe710cded0398e920ec9716089ba65226abf181741897f387e7c539a619c2
|
||||||
Linux_Alpine:
|
Linux_Alpine:
|
||||||
unknown_versioning: *ghcup-32
|
unknown_versioning: *ghcup-32
|
||||||
A_ARM64:
|
A_ARM64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/aarch64-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-linux-ghcup-0.1.15.2
|
||||||
dlHash: 7fa29d8e9a9fe3d1e3a63a1d16fc3550128edbdb9b5b5dff7974358c4dab192c
|
dlHash: d91b7a5416f292f2cf813824eb419f76ad9976d258cee3581123cb6eb01db9a7
|
||||||
Darwin:
|
Darwin:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/aarch64-apple-darwin-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-apple-darwin-ghcup-0.1.15.2
|
||||||
dlHash: 6a743cd50e8124ac2de8be77013d49dcf3b99ce7cc463ec86ed99a904a51dfd9
|
dlHash: 20625ba5e7488f2a6155331750ecead3815ea16b2695c20521633c1412f012cc
|
||||||
A_ARM:
|
A_ARM:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/armv7-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/armv7-linux-ghcup-0.1.15.2
|
||||||
dlHash: 77ee5d9828c2ba771127274e301e81412b9f29af2d65dd85dada4786d9438c2c
|
dlHash: 03a4af5ed895ada1dd21f4cc3f64dc9078a5bf4268313021d004c04bea7f9c2e
|
||||||
HLS:
|
HLS:
|
||||||
1.1.0:
|
1.1.0:
|
||||||
viTags:
|
viTags:
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
globalTools:
|
globalTools:
|
||||||
ShimGen:
|
ShimGen:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/shimgen/gs.exe
|
dlUri: https://downloads.haskell.org/~ghcup/shimgen/shim-2.exe
|
||||||
dlHash: 9ce8b7dad7ff4e5017dbd63d6f6f3d16412b889560cb6ccd3903dbcab0bf4f0d
|
dlHash: 7c55e201f71860c5babea886007c8fa44b861abf50d1c07e5677eb0bda387a70
|
||||||
toolRequirements:
|
toolRequirements:
|
||||||
GHC:
|
GHC:
|
||||||
unknown_version:
|
unknown_version:
|
||||||
@@ -2024,7 +2024,7 @@ ghcupDownloads:
|
|||||||
dlUri: https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.4.0.0/cabal-install-3.4.0.0-armv7-linux-bootstrapped.tar.xz
|
dlUri: https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.4.0.0/cabal-install-3.4.0.0-armv7-linux-bootstrapped.tar.xz
|
||||||
dlHash: 16c0d1eaba24bed14f3e152970179a45d9f9bb5cc839b2c210ad06eb7d4826ed
|
dlHash: 16c0d1eaba24bed14f3e152970179a45d9f9bb5cc839b2c210ad06eb7d4826ed
|
||||||
GHCup:
|
GHCup:
|
||||||
0.1.15.1:
|
0.1.15.2:
|
||||||
viTags:
|
viTags:
|
||||||
- Recommended
|
- Recommended
|
||||||
- Latest
|
- Latest
|
||||||
@@ -2034,48 +2034,46 @@ ghcupDownloads:
|
|||||||
A_64:
|
A_64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning: &ghcup-64
|
unknown_versioning: &ghcup-64
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-linux-ghcup-0.1.15.2
|
||||||
dlHash: 871c9dc1bfbf7df6fe3b9b7250c20a3dae8a7aee171712a3e63689ab75bc9439
|
dlHash: 1eb1bb318a327754f42eaa2245bc81fe53be7c791160d28a186893ded3004ed7
|
||||||
Darwin:
|
Darwin:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-apple-darwin-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-apple-darwin-ghcup-0.1.15.2
|
||||||
dlHash: 7cd67b554fc58c4ffb224b73e369c5dd27c5276c01f102f6423230b34cc635bc
|
dlHash: c2a6436a49f19f108493954d4a3efcb27503e343dd6288c2641784d32320b1ea
|
||||||
FreeBSD:
|
FreeBSD:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-portbld-freebsd-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-portbld-freebsd-ghcup-0.1.15.2
|
||||||
dlHash: b4ad9c9f1a878560e8f770d985d53b8fb70582baf99e40e53ec9ee97dc47ae64
|
dlHash: 7e0c17dd78ebd9fd03e6ecea278c192bac31ca333721bde5b0ef99438b847a20
|
||||||
Windows:
|
Windows:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/x86_64-mingw64-ghcup-0.1.15.1.exe
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/x86_64-mingw64-ghcup-0.1.15.2.exe
|
||||||
dlHash: 045bac4620fc9d1119ed4961aeba46b616ed572dd11b7d35b48caf58eea08d0f
|
dlHash: 4d832052754379531ac472aeef35666e433acfee79d4079826b8ede8ca5de520
|
||||||
Linux_Alpine:
|
Linux_Alpine:
|
||||||
unknown_versioning: *ghcup-64
|
unknown_versioning: *ghcup-64
|
||||||
A_32:
|
A_32:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning: &ghcup-32
|
unknown_versioning: &ghcup-32
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/i386-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/i386-linux-ghcup-0.1.15.2
|
||||||
dlHash: 0c1dcbdd7cfa8accdfbe14c623924f3ca29a35d32a2ac3e61f0eb322855e2cb1
|
dlHash: 3b1fe710cded0398e920ec9716089ba65226abf181741897f387e7c539a619c2
|
||||||
Linux_Alpine:
|
Linux_Alpine:
|
||||||
unknown_versioning: *ghcup-32
|
unknown_versioning: *ghcup-32
|
||||||
A_ARM64:
|
A_ARM64:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/aarch64-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-linux-ghcup-0.1.15.2
|
||||||
dlHash: 7fa29d8e9a9fe3d1e3a63a1d16fc3550128edbdb9b5b5dff7974358c4dab192c
|
dlHash: d91b7a5416f292f2cf813824eb419f76ad9976d258cee3581123cb6eb01db9a7
|
||||||
Darwin:
|
Darwin:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/aarch64-apple-darwin-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/aarch64-apple-darwin-ghcup-0.1.15.2
|
||||||
dlHash: 6a743cd50e8124ac2de8be77013d49dcf3b99ce7cc463ec86ed99a904a51dfd9
|
dlHash: 20625ba5e7488f2a6155331750ecead3815ea16b2695c20521633c1412f012cc
|
||||||
A_ARM:
|
A_ARM:
|
||||||
Linux_UnknownLinux:
|
Linux_UnknownLinux:
|
||||||
unknown_versioning:
|
unknown_versioning:
|
||||||
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.1/armv7-linux-ghcup-0.1.15.1
|
dlUri: https://downloads.haskell.org/~ghcup/0.1.15.2/armv7-linux-ghcup-0.1.15.2
|
||||||
dlHash: 77ee5d9828c2ba771127274e301e81412b9f29af2d65dd85dada4786d9438c2c
|
dlHash: 03a4af5ed895ada1dd21f4cc3f64dc9078a5bf4268313021d004c04bea7f9c2e
|
||||||
HLS:
|
HLS:
|
||||||
1.1.0:
|
1.1.0:
|
||||||
viTags:
|
viTags: []
|
||||||
- Recommended
|
|
||||||
- Latest
|
|
||||||
viChangeLog: https://github.com/haskell/haskell-language-server/blob/master/ChangeLog.md#110
|
viChangeLog: https://github.com/haskell/haskell-language-server/blob/master/ChangeLog.md#110
|
||||||
viPostInstall: "This is just the server part of your LSP configuration. Consult the README on how to configure HLS, your project and your LSP client in your editor: https://github.com/haskell/haskell-language-server/blob/master/README.md"
|
viPostInstall: "This is just the server part of your LSP configuration. Consult the README on how to configure HLS, your project and your LSP client in your editor: https://github.com/haskell/haskell-language-server/blob/master/README.md"
|
||||||
viArch:
|
viArch:
|
||||||
@@ -2094,6 +2092,28 @@ ghcupDownloads:
|
|||||||
dlHash: a1d3f451e64a041aa527a25da29e4716a2de6ae347cef4ef9312fc7611e168cc
|
dlHash: a1d3f451e64a041aa527a25da29e4716a2de6ae347cef4ef9312fc7611e168cc
|
||||||
Linux_Alpine:
|
Linux_Alpine:
|
||||||
unknown_versioning: *hls-64
|
unknown_versioning: *hls-64
|
||||||
|
1.2.0:
|
||||||
|
viTags:
|
||||||
|
- Recommended
|
||||||
|
- Latest
|
||||||
|
viChangeLog: https://github.com/haskell/haskell-language-server/blob/master/ChangeLog.md#120
|
||||||
|
viPostInstall: "This is just the server part of your LSP configuration. Consult the README on how to configure HLS, your project and your LSP client in your editor: https://github.com/haskell/haskell-language-server/blob/master/README.md"
|
||||||
|
viArch:
|
||||||
|
A_64:
|
||||||
|
Linux_UnknownLinux:
|
||||||
|
unknown_versioning: &hls-64
|
||||||
|
dlUri: https://github.com/haskell/haskell-language-server/releases/download/1.2.0/haskell-language-server-Linux-1.2.0.tar.gz
|
||||||
|
dlHash: d29ee22f7bd706da2e2a1bd7640e25bb9736adeafb34eef47d29ea143b0fa927
|
||||||
|
Darwin:
|
||||||
|
unknown_versioning:
|
||||||
|
dlUri: https://github.com/haskell/haskell-language-server/releases/download/1.2.0/haskell-language-server-macOS-1.2.0.tar.gz
|
||||||
|
dlHash: a310d8a3e9c5c4218210f750682c74a0f82ad0f59995adde0dbe775115b1e357
|
||||||
|
Windows:
|
||||||
|
unknown_versioning:
|
||||||
|
dlUri: https://github.com/haskell/haskell-language-server/releases/download/1.2.0/haskell-language-server-Windows-1.2.0.tar.gz
|
||||||
|
dlHash: 961c6ff12c9a9c7a4609f239c5ac70d7d16753cdb8c10348a6a51feeaa0b6aea
|
||||||
|
Linux_Alpine:
|
||||||
|
unknown_versioning: *hls-64
|
||||||
Stack:
|
Stack:
|
||||||
2.5.1:
|
2.5.1:
|
||||||
viTags:
|
viTags:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: ghcup
|
name: ghcup
|
||||||
version: 0.1.15.1
|
version: 0.1.15.2
|
||||||
license: LGPL-3.0-only
|
license: LGPL-3.0-only
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
copyright: Julian Ospald 2020
|
copyright: Julian Ospald 2020
|
||||||
|
|||||||
186
lib/GHCup.hs
186
lib/GHCup.hs
@@ -42,6 +42,7 @@ import GHCup.Version
|
|||||||
import Codec.Archive ( ArchiveResult )
|
import Codec.Archive ( ArchiveResult )
|
||||||
#endif
|
#endif
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
|
import Control.Exception ( evaluate )
|
||||||
import Control.Exception.Safe
|
import Control.Exception.Safe
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
#if !MIN_VERSION_base(4,13,0)
|
#if !MIN_VERSION_base(4,13,0)
|
||||||
@@ -1282,6 +1283,187 @@ rmStackVer ver = do
|
|||||||
Nothing -> liftIO $ rmLink (binDir </> "stack" <> exeExt)
|
Nothing -> liftIO $ rmLink (binDir </> "stack" <> exeExt)
|
||||||
|
|
||||||
|
|
||||||
|
-- assuming the current scheme of having just 1 ghcup bin, no version info is required.
|
||||||
|
rmGhcup :: ( MonadReader AppState m
|
||||||
|
, MonadIO m
|
||||||
|
, MonadCatch m
|
||||||
|
, MonadLogger m
|
||||||
|
)
|
||||||
|
=> m ()
|
||||||
|
|
||||||
|
rmGhcup = do
|
||||||
|
AppState {dirs = Dirs {binDir}} <- ask
|
||||||
|
let ghcupFilename = "ghcup" <> exeExt
|
||||||
|
let ghcupFilepath = binDir </> ghcupFilename
|
||||||
|
|
||||||
|
currentRunningExecPath <- liftIO getExecutablePath
|
||||||
|
|
||||||
|
-- if paths do no exist, warn user, and continue to compare them, as is,
|
||||||
|
-- which should eventually fail and result in a non-standard install warning
|
||||||
|
|
||||||
|
p1 <- handleIO' doesNotExistErrorType
|
||||||
|
(handlePathNotPresent currentRunningExecPath)
|
||||||
|
(liftIO $ canonicalizePath currentRunningExecPath)
|
||||||
|
|
||||||
|
p2 <- handleIO' doesNotExistErrorType
|
||||||
|
(handlePathNotPresent ghcupFilepath)
|
||||||
|
(liftIO $ canonicalizePath ghcupFilepath)
|
||||||
|
|
||||||
|
let areEqualPaths = equalFilePath p1 p2
|
||||||
|
|
||||||
|
unless areEqualPaths $ $logWarn $ nonStandardInstallLocationMsg currentRunningExecPath
|
||||||
|
|
||||||
|
#if defined(IS_WINDOWS)
|
||||||
|
-- since it doesn't seem possible to delete a running exec in windows
|
||||||
|
-- we move it to temp dir, to be deleted at next reboot
|
||||||
|
tempDir <- liftIO $ getTemporaryDirectory
|
||||||
|
let tempFilepath = tempDir </> ghcupFilename
|
||||||
|
hideError UnsupportedOperation $
|
||||||
|
liftIO $ hideError NoSuchThing $
|
||||||
|
Win32.moveFileEx ghcupFilepath (Just tempFilepath) Win32.mOVEFILE_REPLACE_EXISTING
|
||||||
|
#else
|
||||||
|
-- delete it.
|
||||||
|
hideError doesNotExistErrorType $ liftIO $ rmFile ghcupFilepath
|
||||||
|
#endif
|
||||||
|
|
||||||
|
where
|
||||||
|
handlePathNotPresent fp _err = do
|
||||||
|
$logDebug $ "Error: The path does not exist, " <> T.pack fp
|
||||||
|
pure fp
|
||||||
|
|
||||||
|
nonStandardInstallLocationMsg path = T.pack $
|
||||||
|
"current ghcup is invoked from a non-standard location: \n"
|
||||||
|
<> path <>
|
||||||
|
"\n you may have to uninstall it manually."
|
||||||
|
|
||||||
|
rmTool :: ( MonadReader AppState m
|
||||||
|
, MonadLogger m
|
||||||
|
, MonadFail m
|
||||||
|
, MonadMask m
|
||||||
|
, MonadUnliftIO m)
|
||||||
|
=> ListResult
|
||||||
|
-> Excepts '[NotInstalled ] m ()
|
||||||
|
|
||||||
|
rmTool ListResult {lVer, lTool, lCross} = do
|
||||||
|
case lTool of
|
||||||
|
GHC ->
|
||||||
|
let ghcTargetVersion = GHCTargetVersion lCross lVer
|
||||||
|
in rmGHCVer ghcTargetVersion
|
||||||
|
HLS -> rmHLSVer lVer
|
||||||
|
Cabal -> rmCabalVer lVer
|
||||||
|
Stack -> rmStackVer lVer
|
||||||
|
GHCup -> lift rmGhcup
|
||||||
|
|
||||||
|
|
||||||
|
rmGhcupDirs :: ( MonadReader AppState m
|
||||||
|
, MonadIO m
|
||||||
|
, MonadLogger m
|
||||||
|
, MonadCatch m
|
||||||
|
, MonadMask m )
|
||||||
|
=> m [FilePath]
|
||||||
|
rmGhcupDirs = do
|
||||||
|
Dirs
|
||||||
|
{ baseDir
|
||||||
|
, binDir
|
||||||
|
, logsDir
|
||||||
|
, cacheDir
|
||||||
|
} <- asks dirs
|
||||||
|
|
||||||
|
let envFilePath = baseDir </> "env"
|
||||||
|
|
||||||
|
confFilePath <- getConfigFilePath
|
||||||
|
|
||||||
|
rmEnvFile envFilePath
|
||||||
|
rmConfFile confFilePath
|
||||||
|
rmDir cacheDir
|
||||||
|
rmDir logsDir
|
||||||
|
rmBinDir binDir
|
||||||
|
#if defined(IS_WINDOWS)
|
||||||
|
rmDir (baseDir </> "msys64")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
liftIO $ removeEmptyDirsRecursive baseDir
|
||||||
|
|
||||||
|
-- report files in baseDir that are left-over after
|
||||||
|
-- the standard location deletions above
|
||||||
|
hideErrorDef [doesNotExistErrorType] [] $ reportRemainingFiles baseDir
|
||||||
|
|
||||||
|
where
|
||||||
|
|
||||||
|
rmEnvFile :: (MonadCatch m, MonadLogger m, MonadIO m) => FilePath -> m ()
|
||||||
|
rmEnvFile enFilePath = do
|
||||||
|
$logInfo "Removing Ghcup Environment File"
|
||||||
|
hideError doesNotExistErrorType $ liftIO $ deleteFile enFilePath
|
||||||
|
|
||||||
|
rmConfFile :: (MonadCatch m, MonadLogger m, MonadIO m) => FilePath -> m ()
|
||||||
|
rmConfFile confFilePath = do
|
||||||
|
$logInfo "removing Ghcup Config File"
|
||||||
|
hideError doesNotExistErrorType $ liftIO $ deleteFile confFilePath
|
||||||
|
|
||||||
|
rmDir :: (MonadLogger m, MonadIO m, MonadCatch m) => FilePath -> m ()
|
||||||
|
rmDir dir = do
|
||||||
|
$logInfo [i|removing #{dir}|]
|
||||||
|
contents <- hideErrorDef [doesNotExistErrorType] []
|
||||||
|
$ liftIO
|
||||||
|
(getDirectoryContentsRecursive dir >>= evaluate)
|
||||||
|
forM_ contents (liftIO . deleteFile . (dir </>))
|
||||||
|
|
||||||
|
rmBinDir :: (MonadCatch m, MonadIO m) => FilePath -> m ()
|
||||||
|
rmBinDir binDir = do
|
||||||
|
#if !defined(IS_WINDOWS)
|
||||||
|
isXDGStyle <- liftIO useXDG
|
||||||
|
if not isXDGStyle
|
||||||
|
then removeDirIfEmptyOrIsSymlink binDir
|
||||||
|
else pure ()
|
||||||
|
#else
|
||||||
|
removeDirIfEmptyOrIsSymlink binDir
|
||||||
|
#endif
|
||||||
|
|
||||||
|
reportRemainingFiles :: MonadIO m => FilePath -> m [FilePath]
|
||||||
|
reportRemainingFiles dir = do
|
||||||
|
remainingFiles <- liftIO $ getDirectoryContentsRecursive dir
|
||||||
|
let normalizedFilePaths = fmap normalise remainingFiles
|
||||||
|
let sortedByDepthRemainingFiles = sortBy (flip compareFn) normalizedFilePaths
|
||||||
|
let remainingFilesAbsolute = fmap (dir </>) sortedByDepthRemainingFiles
|
||||||
|
|
||||||
|
pure remainingFilesAbsolute
|
||||||
|
|
||||||
|
where
|
||||||
|
calcDepth :: FilePath -> Int
|
||||||
|
calcDepth = length . filter isPathSeparator
|
||||||
|
|
||||||
|
compareFn :: FilePath -> FilePath -> Ordering
|
||||||
|
compareFn fp1 fp2 = compare (calcDepth fp1) (calcDepth fp2)
|
||||||
|
|
||||||
|
removeEmptyDirsRecursive :: FilePath -> IO ()
|
||||||
|
removeEmptyDirsRecursive fp = do
|
||||||
|
cs <- listDirectory fp >>= filterM doesDirectoryExist . fmap (fp </>)
|
||||||
|
forM_ cs removeEmptyDirsRecursive
|
||||||
|
hideError InappropriateType $ removeDirIfEmptyOrIsSymlink fp
|
||||||
|
|
||||||
|
|
||||||
|
-- we expect only files inside cache/log dir
|
||||||
|
-- we report remaining files/dirs later,
|
||||||
|
-- hence the force/quiet mode in these delete functions below.
|
||||||
|
|
||||||
|
deleteFile :: FilePath -> IO ()
|
||||||
|
deleteFile filepath = do
|
||||||
|
hideError InappropriateType $ rmFile filepath
|
||||||
|
|
||||||
|
removeDirIfEmptyOrIsSymlink :: (MonadCatch m, MonadIO m) => FilePath -> m ()
|
||||||
|
removeDirIfEmptyOrIsSymlink filepath =
|
||||||
|
hideError UnsatisfiedConstraints $
|
||||||
|
handleIO' InappropriateType
|
||||||
|
(handleIfSym filepath)
|
||||||
|
(liftIO $ removeDirectory filepath)
|
||||||
|
where
|
||||||
|
handleIfSym fp e = do
|
||||||
|
isSym <- liftIO $ pathIsSymbolicLink fp
|
||||||
|
if isSym
|
||||||
|
then liftIO $ deleteFile fp
|
||||||
|
else liftIO $ ioError e
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
--[ Debug info ]--
|
--[ Debug info ]--
|
||||||
@@ -1623,14 +1805,14 @@ upgradeGHCup :: ( MonadMask m
|
|||||||
]
|
]
|
||||||
m
|
m
|
||||||
Version
|
Version
|
||||||
upgradeGHCup mtarget force = do
|
upgradeGHCup mtarget force' = do
|
||||||
AppState { dirs = Dirs {..}
|
AppState { dirs = Dirs {..}
|
||||||
, pfreq
|
, pfreq
|
||||||
, ghcupInfo = GHCupInfo { _ghcupDownloads = dls }
|
, ghcupInfo = GHCupInfo { _ghcupDownloads = dls }
|
||||||
, settings } <- lift ask
|
, settings } <- lift ask
|
||||||
lift $ $(logInfo) [i|Upgrading GHCup...|]
|
lift $ $(logInfo) [i|Upgrading GHCup...|]
|
||||||
let latestVer = fromJust $ fst <$> getLatest dls GHCup
|
let latestVer = fromJust $ fst <$> getLatest dls GHCup
|
||||||
when (not force && (latestVer <= pvpToVersion ghcUpVer)) $ throwE NoUpdate
|
when (not force' && (latestVer <= pvpToVersion ghcUpVer)) $ throwE NoUpdate
|
||||||
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
|
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
|
||||||
tmp <- lift withGHCupTmpDir
|
tmp <- lift withGHCupTmpDir
|
||||||
let fn = "ghcup" <> exeExt
|
let fn = "ghcup" <> exeExt
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ module GHCup.Utils.Dirs
|
|||||||
, parseGHCupGHCDir
|
, parseGHCupGHCDir
|
||||||
, relativeSymlink
|
, relativeSymlink
|
||||||
, withGHCupTmpDir
|
, withGHCupTmpDir
|
||||||
|
, getConfigFilePath
|
||||||
|
#if !defined(IS_WINDOWS)
|
||||||
|
, useXDG
|
||||||
|
#endif
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@@ -201,13 +205,16 @@ getDirs = do
|
|||||||
--[ GHCup files ]--
|
--[ GHCup files ]--
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
getConfigFilePath :: (MonadIO m) => m FilePath
|
||||||
|
getConfigFilePath = do
|
||||||
|
confDir <- liftIO ghcupConfigDir
|
||||||
|
pure $ confDir </> "config.yaml"
|
||||||
|
|
||||||
ghcupConfigFile :: (MonadIO m)
|
ghcupConfigFile :: (MonadIO m)
|
||||||
=> Excepts '[JSONError] m UserSettings
|
=> Excepts '[JSONError] m UserSettings
|
||||||
ghcupConfigFile = do
|
ghcupConfigFile = do
|
||||||
confDir <- liftIO ghcupConfigDir
|
filepath <- getConfigFilePath
|
||||||
let file = confDir </> "config.yaml"
|
contents <- liftIO $ handleIO' NoSuchThing (\_ -> pure Nothing) $ Just <$> BS.readFile filepath
|
||||||
contents <- liftIO $ handleIO' NoSuchThing (\_ -> pure Nothing) $ Just <$> BS.readFile file
|
|
||||||
case contents of
|
case contents of
|
||||||
Nothing -> pure defaultUserSettings
|
Nothing -> pure defaultUserSettings
|
||||||
Just contents' -> lE' JSONDecodeError . first show . Y.decodeEither' $ contents'
|
Just contents' -> lE' JSONDecodeError . first show . Y.decodeEither' $ contents'
|
||||||
|
|||||||
@@ -190,14 +190,14 @@ hideError :: (MonadIO m, MonadCatch m) => IOErrorType -> m () -> m ()
|
|||||||
hideError err = handleIO (\e -> if err == ioeGetErrorType e then pure () else liftIO . ioError $ e)
|
hideError err = handleIO (\e -> if err == ioeGetErrorType e then pure () else liftIO . ioError $ e)
|
||||||
|
|
||||||
|
|
||||||
hideErrorDef :: [IOErrorType] -> a -> IO a -> IO a
|
hideErrorDef :: (MonadIO m, MonadCatch m) => [IOErrorType] -> a -> m a -> m a
|
||||||
hideErrorDef errs def =
|
hideErrorDef errs def =
|
||||||
handleIO (\e -> if ioeGetErrorType e `elem` errs then pure def else ioError e)
|
handleIO (\e -> if ioeGetErrorType e `elem` errs then pure def else liftIO $ ioError e)
|
||||||
|
|
||||||
|
|
||||||
hideErrorDefM :: [IOErrorType] -> IO a -> IO a -> IO a
|
hideErrorDefM :: (MonadIO m, MonadCatch m) => [IOErrorType] -> m a -> m a -> m a
|
||||||
hideErrorDefM errs def =
|
hideErrorDefM errs def =
|
||||||
handleIO (\e -> if ioeGetErrorType e `elem` errs then def else ioError e)
|
handleIO (\e -> if ioeGetErrorType e `elem` errs then def else liftIO $ ioError e)
|
||||||
|
|
||||||
|
|
||||||
-- TODO: does this work?
|
-- TODO: does this work?
|
||||||
@@ -334,37 +334,38 @@ copyDirectoryRecursive srcDir destDir = do
|
|||||||
in doCopy src dest
|
in doCopy src dest
|
||||||
| (srcBase, srcFile) <- srcFiles ]
|
| (srcBase, srcFile) <- srcFiles ]
|
||||||
|
|
||||||
-- | List all the files in a directory and all subdirectories.
|
|
||||||
--
|
-- | List all the files in a directory and all subdirectories.
|
||||||
-- The order places files in sub-directories after all the files in their
|
--
|
||||||
-- parent directories. The list is generated lazily so is not well defined if
|
-- The order places files in sub-directories after all the files in their
|
||||||
-- the source directory structure changes before the list is used.
|
-- parent directories. The list is generated lazily so is not well defined if
|
||||||
--
|
-- the source directory structure changes before the list is used.
|
||||||
getDirectoryContentsRecursive :: FilePath -> IO [FilePath]
|
--
|
||||||
getDirectoryContentsRecursive topdir = recurseDirectories [""]
|
getDirectoryContentsRecursive :: FilePath -> IO [FilePath]
|
||||||
|
getDirectoryContentsRecursive topdir = recurseDirectories [""]
|
||||||
|
where
|
||||||
|
recurseDirectories :: [FilePath] -> IO [FilePath]
|
||||||
|
recurseDirectories [] = return []
|
||||||
|
recurseDirectories (dir:dirs) = unsafeInterleaveIO $ do
|
||||||
|
(files, dirs') <- collect [] [] =<< getDirectoryContents (topdir </> dir)
|
||||||
|
files' <- recurseDirectories (dirs' ++ dirs)
|
||||||
|
return (files ++ files')
|
||||||
|
|
||||||
where
|
where
|
||||||
recurseDirectories :: [FilePath] -> IO [FilePath]
|
collect files dirs' [] = return (reverse files
|
||||||
recurseDirectories [] = return []
|
,reverse dirs')
|
||||||
recurseDirectories (dir:dirs) = unsafeInterleaveIO $ do
|
collect files dirs' (entry:entries) | ignore entry
|
||||||
(files, dirs') <- collect [] [] =<< getDirectoryContents (topdir </> dir)
|
= collect files dirs' entries
|
||||||
files' <- recurseDirectories (dirs' ++ dirs)
|
collect files dirs' (entry:entries) = do
|
||||||
return (files ++ files')
|
let dirEntry = dir </> entry
|
||||||
|
isDirectory <- doesDirectoryExist (topdir </> dirEntry)
|
||||||
|
if isDirectory
|
||||||
|
then collect files (dirEntry:dirs') entries
|
||||||
|
else collect (dirEntry:files) dirs' entries
|
||||||
|
|
||||||
where
|
ignore ['.'] = True
|
||||||
collect files dirs' [] = return (reverse files
|
ignore ['.', '.'] = True
|
||||||
,reverse dirs')
|
ignore _ = False
|
||||||
collect files dirs' (entry:entries) | ignore entry
|
|
||||||
= collect files dirs' entries
|
|
||||||
collect files dirs' (entry:entries) = do
|
|
||||||
let dirEntry = dir </> entry
|
|
||||||
isDirectory <- doesDirectoryExist (topdir </> dirEntry)
|
|
||||||
if isDirectory
|
|
||||||
then collect files (dirEntry:dirs') entries
|
|
||||||
else collect (dirEntry:files) dirs' entries
|
|
||||||
|
|
||||||
ignore ['.'] = True
|
|
||||||
ignore ['.', '.'] = True
|
|
||||||
ignore _ = False
|
|
||||||
|
|
||||||
-- https://github.com/haskell/directory/issues/110
|
-- https://github.com/haskell/directory/issues/110
|
||||||
-- https://github.com/haskell/directory/issues/96
|
-- https://github.com/haskell/directory/issues/96
|
||||||
|
|||||||
Reference in New Issue
Block a user