packages feed

ghcup-0.2.7.0 / lib / GHCup / Command / Fixup.hs

{-# LANGUAGE DataKinds #-}{-# LANGUAGE FlexibleContexts #-}{-# LANGUAGE OverloadedStrings #-}module GHCup.Command.Fixup whereimport GHCup.Command.Install.LowLevelimport GHCup.Command.Listimport GHCup.Errorsimport GHCup.Preludeimport GHCup.Query.DBimport GHCup.Query.GHCupDirsimport GHCup.Typesimport GHCup.Types.Opticsimport Control.Monad                  ( forM_, when )import Control.Monad.Reader           ( MonadReader )import Data.Variant.Exceptsimport Text.PrettyPrint.HughesPJClass ( prettyShow )import qualified Data.Map.Strict as Mimport qualified Data.Text       as TfixupSymlinks ::  ( HasLog env  , MonadReader env m  , HasDirs env  , HasPlatformReq env  , HasGHCupInfo env  , MonadIOish m  )  => Excepts '[MalformedInstallInfo, ParseError] m ()fixupSymlinks = do  Dirs{..} <- getDirs  tlr <- liftE $ listVersions Nothing [ListInstalled True] ShowNone False NShowAll (Nothing, Nothing)  forM_ (M.toList $ M.filterWithKey (\t _ -> t /= ghcup) tlr) $ \(tool, (_mtd, lrs)) ->    forM_ lrs $ \ListResult{..} -> do      let tver = TargetVersion lCross lVer      logInfo $ "Fixing symlinks for " <> T.pack (prettyShow tool) <> " version " <> T.pack (prettyShow tver)      idr <- toolInstallDestination tool tver      rawSpec <- liftE $ getSymlinkSpecPortable' tool tver      when (null rawSpec) $ logWarn $ "Could not find symlink specification in the DB. Consider reinstalling " <> T.pack (prettyShow tool) <> "-" <> T.pack (prettyShow tver)      liftE $ symlinkBinaries (GHCupDir idr) rawSpec (GHCupBinDir binDir) tool tver