Skip to content

Commit

Permalink
Merge pull request #6401 from phadej/backport-batch-2
Browse files Browse the repository at this point in the history
Backport batch 2 into 3.0
  • Loading branch information
phadej authored Dec 4, 2019
2 parents b12ac19 + 2245d56 commit 6279b6f
Show file tree
Hide file tree
Showing 30 changed files with 340 additions and 410 deletions.
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Note: some cabal-testsuite tests need .git, so we cannot ignore that.

cabal.project.local
.ghc.environment.*

**/.hpc
**/*.hi
**/*.o
**/*.p_hi
**/*.prof
**/*.tix

**/*.sw*

**/Setup
**/*.dist

Cabal/dist/
Cabal/.python-sphinx-virtualenv/
Cabal/tests/Setup
Cabal/Setup
Cabal/source-file-list

cabal-install/dist/
cabal-install/Setup
cabal-install/source-file-list

.github/
dist-newstyle/
dist-newstyle-*/

Cabal/.python-sphinx-virtualenv
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ matrix:
- env: GHCVER=8.6.5 SCRIPT=script USE_GOLD=YES
os: linux
sudo: required
- env: GHCVER=8.8.1 SCRIPT=script USE_GOLD=YES
os: linux
sudo: required
#- env: GHCVER=8.8.1 SCRIPT=script USE_GOLD=YES
# os: linux
# sudo: required
Expand Down Expand Up @@ -125,7 +128,7 @@ before_install:
- export PATH=$HOME/bin:$PATH
- export PATH=$HOME/.cabal/bin:$PATH
- export PATH=$HOME/.local/bin:$PATH
- export PATH=/opt/cabal/2.4/bin:$PATH
- export PATH=/opt/cabal/3.0/bin:$PATH
- if [ "$USE_GOLD" = "YES" ]; then sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20; fi
- if [ "$USE_GOLD" = "YES" ]; then sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10; fi
- ld -v
Expand Down
30 changes: 16 additions & 14 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ library
ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs
if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances
-Wnoncanonical-monadfail-instances
else
if impl(ghc <8.8)
ghc-options: -Wnoncanonical-monadfail-instances

if !impl(ghc >= 8.0)
-- at least one of lib:Cabal's dependency (i.e. `parsec`)
-- already depends on `fail` and `semigroups` transitively
build-depends: fail == 4.9.*, semigroups >= 0.18.3 && < 0.20
Expand Down Expand Up @@ -605,14 +607,14 @@ test-suite unit-tests
directory,
filepath,
integer-logarithms >= 1.0.2 && <1.1,
tasty >= 1.1.0.3 && < 1.2,
tasty >= 1.2.3 && < 1.3,
tasty-hunit,
tasty-quickcheck,
tagged,
temporary,
text,
pretty,
QuickCheck >= 2.11.3 && < 2.12,
QuickCheck >= 2.13.2 && < 2.14,
Cabal
ghc-options: -Wall
default-language: Haskell2010
Expand All @@ -623,22 +625,22 @@ test-suite parser-tests
main-is: ParserTests.hs
build-depends:
base,
base-compat >=0.10.4 && <0.11,
base-compat >=0.11.0 && <0.12,
bytestring,
directory,
filepath,
tasty >= 1.1.0.3 && < 1.2,
tasty >= 1.2.3 && < 1.3,
tasty-hunit,
tasty-quickcheck,
tasty-golden >=2.3.1.1 && <2.4,
Diff >=0.3.4 && <0.4,
Diff >=0.4 && <0.5,
Cabal
ghc-options: -Wall
default-language: Haskell2010

if impl(ghc >= 7.8)
build-depends:
tree-diff >= 0.0.2 && <0.1
tree-diff >= 0.1 && <0.2
other-modules:
Instances.TreeDiff
Instances.TreeDiff.Language
Expand All @@ -654,9 +656,9 @@ test-suite check-tests
bytestring,
directory,
filepath,
tasty >= 1.1.0.3 && < 1.2,
tasty >= 1.2.3 && < 1.3,
tasty-golden >=2.3.1.1 && <2.4,
Diff >=0.3.4 && <0.4,
Diff >=0.4 && <0.5,
Cabal
ghc-options: -Wall
default-language: Haskell2010
Expand Down Expand Up @@ -696,15 +698,15 @@ test-suite hackage-tests
filepath

build-depends:
base-compat >=0.10.4 && <0.11,
base-compat >=0.11.0 && <0.12,
base-orphans >=0.6 && <0.9,
optparse-applicative >=0.13.2.0 && <0.15,
optparse-applicative >=0.13.2.0 && <0.16,
stm >=2.4.5.0 && <2.6,
tar >=0.5.0.3 && <0.6

if impl(ghc >= 7.8)
build-depends:
tree-diff >= 0.0.2 && <0.1
tree-diff >= 0.1 && <0.2
other-modules:
Instances.TreeDiff
Instances.TreeDiff.Language
Expand All @@ -726,7 +728,7 @@ test-suite rpmvercmp
bytestring

build-depends:
tasty >= 1.1.0.3 && < 1.2,
tasty >= 1.2.3 && < 1.3,
tasty-hunit,
tasty-quickcheck,
QuickCheck
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/CheckTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Main
import Test.Tasty
import Test.Tasty.Golden.Advanced (goldenTest)

import Data.Algorithm.Diff (Diff (..), getGroupedDiff)
import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff)
import Distribution.Fields (runParseResult)
import Distribution.PackageDescription.Check (checkPackage)
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Test.Tasty.Golden.Advanced (goldenTest)
import Test.Tasty.HUnit

import Control.Monad (unless, void)
import Data.Algorithm.Diff (Diff (..), getGroupedDiff)
import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff)
import Data.Maybe (isNothing)
import Distribution.Fields (runParseResult)
import Distribution.PackageDescription (GenericPackageDescription)
Expand Down
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LEXER_HS:=Cabal/Distribution/Fields/Lexer.hs
SPDX_LICENSE_HS:=Cabal/Distribution/SPDX/LicenseId.hs
SPDX_EXCEPTION_HS:=Cabal/Distribution/SPDX/LicenseExceptionId.hs

CABALBUILD := cabal new-build --enable-tests
CABALRUN := cabal new-run --enable-tests
CABALBUILD := cabal v2-build
CABALRUN := cabal v2-run

# default rules

Expand All @@ -19,6 +19,10 @@ lib : $(LEXER_HS)
exe : $(LEXER_HS)
$(CABALBUILD) cabal-install:exes

# Build library with oldest supported GHC
lib-ghc-7.6 :
$(CABALBUILD) --project-file=cabal.project.libonly --with-compiler=ghc-7.6.3 Cabal:libs

# source generation: Lexer

lexer : $(LEXER_HS)
Expand All @@ -33,10 +37,10 @@ $(LEXER_HS) : boot/Lexer.x
spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)

$(SPDX_LICENSE_HS) : boot/SPDX.LicenseId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDX.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json
cabal new-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx -- boot/SPDX.LicenseId.template.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json license-list-data/licenses-3.6.json $(SPDX_LICENSE_HS)
cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx -- boot/SPDX.LicenseId.template.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json license-list-data/licenses-3.6.json $(SPDX_LICENSE_HS)

$(SPDX_EXCEPTION_HS) : boot/SPDX.LicenseExceptionId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDXExc.hs license-list-data/exceptions-3.0.json license-list-data/exceptions-3.2.json
cabal new-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx-exc -- boot/SPDX.LicenseExceptionId.template.hs license-list-data/exceptions-3.0.json license-list-data/exceptions-3.2.json license-list-data/exceptions-3.6.json $(SPDX_EXCEPTION_HS)
cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx-exc -- boot/SPDX.LicenseExceptionId.template.hs license-list-data/exceptions-3.0.json license-list-data/exceptions-3.2.json license-list-data/exceptions-3.6.json $(SPDX_EXCEPTION_HS)

# cabal-install.cabal file generation

Expand All @@ -59,21 +63,21 @@ cabal-install-monolithic : cabal-install/cabal-install.cabal.pp
gen-extra-source-files : gen-extra-source-files-lib gen-extra-source-files-cli

gen-extra-source-files-lib :
cabal new-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-extra-source-files -- $$(pwd)/Cabal/Cabal.cabal
cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-extra-source-files -- $$(pwd)/Cabal/Cabal.cabal

# We need to generate cabal-install-dev so the test modules are in .cabal file!
gen-extra-source-files-cli :
$(MAKE) cabal-install-dev
cabal new-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-extra-source-files -- $$(pwd)/cabal-install/cabal-install.cabal.pp $$(pwd)/cabal-install/cabal-install.cabal
cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-extra-source-files -- $$(pwd)/cabal-install/cabal-install.cabal.pp $$(pwd)/cabal-install/cabal-install.cabal
$(MAKE) cabal-install-prod

# ghcid

ghcid-lib :
ghcid -c 'cabal new-repl Cabal'
ghcid -c 'cabal v2-repl Cabal'

ghcid-cli :
ghcid -c 'cabal new-repl cabal-install'
ghcid -c 'cabal v2-repl cabal-install'

# doctests (relies on .ghc.environment files)

Expand All @@ -83,7 +87,7 @@ doctest :
# tests

check-tests :
$(CABALRUN) --enable-tests check-tests -- --cwd Cabal ${TEST}
$(CABALRUN) check-tests -- --cwd Cabal ${TEST}

parser-tests :
$(CABALRUN) parser-tests -- --cwd Cabal ${TEST}
Expand All @@ -105,3 +109,6 @@ cabal-install-test:
$(CABALBUILD) -j3 cabal-tests cabal
rm -rf .ghc.environment.*
cd cabal-testsuite && `cabal-plan list-bin cabal-tests` --with-cabal=`cabal-plan list-bin cabal` --hide-successes -j3 ${TEST}

validate-via-docker:
docker build -t cabal-validate -f validate.dockerfile .
4 changes: 3 additions & 1 deletion cabal-install/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ module Distribution.Client.CmdBuild (
selectComponentTarget
) where

import Prelude ()
import Distribution.Client.Compat.Prelude

import Distribution.Client.ProjectOrchestration
import Distribution.Client.CmdErrorMessages

import Distribution.Compat.Semigroup ((<>))
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags
, liftOptions, yesNoOpt )
Expand Down
18 changes: 8 additions & 10 deletions cabal-install/Distribution/Client/CmdSdist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module Distribution.Client.CmdSdist
, SdistFlags(..), defaultSdistFlags
, OutputFormat(..)) where

import Prelude ()
import Distribution.Client.Compat.Prelude

import Distribution.Client.CmdErrorMessages
( Plural(..), renderComponentKind )
import Distribution.Client.ProjectOrchestration
Expand All @@ -29,9 +32,6 @@ import Distribution.Client.DistDirLayout
import Distribution.Client.ProjectConfig
( findProjectRoot, readProjectConfig )

import Distribution.Compat.Semigroup
((<>))

import Distribution.Package
( Package(packageId) )
import Distribution.PackageDescription.Configuration
Expand Down Expand Up @@ -64,8 +64,6 @@ import qualified Codec.Archive.Tar.Entry as Tar
import qualified Codec.Compression.GZip as GZip
import Control.Exception
( throwIO )
import Control.Monad
( when, forM_ )
import Control.Monad.Trans
( liftIO )
import Control.Monad.State.Lazy
Expand All @@ -77,7 +75,7 @@ import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.Either
( partitionEithers )
import Data.List
( find, sortOn, nub )
( sortOn )
import qualified Data.Set as Set
import System.Directory
( getCurrentDirectory, setCurrentDirectory
Expand Down Expand Up @@ -192,7 +190,7 @@ sdistAction SdistFlags{..} targetStrings globalFlags = do
| length pkgs > 1, not listSources, Just "-" <- mOutputPath' ->
die' verbosity "Can't write multiple tarballs to standard output!"
| otherwise ->
mapM_ (\pkg -> packageToSdist verbosity (distProjectRootDirectory distLayout) format (outputPath pkg) pkg) pkgs
traverse_ (\pkg -> packageToSdist verbosity (distProjectRootDirectory distLayout) format (outputPath pkg) pkg) pkgs

data IsExec = Exec | NoExec
deriving (Show, Eq)
Expand Down Expand Up @@ -256,7 +254,7 @@ packageToSdist verbosity projectRootDir format outputFile pkg = do
Left err -> liftIO $ die' verbosity ("Error packing sdist: " ++ err)
Right path -> tell [Tar.directoryEntry path]

forM_ files $ \(perm, file) -> do
for_ files $ \(perm, file) -> do
let fileDir = takeDirectory (prefix </> file)
perm' = case perm of
Exec -> Tar.executableFilePermissions
Expand All @@ -276,9 +274,9 @@ packageToSdist verbosity projectRootDir format outputFile pkg = do

entries <- execWriterT (evalStateT entriesM mempty)
let -- Pretend our GZip file is made on Unix.
normalize bs = BSL.concat [first, "\x03", rest']
normalize bs = BSL.concat [pfx, "\x03", rest']
where
(first, rest) = BSL.splitAt 9 bs
(pfx, rest) = BSL.splitAt 9 bs
rest' = BSL.tail rest
-- The Unix epoch, which is the default value, is
-- unsuitable because it causes unpacking problems on
Expand Down
Loading

0 comments on commit 6279b6f

Please sign in to comment.