diff --git a/.gitlab/script/ghcup_release.sh b/.gitlab/script/ghcup_release.sh index 63235d9..b50f3cf 100755 --- a/.gitlab/script/ghcup_release.sh +++ b/.gitlab/script/ghcup_release.sh @@ -14,11 +14,11 @@ ecabal() { ecabal update if [ "${OS}" = "LINUX" ] ; then - ecabal build -w ghc-${GHC_VERSION} -fcurl --ghc-options='-split-sections -optl-static' + ecabal build -w ghc-${GHC_VERSION} --ghc-options='-split-sections -optl-static' elif [ "${OS}" = "FREEBSD" ] ; then - ecabal build -w ghc-${GHC_VERSION} -fcurl --ghc-options='-split-sections' + ecabal build -w ghc-${GHC_VERSION} --ghc-options='-split-sections' else - ecabal build -w ghc-${GHC_VERSION} -fcurl + ecabal build -w ghc-${GHC_VERSION} fi mkdir out diff --git a/.gitlab/script/ghcup_version.sh b/.gitlab/script/ghcup_version.sh index 07d8648..c342cf7 100755 --- a/.gitlab/script/ghcup_version.sh +++ b/.gitlab/script/ghcup_version.sh @@ -20,9 +20,9 @@ eghcup() { ecabal update if [ "${OS}" = "DARWIN" ] ; then - ecabal build -w ghc-${GHC_VERSION} -fcurl -else ecabal build -w ghc-${GHC_VERSION} +else + ecabal build -w ghc-${GHC_VERSION} -finternal-downloader fi cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup')" . diff --git a/ghcup.cabal b/ghcup.cabal index e616f6e..bceecf1 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -21,8 +21,8 @@ source-repository head type: git location: https://gitlab.haskell.org/haskell/ghcup-hs.git -flag Curl - description: Use curl instead of http-io-streams for download +flag internal-downloader + description: Compile the internal downloader, which links against OpenSSL default: False manual: True @@ -304,15 +304,14 @@ library -- other-extensions: hs-source-dirs: lib - if !flag(curl) + if flag(internal-downloader) import: , HsOpenSSL , http-io-streams , io-streams , terminal-progress-bar exposed-modules: GHCup.Download.IOStreams - else - cpp-options: -DCURL + cpp-options: -DINTERNAL_DOWNLOADER executable ghcup import: diff --git a/lib/GHCup/Download.hs b/lib/GHCup/Download.hs index a79c5be..93b2ccf 100644 --- a/lib/GHCup/Download.hs +++ b/lib/GHCup/Download.hs @@ -11,7 +11,7 @@ module GHCup.Download where -#if !defined(CURL) +#if defined(INTERNAL_DOWNLOADER) import GHCup.Download.IOStreams import GHCup.Download.Utils #endif @@ -35,7 +35,7 @@ import Control.Monad.Reader import Control.Monad.Trans.Resource hiding ( throwM ) import Data.Aeson -#if !defined(CURL) +#if defined(INTERNAL_DOWNLOADER) import Data.ByteString ( ByteString ) import Data.CaseInsensitive ( CI ) #endif @@ -43,7 +43,7 @@ import Data.Maybe import Data.String.Interpolate import Data.Time.Clock import Data.Time.Clock.POSIX -#if !defined(CURL) +#if defined(INTERNAL_DOWNLOADER) import Data.Time.Format #endif import Data.Versions @@ -62,7 +62,7 @@ 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) +#if defined(INTERNAL_DOWNLOADER) import qualified Data.CaseInsensitive as CI import qualified Data.Map.Strict as M import qualified Data.Text as T @@ -220,7 +220,7 @@ getDownloads urlSource = do getModTime = do -#if defined(CURL) +#if !defined(INTERNAL_DOWNLOADER) pure Nothing #else headers <- @@ -319,7 +319,7 @@ download dli dest mfn (liftIO $ hideError doesNotExistErrorType $ deleteFile destFile) >> (throwE . DownloadFailed $ e) ) $ do -#if defined(CURL) +#if !defined(INTERNAL_DOWNLOADER) liftE $ lEM @_ @'[ProcessError] $ liftIO $ exec "curl" True ["-fL", "-o", toFilePath destFile , serializeURIRef' $ view dlUri dli] Nothing Nothing #else @@ -404,7 +404,7 @@ downloadBS uri' where scheme = view (uriSchemeL' % schemeBSL') uri' path = view pathL' uri' -#if defined(CURL) +#if !defined(INTERNAL_DOWNLOADER) dl _ = do lift $ $(logDebug) [i|downloading: #{serializeURIRef' uri'}|] let exe = [rel|curl|]