Compare commits
5 Commits
isolated-i
...
v0.1.16.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
6701093c3b
|
|||
|
e9fdc073c6
|
|||
|
57c791106b
|
|||
|
fcba151fad
|
|||
|
|
1cfff674b7 |
@@ -1,5 +1,14 @@
|
|||||||
# Revision history for ghcup
|
# Revision history for ghcup
|
||||||
|
|
||||||
|
## 0.1.16.2 -- 2021-08-12
|
||||||
|
|
||||||
|
* Add isolated installations wrt [#141](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/141) by Arjun Kathuria
|
||||||
|
* Implement config cli MVP wrt [#134](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/134) by Oleksii Dorozhkin
|
||||||
|
* Fix `ghcup compile ghc --flavor`
|
||||||
|
* Fix minor installation bug causing increased disk space wrt [#139](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/139)
|
||||||
|
* Improved error handling wrt [#136](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/136)
|
||||||
|
* Various improvements to metadata download when using `file://` and `--offline` wrt [#137](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/137)
|
||||||
|
|
||||||
## 0.1.16.1 -- 2021-07-29
|
## 0.1.16.1 -- 2021-07-29
|
||||||
|
|
||||||
* Add 'nuke' subcommand wrt [#135](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/135), implemented by Arjun Kathuria
|
* Add 'nuke' subcommand wrt [#135](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/135), implemented by Arjun Kathuria
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ import qualified Data.Map.Strict as M
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as T
|
import qualified Data.Text.IO as T
|
||||||
import qualified Data.Text.Encoding as E
|
import qualified Data.Text.Encoding as E
|
||||||
|
import qualified Data.Yaml as Y
|
||||||
|
import qualified Data.Yaml.Pretty as YP
|
||||||
import qualified Text.Megaparsec as MP
|
import qualified Text.Megaparsec as MP
|
||||||
import qualified Text.Megaparsec.Char as MPC
|
import qualified Text.Megaparsec.Char as MPC
|
||||||
|
|
||||||
@@ -105,6 +107,7 @@ data Command
|
|||||||
| Rm (Either RmCommand RmOptions)
|
| Rm (Either RmCommand RmOptions)
|
||||||
| DInfo
|
| DInfo
|
||||||
| Compile CompileCommand
|
| Compile CompileCommand
|
||||||
|
| Config ConfigCommand
|
||||||
| Whereis WhereisOptions WhereisCommand
|
| Whereis WhereisOptions WhereisCommand
|
||||||
| Upgrade UpgradeOpts Bool
|
| Upgrade UpgradeOpts Bool
|
||||||
| ToolRequirements
|
| ToolRequirements
|
||||||
@@ -174,6 +177,8 @@ data RmOptions = RmOptions
|
|||||||
|
|
||||||
data CompileCommand = CompileGHC GHCCompileOptions
|
data CompileCommand = CompileGHC GHCCompileOptions
|
||||||
|
|
||||||
|
data ConfigCommand = ShowConfig | SetConfig String String | InitConfig
|
||||||
|
|
||||||
data GHCCompileOptions = GHCCompileOptions
|
data GHCCompileOptions = GHCCompileOptions
|
||||||
{ targetGhc :: Either Version GitBranch
|
{ targetGhc :: Either Version GitBranch
|
||||||
, bootstrapGhc :: Either Version FilePath
|
, bootstrapGhc :: Either Version FilePath
|
||||||
@@ -410,6 +415,12 @@ com =
|
|||||||
<> footerDoc (Just $ text changeLogFooter)
|
<> footerDoc (Just $ text changeLogFooter)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
<> command
|
||||||
|
"config"
|
||||||
|
( Config
|
||||||
|
<$> info (configP <**> helper)
|
||||||
|
(progDesc "Show or set config" <> footerDoc (Just $ text configFooter))
|
||||||
|
)
|
||||||
<> commandGroup "Other commands:"
|
<> commandGroup "Other commands:"
|
||||||
<> hidden
|
<> hidden
|
||||||
)
|
)
|
||||||
@@ -484,6 +495,17 @@ Examples:
|
|||||||
ghcup prefetch ghc 8.10.5
|
ghcup prefetch ghc 8.10.5
|
||||||
ghcup --offline install ghc 8.10.5|]
|
ghcup --offline install ghc 8.10.5|]
|
||||||
|
|
||||||
|
configFooter :: String
|
||||||
|
configFooter = [s|Examples:
|
||||||
|
|
||||||
|
# show current config
|
||||||
|
ghcup config
|
||||||
|
|
||||||
|
# initialize config
|
||||||
|
ghcup config init
|
||||||
|
|
||||||
|
# set <key> <value> configuration pair
|
||||||
|
ghcup config <key> <value>|]
|
||||||
|
|
||||||
installCabalFooter :: String
|
installCabalFooter :: String
|
||||||
installCabalFooter = [s|Discussion:
|
installCabalFooter = [s|Discussion:
|
||||||
@@ -797,6 +819,19 @@ Examples:
|
|||||||
# build cross compiler
|
# build cross compiler
|
||||||
ghcup compile ghc -j 4 -v 8.4.2 -b 8.2.2 -x armv7-unknown-linux-gnueabihf --config $(pwd)/build.mk -- --enable-unregisterised|]
|
ghcup compile ghc -j 4 -v 8.4.2 -b 8.2.2 -x armv7-unknown-linux-gnueabihf --config $(pwd)/build.mk -- --enable-unregisterised|]
|
||||||
|
|
||||||
|
configP :: Parser ConfigCommand
|
||||||
|
configP = subparser
|
||||||
|
( command "init" initP
|
||||||
|
<> command "set" setP -- [set] KEY VALUE at help lhs
|
||||||
|
<> command "show" showP
|
||||||
|
)
|
||||||
|
<|> argsP -- add show for a single option
|
||||||
|
<|> pure ShowConfig
|
||||||
|
where
|
||||||
|
initP = info (pure InitConfig) (progDesc "Write default config to ~/.ghcup/config.yaml")
|
||||||
|
showP = info (pure ShowConfig) (progDesc "Show current config (default)")
|
||||||
|
setP = info argsP (progDesc "Set config KEY to VALUE")
|
||||||
|
argsP = SetConfig <$> argument str (metavar "KEY") <*> argument str (metavar "VALUE")
|
||||||
|
|
||||||
whereisP :: Parser WhereisCommand
|
whereisP :: Parser WhereisCommand
|
||||||
whereisP = subparser
|
whereisP = subparser
|
||||||
@@ -1282,6 +1317,21 @@ toSettings options = do
|
|||||||
, bShowAllTools = fromMaybe bShowAllTools kShowAllTools
|
, bShowAllTools = fromMaybe bShowAllTools kShowAllTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSettings :: Monad m => UTF8.ByteString -> Settings -> Excepts '[JSONError] m Settings
|
||||||
|
updateSettings config settings = do
|
||||||
|
settings' <- lE' JSONDecodeError . first show . Y.decodeEither' $ config
|
||||||
|
pure $ mergeConf settings' settings
|
||||||
|
where
|
||||||
|
mergeConf :: UserSettings -> Settings -> Settings
|
||||||
|
mergeConf UserSettings{..} Settings{..} =
|
||||||
|
let cache' = fromMaybe cache uCache
|
||||||
|
noVerify' = fromMaybe noVerify uNoVerify
|
||||||
|
keepDirs' = fromMaybe keepDirs uKeepDirs
|
||||||
|
downloader' = fromMaybe downloader uDownloader
|
||||||
|
verbose' = fromMaybe verbose uVerbose
|
||||||
|
urlSource' = fromMaybe urlSource uUrlSource
|
||||||
|
noNetwork' = fromMaybe noNetwork uNoNetwork
|
||||||
|
in Settings cache' noVerify' keepDirs' downloader' verbose' urlSource' noNetwork'
|
||||||
|
|
||||||
upgradeOptsP :: Parser UpgradeOpts
|
upgradeOptsP :: Parser UpgradeOpts
|
||||||
upgradeOptsP =
|
upgradeOptsP =
|
||||||
@@ -1316,6 +1366,11 @@ describe_result = $( LitE . StringL <$>
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
formatConfig :: UserSettings -> String
|
||||||
|
formatConfig settings
|
||||||
|
= UTF8.toString . YP.encodePretty yamlConfig $ settings
|
||||||
|
where
|
||||||
|
yamlConfig = YP.setConfCompare compare YP.defConfig
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
@@ -2023,6 +2078,37 @@ Make sure to clean up #{tmpdir} afterwards.|])
|
|||||||
runLogger $ $(logError) $ T.pack $ prettyShow e
|
runLogger $ $(logError) $ T.pack $ prettyShow e
|
||||||
pure $ ExitFailure 9
|
pure $ ExitFailure 9
|
||||||
|
|
||||||
|
Config InitConfig -> do
|
||||||
|
path <- getConfigFilePath
|
||||||
|
writeFile path $ formatConfig $ fromSettings settings (Just keybindings)
|
||||||
|
runLogger $ $(logDebug) [i|"config.yaml initialized at #{path}|]
|
||||||
|
pure ExitSuccess
|
||||||
|
|
||||||
|
Config ShowConfig -> do
|
||||||
|
putStrLn $ formatConfig $ fromSettings settings (Just keybindings)
|
||||||
|
pure ExitSuccess
|
||||||
|
|
||||||
|
Config (SetConfig k v) -> do
|
||||||
|
case v of
|
||||||
|
"" -> do
|
||||||
|
runLogger $ $(logError) "Empty values are not allowed"
|
||||||
|
pure $ ExitFailure 55
|
||||||
|
_ -> do
|
||||||
|
r <- runE @'[JSONError] $ do
|
||||||
|
settings' <- updateSettings [i|#{k}: #{v}\n|] settings
|
||||||
|
path <- liftIO getConfigFilePath
|
||||||
|
liftIO $ writeFile path $ formatConfig $ fromSettings settings' (Just keybindings)
|
||||||
|
runLogger $ $(logDebug) $ T.pack $ show settings'
|
||||||
|
pure ()
|
||||||
|
|
||||||
|
case r of
|
||||||
|
VRight _ -> pure ExitSuccess
|
||||||
|
VLeft (V (JSONDecodeError e)) -> do
|
||||||
|
runLogger $ $(logError)
|
||||||
|
[i|Error decoding config: #{e}|]
|
||||||
|
pure $ ExitFailure 65
|
||||||
|
VLeft _ -> pure $ ExitFailure 65
|
||||||
|
|
||||||
Whereis WhereisOptions{..} (WhereisTool tool (Just (ToolVersion v))) ->
|
Whereis WhereisOptions{..} (WhereisTool tool (Just (ToolVersion v))) ->
|
||||||
runLeanWhereIs (do
|
runLeanWhereIs (do
|
||||||
loc <- liftE $ whereIsTool tool v
|
loc <- liftE $ whereIsTool tool v
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: ghcup
|
name: ghcup
|
||||||
version: 0.1.16.1
|
version: 0.1.16.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
|
||||||
@@ -226,6 +226,7 @@ executable ghcup
|
|||||||
, uri-bytestring ^>=0.3.2.2
|
, uri-bytestring ^>=0.3.2.2
|
||||||
, utf8-string ^>=1.0
|
, utf8-string ^>=1.0
|
||||||
, versions >=4.0.1 && <5.1
|
, versions >=4.0.1 && <5.1
|
||||||
|
, yaml ^>=0.11.4.0
|
||||||
|
|
||||||
if flag(internal-downloader)
|
if flag(internal-downloader)
|
||||||
cpp-options: -DINTERNAL_DOWNLOADER
|
cpp-options: -DINTERNAL_DOWNLOADER
|
||||||
|
|||||||
@@ -2127,7 +2127,7 @@ endif|]
|
|||||||
liftIO $ threadDelay 5000000
|
liftIO $ threadDelay 5000000
|
||||||
|
|
||||||
addBuildFlavourToConf bc = case buildFlavour of
|
addBuildFlavourToConf bc = case buildFlavour of
|
||||||
Just bf -> [i|BuildFlavour = #{bf}|] <> [s|
|
Just bf -> [i|BuildFlavour = #{bf}
|
||||||
|] <> [i|#{bc}|]
|
|] <> [i|#{bc}|]
|
||||||
Nothing -> bc
|
Nothing -> bc
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,41 @@ data UserSettings = UserSettings
|
|||||||
defaultUserSettings :: UserSettings
|
defaultUserSettings :: UserSettings
|
||||||
defaultUserSettings = UserSettings Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
|
defaultUserSettings = UserSettings Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
|
||||||
|
|
||||||
|
fromSettings :: Settings -> Maybe KeyBindings -> UserSettings
|
||||||
|
fromSettings Settings{..} Nothing =
|
||||||
|
UserSettings {
|
||||||
|
uCache = Just cache
|
||||||
|
, uNoVerify = Just noVerify
|
||||||
|
, uVerbose = Just verbose
|
||||||
|
, uKeepDirs = Just keepDirs
|
||||||
|
, uDownloader = Just downloader
|
||||||
|
, uNoNetwork = Just noNetwork
|
||||||
|
, uKeyBindings = Nothing
|
||||||
|
, uUrlSource = Just urlSource
|
||||||
|
}
|
||||||
|
fromSettings Settings{..} (Just KeyBindings{..}) =
|
||||||
|
let ukb = UserKeyBindings
|
||||||
|
{ kUp = Just bUp
|
||||||
|
, kDown = Just bDown
|
||||||
|
, kQuit = Just bQuit
|
||||||
|
, kInstall = Just bInstall
|
||||||
|
, kUninstall = Just bUninstall
|
||||||
|
, kSet = Just bSet
|
||||||
|
, kChangelog = Just bChangelog
|
||||||
|
, kShowAll = Just bShowAllVersions
|
||||||
|
, kShowAllTools = Just bShowAllTools
|
||||||
|
}
|
||||||
|
in UserSettings {
|
||||||
|
uCache = Just cache
|
||||||
|
, uNoVerify = Just noVerify
|
||||||
|
, uVerbose = Just verbose
|
||||||
|
, uKeepDirs = Just keepDirs
|
||||||
|
, uDownloader = Just downloader
|
||||||
|
, uNoNetwork = Just noNetwork
|
||||||
|
, uKeyBindings = Just ukb
|
||||||
|
, uUrlSource = Just urlSource
|
||||||
|
}
|
||||||
|
|
||||||
data UserKeyBindings = UserKeyBindings
|
data UserKeyBindings = UserKeyBindings
|
||||||
{ kUp :: Maybe Key
|
{ kUp :: Maybe Key
|
||||||
, kDown :: Maybe Key
|
, kDown :: Maybe Key
|
||||||
|
|||||||
@@ -316,3 +316,6 @@ deriveJSON defaultOptions { sumEncoding = ObjectWithSingleField } ''URLSource
|
|||||||
deriveJSON defaultOptions { sumEncoding = ObjectWithSingleField } ''Key
|
deriveJSON defaultOptions { sumEncoding = ObjectWithSingleField } ''Key
|
||||||
deriveJSON defaultOptions { fieldLabelModifier = \str' -> maybe str' T.unpack . T.stripPrefix (T.pack "k-") . T.pack . kebab $ str' } ''UserKeyBindings
|
deriveJSON defaultOptions { fieldLabelModifier = \str' -> maybe str' T.unpack . T.stripPrefix (T.pack "k-") . T.pack . kebab $ str' } ''UserKeyBindings
|
||||||
deriveJSON defaultOptions { fieldLabelModifier = \str' -> maybe str' T.unpack . T.stripPrefix (T.pack "u-") . T.pack . kebab $ str' } ''UserSettings
|
deriveJSON defaultOptions { fieldLabelModifier = \str' -> maybe str' T.unpack . T.stripPrefix (T.pack "u-") . T.pack . kebab $ str' } ''UserSettings
|
||||||
|
|
||||||
|
deriveToJSON defaultOptions { fieldLabelModifier = kebab } ''Settings
|
||||||
|
deriveToJSON defaultOptions { fieldLabelModifier = drop 2 . kebab } ''KeyBindings -- move under key-bindings key
|
||||||
|
|||||||
Reference in New Issue
Block a user