diff --git a/Cabal/Distribution/Compat/Directory.hs b/Cabal/Distribution/Compat/Directory.hs index 6bc4b07b861..07330951c01 100644 --- a/Cabal/Distribution/Compat/Directory.hs +++ b/Cabal/Distribution/Compat/Directory.hs @@ -38,7 +38,12 @@ makeAbsolute p | Path.isAbsolute p = return p #if !MIN_VERSION_directory(1,2,7) doesPathExist :: FilePath -> IO Bool -doesPathExist path = (||) <$> doesDirectoryExist path <*> doesFileExist path +doesPathExist path = do + -- not using Applicative, as this way we can do less IO + e <- doesDirectoryExist path + if e + then return True + else doesFileExist path #endif diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index 51d4335c6d2..19bff1a7648 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -305,31 +305,31 @@ executable cabal Paths_cabal_install build-depends: - async >= 2.0 && < 3, + async >= 2.0 && < 2.3, array >= 0.4 && < 0.6, - base >= 4.6 && < 5, + base >= 4.8 && < 4.13, base16-bytestring >= 0.1.1 && < 0.2, - binary >= 0.7 && < 0.9, - bytestring >= 0.10.2 && < 1, + binary >= 0.7.3 && < 0.9, + bytestring >= 0.10.6.0 && < 0.11, Cabal == 2.5.*, - containers >= 0.5 && < 0.7, + containers >= 0.5.6.2 && < 0.7, cryptohash-sha256 >= 0.11 && < 0.12, - deepseq >= 1.3 && < 1.5, + deepseq >= 1.4.1.1 && < 1.5, directory >= 1.2.2.0 && < 1.4, echo >= 0.1.3 && < 0.2, edit-distance >= 0.2.2 && < 0.3, - filepath >= 1.3 && < 1.5, - hashable >= 1.0 && < 2, + filepath >= 1.4.0.0 && < 1.5, + hashable >= 1.0 && < 1.3, HTTP >= 4000.1.5 && < 4000.4, - mtl >= 2.0 && < 3, + mtl >= 2.0 && < 2.3, network-uri >= 2.6.0.2 && < 2.7, network >= 2.6 && < 2.9, pretty >= 1.1 && < 1.2, - process >= 1.1.0.2 && < 1.7, + process >= 1.2.3.0 && < 1.7, random >= 1 && < 1.2, - stm >= 2.0 && < 3, + stm >= 2.0 && < 2.6, tar >= 0.5.0.3 && < 0.6, - time >= 1.4 && < 1.10, + time >= 1.5.0.1 && < 1.10, zlib >= 0.5.3 && < 0.7, hackage-security >= 0.5.2.2 && < 0.6, text >= 1.2.3 && < 1.3, diff --git a/cabal-install/cabal-install.cabal.pp b/cabal-install/cabal-install.cabal.pp index f83bad117c8..b0f64c24643 100644 --- a/cabal-install/cabal-install.cabal.pp +++ b/cabal-install/cabal-install.cabal.pp @@ -16,31 +16,31 @@ # %def CABAL_BUILDDEPENDS build-depends: - async >= 2.0 && < 3, + async >= 2.0 && < 2.3, array >= 0.4 && < 0.6, - base >= 4.6 && < 5, + base >= 4.8 && < 4.13, base16-bytestring >= 0.1.1 && < 0.2, - binary >= 0.7 && < 0.9, - bytestring >= 0.10.2 && < 1, + binary >= 0.7.3 && < 0.9, + bytestring >= 0.10.6.0 && < 0.11, Cabal == 2.5.*, - containers >= 0.5 && < 0.7, + containers >= 0.5.6.2 && < 0.7, cryptohash-sha256 >= 0.11 && < 0.12, - deepseq >= 1.3 && < 1.5, + deepseq >= 1.4.1.1 && < 1.5, directory >= 1.2.2.0 && < 1.4, echo >= 0.1.3 && < 0.2, edit-distance >= 0.2.2 && < 0.3, - filepath >= 1.3 && < 1.5, - hashable >= 1.0 && < 2, + filepath >= 1.4.0.0 && < 1.5, + hashable >= 1.0 && < 1.3, HTTP >= 4000.1.5 && < 4000.4, - mtl >= 2.0 && < 3, + mtl >= 2.0 && < 2.3, network-uri >= 2.6.0.2 && < 2.7, network >= 2.6 && < 2.9, pretty >= 1.1 && < 1.2, - process >= 1.1.0.2 && < 1.7, + process >= 1.2.3.0 && < 1.7, random >= 1 && < 1.2, - stm >= 2.0 && < 3, + stm >= 2.0 && < 2.6, tar >= 0.5.0.3 && < 0.6, - time >= 1.4 && < 1.10, + time >= 1.5.0.1 && < 1.10, zlib >= 0.5.3 && < 0.7, hackage-security >= 0.5.2.2 && < 0.6, text >= 1.2.3 && < 1.3, diff --git a/cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs b/cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs index 0142cc6d162..4879149060c 100644 --- a/cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs +++ b/cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs @@ -1,7 +1,8 @@ import Test.Cabal.Prelude import Data.Maybe -import System.Directory +import Distribution.Compat.Directory import Control.Monad.IO.Class + main = cabalTest $ do withPackageDb $ do withSandbox $ do diff --git a/cabal-testsuite/Test/Cabal/Server.hs b/cabal-testsuite/Test/Cabal/Server.hs index c05e521b227..fd0f9043ca8 100644 --- a/cabal-testsuite/Test/Cabal/Server.hs +++ b/cabal-testsuite/Test/Cabal/Server.hs @@ -254,9 +254,15 @@ initServer s0 = do #else pid <- withProcessHandle (serverProcessHandle s0) $ \ph -> case ph of +#if MIN_VERSION_process(1,2,0) OpenHandle x -> return (show x) -- TODO: handle OpenExtHandle? _ -> return (serverProcessId s0) +#else + OpenHandle x -> return (ph, show x) + -- TODO: handle OpenExtHandle? + _ -> return (ph, serverProcessId s0) +#endif #endif let s = s0 { serverProcessId = pid } -- We will read/write a line at a time, including for diff --git a/cabal-testsuite/main/cabal-tests.hs b/cabal-testsuite/main/cabal-tests.hs index aac729eea80..e3424f542a1 100644 --- a/cabal-testsuite/main/cabal-tests.hs +++ b/cabal-testsuite/main/cabal-tests.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE NondecreasingIndentation #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -20,13 +21,25 @@ import Control.Monad import qualified Control.Exception as E import GHC.Conc (numCapabilities) import Data.List -import Data.Monoid (mempty, (<>)) import Text.Printf import qualified System.Clock as Clock import System.IO import System.FilePath import System.Exit -import System.Process (callProcess, showCommandForUser) +import System.Process ( +#if MIN_VERSION_process(1,2,0) + callProcess, +#else + proc, createProcess, waitForProcess, terminateProcess, +#endif + showCommandForUser) + +#if !MIN_VERSION_base(4,12,0) +import Data.Monoid ((<>)) +#endif +#if !MIN_VERSION_base(4,8,0) +import Data.Monoid (mempty) +#endif -- | Record for arguments that can be passed to @cabal-tests@ executable. data MainArgs = MainArgs { @@ -298,3 +311,20 @@ getTime = do t <- Clock.getTime Clock.Monotonic let ns = realToFrac $ Clock.toNanoSecs t return $ ns / 10 ^ (9 :: Int) + +------------------------------------------------------------------------------- +-- compat +------------------------------------------------------------------------------- + +#if !MIN_VERSION_process(1,2,0) +callProcess :: FilePath -> [String] -> IO () +callProcess cmd args = do + exit_code <- bracket (createProcess (proc cmd args)) cleanupProcess + $ \(_, _, _, ph) -> waitForProcess ph + case exit_code of + ExitSuccess -> return () + ExitFailure r -> fail $ "processFailedException " ++ show (cmd, args, r) + where + cleanupProcess (_, _, _, ph) = terminateProcess ph + +#endif diff --git a/cabal.project b/cabal.project index 71a1156d389..829ee4eb01b 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,4 @@ packages: Cabal/ cabal-testsuite/ cabal-install/ solver-benchmarks/ pretty-show-1.6.16/ -constraints: unix >= 2.7.1.0 -- Uncomment to allow picking up extra local unpacked deps: --optional-packages: */ diff --git a/cabal.project.local.travis b/cabal.project.local.travis new file mode 100644 index 00000000000..9e740101cea --- /dev/null +++ b/cabal.project.local.travis @@ -0,0 +1,32 @@ +-- Force error messages to be better +-- Parallel new-build error messages are non-existent. +-- Turn off parallelization to get good errors. +jobs: 1 + +-- We vendor a copy of hackage-repo-tool so that we can +-- build it reliably. If we eventually get new-install +-- in the bootstrap, this can go away. +optional-packages: hackage-repo-tool-*/ +-- hackage-repo-tool has upper bound on time +allow-newer: hackage-repo-tool:time + +-- The -fno-warn-orphans is a hack to make Cabal-1.24 +-- build properly (unfortunately the flags here get applied +-- to the dependencies too!) +package Cabal + ghc-options: -Werror -fno-warn-orphans + +constraints: + binary installed, + bytestring installed, + containers installed, + deepseq installed, + directory installed, + filepath installed, + pretty installed, + process installed, + time installed, + unix installed + +package cabal-install + ghc-options: -Werror diff --git a/cabal.project.travis.libonly b/cabal.project.travis.libonly new file mode 100644 index 00000000000..6cc029bd1d5 --- /dev/null +++ b/cabal.project.travis.libonly @@ -0,0 +1,24 @@ +-- A copy of cabal.project, but with a trimmed down 'packages' +-- field. Needed for LIB_ONLY configurations that can't build cabal-install, +-- only lib:Cabal. + +packages: Cabal/ cabal-testsuite/ + +-- Uncomment to allow picking up extra local unpacked deps: +--optional-packages: */ + +program-options + -- So us hackers get all the assertion failures early: + -- + -- NOTE: currently commented out, see + -- https://github.com/haskell/cabal/issues/3911 + -- + -- ghc-options: -fno-ignore-asserts + -- + -- as a workaround we specify it for each package individually: +package Cabal + ghc-options: -fno-ignore-asserts +package cabal-testsuite + ghc-options: -fno-ignore-asserts +package cabal-install + ghc-options: -fno-ignore-asserts diff --git a/cabal.project.validate b/cabal.project.validate index 68973f49550..1c2fc689abf 100644 --- a/cabal.project.validate +++ b/cabal.project.validate @@ -1,8 +1,6 @@ -packages: Cabal/ cabal-testsuite/ cabal-install/ +packages: Cabal/ cabal-testsuite/ package Cabal ghc-options: -Werror -fno-ignore-asserts package cabal-testsuite ghc-options: -Werror -fno-ignore-asserts -package cabal-install - ghc-options: -Werror -fno-ignore-asserts diff --git a/travis-script.sh b/travis-script.sh index a2fa2455ab6..80724b6c23d 100755 --- a/travis-script.sh +++ b/travis-script.sh @@ -82,10 +82,13 @@ timed cabal update # --------------------------------------------------------------------- make cabal-install-monolithic -cp cabal.project.travis cabal.project.local +if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then + cp cabal.project.travis.libonly cabal.project +fi +cp cabal.project.local.travis cabal.project.local # hackage-repo-tool is a bit touchy to install on GHC 8.0, so instead we -# do it via new-build. See also cabal.project.travis. The downside of +# do it via new-build. See also cabal.project.local.travis. The downside of # doing it this way is that the build product cannot be cached, but # hackage-repo-tool is a relatively small package so it's good. timed cabal unpack hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}