diff --git a/app/ghcup-gen/Main.hs b/app/ghcup-gen/Main.hs index feab6ec..0e9b1c8 100644 --- a/app/ghcup-gen/Main.hs +++ b/app/ghcup-gen/Main.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} @@ -14,7 +15,9 @@ import GHCupDownloads import Data.Aeson ( eitherDecode ) import Data.Aeson.Encode.Pretty +#if !MIN_VERSION_base(4,13,0) import Data.Semigroup ( (<>) ) +#endif import Options.Applicative hiding ( style ) import System.Console.Pretty import System.Exit diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index 627f424..397e3c3 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} @@ -18,6 +19,9 @@ import GHCup.Utils.Logger import GHCup.Utils.Prelude import GHCup.Version +#if !MIN_VERSION_base(4,13,0) +import Control.Monad.Fail ( MonadFail ) +#endif import Control.Monad.Logger import Control.Monad.Reader import Control.Monad.Trans.Resource diff --git a/cabal.project b/cabal.project index 9462b2b..05eabad 100644 --- a/cabal.project +++ b/cabal.project @@ -1,7 +1,5 @@ packages: ./ghcup.cabal -with-compiler: ghc-8.8.3 - optimization: 2 package streamly @@ -16,4 +14,3 @@ package tar-bytestring constraints: http-io-streams -brotli allow-newer: base - diff --git a/cabal.project.freeze b/cabal.project.freeze deleted file mode 100644 index 5c7cb3e..0000000 --- a/cabal.project.freeze +++ /dev/null @@ -1,238 +0,0 @@ -constraints: any.Cabal ==3.0.1.0, - any.HsOpenSSL ==0.11.4.18, - HsOpenSSL -fast-bignum -homebrew-openssl -macports-openssl -old-locale, - any.IfElse ==0.85, - any.QuickCheck ==2.14, - QuickCheck +templatehaskell, - any.StateVar ==1.2, - any.abstract-deque ==0.3, - abstract-deque -usecas, - any.aeson ==1.4.7.1, - aeson -bytestring-builder -cffi -developer -fast, - any.aeson-pretty ==0.8.8, - aeson-pretty -lib-only, - any.alex ==3.2.5, - alex +small_base, - any.ansi-terminal ==0.10.3, - ansi-terminal -example, - any.ansi-wl-pprint ==0.6.9, - ansi-wl-pprint -example, - any.array ==0.5.4.0, - any.ascii-string ==1.0.1.4, - any.assoc ==1.0.1, - any.async ==2.2.2, - async -bench, - any.atomic-primops ==0.8.3, - atomic-primops -debug, - any.attoparsec ==0.13.2.4, - attoparsec -developer, - any.auto-update ==0.1.6, - any.base ==4.13.0.0, - any.base-compat ==0.11.1, - any.base-compat-batteries ==0.11.1, - any.base-orphans ==0.8.2, - any.base-prelude ==1.3, - any.base16-bytestring ==0.1.1.6, - any.base64-bytestring ==1.0.0.3, - any.bifunctors ==5.5.7, - bifunctors +semigroups +tagged, - any.binary ==0.8.7.0, - any.blaze-builder ==0.4.1.0, - any.bytestring ==0.10.10.0, - any.bytestring-builder ==0.10.8.2.0, - bytestring-builder +bytestring_has_builder, - any.bz2 ==1.0.0.2, - bz2 -cross +with-bzlib, - any.c2hs ==0.28.6, - c2hs +base3 -regression, - any.cabal-doctest ==1.0.8, - any.case-insensitive ==1.2.1.0, - any.cereal ==0.5.8.1, - cereal -bytestring-builder, - any.clock ==0.8, - clock -llvm, - any.cmdargs ==0.10.20, - cmdargs +quotation -testprog, - any.colour ==2.3.5, - any.comonad ==5.0.6, - comonad +containers +distributive +test-doctests, - any.concurrent-output ==1.10.11, - any.conduit ==1.3.2, - any.conduit-extra ==1.3.5, - any.containers ==0.6.2.1, - any.contravariant ==1.5.2, - contravariant +semigroups +statevar +tagged, - any.cryptohash-sha256 ==0.11.101.0, - cryptohash-sha256 -exe, - any.data-default-class ==0.1.2.0, - any.data-default-instances-base ==0.1.0.1, - any.deepseq ==1.4.4.0, - any.deferred-folds ==0.9.10.1, - any.directory ==1.3.6.0, - any.distributive ==0.6.1, - distributive +semigroups +tagged, - any.dlist ==0.8.0.8, - any.easy-file ==0.2.2, - any.errors ==2.3.0, - any.exceptions ==0.10.4, - exceptions +transformers-0-4, - any.extra ==1.7.1, - any.fast-logger ==3.0.1, - any.filepath ==1.4.2.1, - any.focus ==1.0.1.3, - any.foldl ==1.4.6, - any.free ==5.1.3, - any.fusion-plugin-types ==0.1.0, - any.generics-sop ==0.5.1.0, - any.ghc-boot-th ==8.8.3, - any.ghc-prim ==0.5.3, - any.happy ==1.19.12, - happy +small_base, - any.hashable ==1.3.0.0, - hashable -examples +integer-gmp +sse2 -sse41, - any.haskell-src-exts ==1.23.0, - any.haskell-src-meta ==0.8.5, - any.haskus-utils-data ==1.2, - any.haskus-utils-types ==1.5, - any.haskus-utils-variant ==3.0, - any.heaps ==0.3.6.1, - any.hpath ==0.11.0, - any.hpath-directory ==0.13.2, - any.hpath-filepath ==0.10.4, - any.hpath-io ==0.13.1, - any.hpath-posix ==0.13.1, - any.hsc2hs ==0.68.7, - hsc2hs -in-ghc-tree, - any.http-io-streams ==0.1.2.0, - http-io-streams -brotli, - any.indexed-profunctors ==0.1, - any.integer-gmp ==1.0.2.0, - any.integer-logarithms ==1.0.3, - integer-logarithms -check-bounds +integer-gmp, - any.io-streams ==1.5.1.0, - io-streams -nointeractivetests, - any.language-bash ==0.9.0, - any.language-c ==0.8.3, - language-c -allwarnings +iecfpextension +separatesyb +usebytestrings, - any.lifted-base ==0.2.3.12, - any.list-t ==1.0.4, - any.lockfree-queue ==0.2.3.1, - any.lzma ==0.0.0.3, - any.math-functions ==0.3.3.0, - math-functions +system-erf +system-expm1, - any.megaparsec ==8.0.0, - megaparsec -dev, - any.mmorph ==1.1.3, - any.monad-control ==1.0.2.3, - any.monad-logger ==0.3.32, - monad-logger +template_haskell, - any.monad-loops ==0.4.3, - monad-loops +base4, - any.mono-traversable ==1.0.15.1, - any.mtl ==2.2.2, - any.mwc-random ==0.14.0.0, - any.network ==3.1.1.1, - any.network-uri ==2.6.3.0, - any.old-locale ==1.0.0.7, - any.old-time ==1.1.0.3, - any.openssl-streams ==1.2.2.0, - any.optics ==0.2, - any.optics-core ==0.2, - any.optics-extra ==0.2, - any.optics-th ==0.2, - any.optics-vl ==0.2, - any.optparse-applicative ==0.15.1.0, - any.parsec ==3.1.14.0, - any.parser-combinators ==1.2.1, - parser-combinators -dev, - any.pretty ==1.1.3.6, - any.pretty-terminal ==0.1.0.0, - any.prettyprinter ==1.6.1, - prettyprinter -buildreadme, - any.primitive ==0.7.0.1, - any.primitive-extras ==0.8, - any.primitive-unlifted ==0.1.3.0, - any.process ==1.6.8.0, - any.profunctors ==5.5.2, - any.random ==1.1, - any.recursion-schemes ==5.1.3, - recursion-schemes +template-haskell, - any.regex-base ==0.94.0.0, - any.regex-posix ==0.96.0.0, - regex-posix -_regex-posix-clib, - any.resourcet ==1.2.3, - any.rts ==1.0, - any.safe ==0.3.18, - any.safe-exceptions ==0.1.7.0, - any.scientific ==0.3.6.2, - scientific -bytestring-builder -integer-simple, - any.semigroupoids ==5.3.4, - semigroupoids +comonad +containers +contravariant +distributive +doctests +tagged +unordered-containers, - any.semigroups ==0.19.1, - semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers, - any.sop-core ==0.5.0.1, - any.split ==0.2.3.4, - any.splitmix ==0.0.4, - splitmix -optimised-mixer +random, - any.stm ==2.5.0.0, - any.stm-chans ==3.0.0.4, - any.streaming-commons ==0.2.1.2, - streaming-commons -use-bytestring-builder, - any.streamly ==0.7.1, - streamly -debug -dev -examples -examples-sdl -fusion-plugin -has-llvm -inspection -no-charts -no-fusion -streamk, - any.streamly-bytestring ==0.1.2, - any.streamly-posix ==0.1.0.0, - any.strict-base ==0.4.0.0, - any.string-interpolate ==0.2.0.0, - any.syb ==0.7.1, - any.table-layout ==0.8.0.5, - any.tagged ==0.8.6, - tagged +deepseq +transformers, - any.tar-bytestring ==0.6.3.2, - any.template-haskell ==2.15.0.0, - any.terminal-progress-bar ==0.4.1, - any.terminal-size ==0.3.2.1, - any.text ==1.2.4.0, - any.text-conversions ==0.3.0, - any.text-short ==0.1.3, - text-short -asserts, - any.th-abstraction ==0.3.2.0, - any.th-expand-syns ==0.4.6.0, - any.th-lift ==0.8.1, - any.th-lift-instances ==0.1.15, - any.th-orphans ==0.13.9, - any.th-reify-many ==0.1.9, - any.these ==1.0.1, - these +aeson +assoc +quickcheck +semigroupoids, - any.time ==1.9.3, - any.time-compat ==1.9.3, - time-compat -old-locale, - any.transformers ==0.5.6.2, - any.transformers-base ==0.4.5.2, - transformers-base +orphaninstances, - any.transformers-compat ==0.6.5, - transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, - any.typed-process ==0.2.6.0, - any.unix ==2.7.2.2, - any.unix-bytestring ==0.3.7.3, - any.unix-compat ==0.5.2, - unix-compat -old-time, - any.unix-time ==0.4.7, - any.unliftio-core ==0.2.0.1, - any.unordered-containers ==0.2.10.0, - unordered-containers -debug, - any.uri-bytestring ==0.3.2.2, - uri-bytestring -lib-werror, - any.utf8-string ==1.0.1.1, - any.uuid-types ==1.0.3, - any.vector ==0.12.1.2, - vector +boundschecks -internalchecks -unsafechecks -wall, - any.vector-algorithms ==0.8.0.3, - vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks, - any.vector-builder ==0.3.8, - any.vector-th-unbox ==0.2.1.7, - any.versions ==3.5.3, - any.word8 ==0.1.3, - any.zlib ==0.6.2.1, - zlib -non-blocking-ffi -pkg-config, - any.zlib-bindings ==0.1.1.5 diff --git a/ghcup.cabal b/ghcup.cabal index 82603d1..6aee8b9 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -277,8 +277,6 @@ library , word8 , zlib - -- deps - -- cabal-fmt: expand lib exposed-modules: GHCup GHCup.Download diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 8f32580..def539d 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} @@ -28,6 +29,9 @@ import GHCup.Version import Control.Applicative import Control.Exception.Safe import Control.Monad +#if !MIN_VERSION_base(4,13,0) +import Control.Monad.Fail ( MonadFail ) +#endif import Control.Monad.Logger import Control.Monad.Reader import Control.Monad.Trans.Resource diff --git a/lib/GHCup/Download.hs b/lib/GHCup/Download.hs index f24efef..9c2358a 100644 --- a/lib/GHCup/Download.hs +++ b/lib/GHCup/Download.hs @@ -28,18 +28,25 @@ import GHCup.Version import Control.Applicative import Control.Exception.Safe import Control.Monad +#if !MIN_VERSION_base(4,13,0) +import Control.Monad.Fail ( MonadFail ) +#endif import Control.Monad.Logger import Control.Monad.Reader import Control.Monad.Trans.Resource hiding ( throwM ) import Data.Aeson +#if !defined(CURL) import Data.ByteString ( ByteString ) import Data.CaseInsensitive ( CI ) +#endif import Data.Maybe import Data.String.Interpolate import Data.Time.Clock import Data.Time.Clock.POSIX +#if !defined(CURL) import Data.Time.Format +#endif import Data.Versions import GHC.IO.Exception import HPath @@ -56,9 +63,11 @@ import URI.ByteString import qualified Crypto.Hash.SHA256 as SHA256 import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Lazy as L +#if !defined(CURL) import qualified Data.CaseInsensitive as CI import qualified Data.Map.Strict as M import qualified Data.Text as T +#endif import qualified Data.Text.Encoding as E import qualified System.Posix.Files.ByteString as PF import qualified System.Posix.RawFilePath.Directory @@ -177,7 +186,6 @@ getDownloads urlSource = do $ getHead uri' ) pure $ parseModifiedHeader headers -#endif parseModifiedHeader :: (M.Map (CI ByteString) ByteString) -> Maybe UTCTime parseModifiedHeader headers = @@ -187,6 +195,8 @@ getDownloads urlSource = do "%a, %d %b %Y %H:%M:%S %Z" (T.unpack . E.decodeUtf8 $ h) +#endif + writeFileWithModTime :: UTCTime -> Path Abs -> L.ByteString -> IO () writeFileWithModTime utctime path content = do let mod_time = utcTimeToPOSIXSeconds utctime @@ -377,8 +387,8 @@ downloadBS uri' where scheme = view (uriSchemeL' % schemeBSL') uri' path = view pathL' uri' - dl https = do #if defined(CURL) + dl _ = do let exe = [rel|curl|] args = ["-sSfL", serializeURIRef' uri'] liftIO (executeOut exe args Nothing) >>= \case @@ -386,6 +396,7 @@ downloadBS uri' pure $ L.fromStrict stdout CapturedProcess (ExitFailure i') _ _ -> throwE $ NonZeroExit i' (toFilePath exe) args #else + dl https = do (_, host', fullPath', port') <- liftE $ uriToQuadruple uri' liftE $ downloadBS' https host' fullPath' port' #endif diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 592db4b..659ff01 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} @@ -22,6 +23,9 @@ import GHCup.Utils.Prelude import Control.Applicative import Control.Exception.Safe import Control.Monad +#if !MIN_VERSION_base(4,13,0) +import Control.Monad.Fail ( MonadFail ) +#endif import Control.Monad.Logger import Control.Monad.Reader import Data.Attoparsec.ByteString @@ -293,7 +297,7 @@ urlBaseName :: MonadThrow m urlBaseName = parseRel . snd . B.breakEnd (== _slash) . urlDecode False --- Get tool files from ~/.ghcup/bin/ghc//bin/* +-- Get tool files from '~/.ghcup/bin/ghc//bin/*' -- while ignoring *- symlinks. -- -- Returns unversioned relative files, e.g.: diff --git a/lib/GHCup/Utils/File.hs b/lib/GHCup/Utils/File.hs index fcd0d28..a49fcde 100644 --- a/lib/GHCup/Utils/File.hs +++ b/lib/GHCup/Utils/File.hs @@ -232,7 +232,7 @@ execLogged exe spath args lfile chdir env = do readTilEOF action' fd' = do bs <- readLine fd' - action' bs + void $ action' bs readTilEOF action' fd' @@ -309,7 +309,7 @@ captureOutStreams action = do readTilEOF ~action' fd' = do bs <- SPIB.fdRead fd' 512 - action' bs + void $ action' bs readTilEOF action' fd' diff --git a/lib/GHCup/Utils/Version/QQ.hs b/lib/GHCup/Utils/Version/QQ.hs index 73b1deb..0938d1e 100644 --- a/lib/GHCup/Utils/Version/QQ.hs +++ b/lib/GHCup/Utils/Version/QQ.hs @@ -1,4 +1,5 @@ {-# OPTIONS_GHC -Wno-orphans #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveLift #-} {-# LANGUAGE FlexibleInstances #-} @@ -11,6 +12,9 @@ module GHCup.Utils.Version.QQ where import Data.Data import Data.Text ( Text ) import Data.Versions +#if !MIN_VERSION_base(4,13,0) +import GHC.Base +#endif import Language.Haskell.TH import Language.Haskell.TH.Quote ( QuasiQuoter(..) ) import Language.Haskell.TH.Syntax ( Lift @@ -36,6 +40,11 @@ deriving instance Data VSep deriving instance Lift VUnit deriving instance Data VUnit +#if !MIN_VERSION_base(4,13,0) +deriving instance Lift (NonEmpty Word) +instance Lift Text +#endif + qq :: (Text -> Q Exp) -> QuasiQuoter qq quoteExp' = QuasiQuoter { quoteExp = (\s -> quoteExp' . T.pack $ s)