Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,15 @@ checkPaths pkg =
, (GHC, flags) <- options bi
, path <- flags
, isInsideDist path ]
++
[ PackageBuildWarning $
"Using a '*' character in 'data-dir', like " ++ path ++ ", can behave"
++ " erratically with prior versions of Cabal. It is recommended that you"
++ " set 'cabal-version: 3.0' to exclude old versions."
| path <- [dataDir pkg]
, specVersion pkg < mkVersion [3,0]
, '*' `elem` path
]
where
isOutsideTree path = case splitDirectories path of
"..":_ -> True
Expand Down
4 changes: 2 additions & 2 deletions Cabal/Distribution/Simple/SrcDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ listPackageSourcesOrdinary verbosity pkg_descr pps =

-- Data files.
, fmap concat
. for (dataFiles pkg_descr) $ \filename ->
matchFileGlob (dataDir pkg_descr </> filename)
. for (dataFiles pkg_descr) $ \ filename -> fmap (fmap (dataDir pkg_descr </>)) $
matchDirFileGlob (dataDir pkg_descr) filename

-- Extra doc files.
, fmap concat
Expand Down
4 changes: 4 additions & 0 deletions cabal-install/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
-*-change-log-*-

2.3.0.0 (current development version)
* `cabal sdist` would error out when `data-dir` included `*`
characters. These are now correctly treated as inert.

2.2.0.0 (current development version)
* '--with-PROG' and '--PROG-options' are applied to all packages
and not local packages only (#5019).
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SDist/ListSources/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = return ()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
11 changes: 11 additions & 0 deletions cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 2.2
name: list-sources
version: 0
data-dir: data
data-files: blah/*.dat
extra-source-files: extra-src/blah/*.html
extra-doc-files: extra-doc/blah/*.tex

executable dummy
default-language: Haskell2010
main-is: Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-d7916f39/sources'
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-d7916f39/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-f48849cb/sources'
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-f48849cb/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Control.Monad.IO.Class
import System.IO.Temp (withSystemTempDirectory)
import Test.Cabal.Prelude
main = setupAndCabalTest $ withSystemTempDirectory "cabal-testsuite.included-in-sdist" $ \dir -> do
let fn = dir </> "sources"
cabal "sdist" ["--list-sources=" ++ fn]
liftIO $ putStrLn =<< readFile fn
assertFileDoesContain fn "data/blah/a.dat"
assertFileDoesContain fn "extra-src/blah/a.html"
assertFileDoesContain fn "extra-doc/blah/a.tex"
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SDist/StarInDataDir/*/a.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SDist/StarInDataDir/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = return ()
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SDist/StarInDataDir/a/a.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-c7bfa464/sources'
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-c7bfa464/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-8306c552/sources'
List of package sources written to file '/tmp/cabal-testsuite.included-in-sdist-8306c552/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Control.Monad.IO.Class
import System.FilePath (normalise)
import System.IO.Temp (withSystemTempDirectory)
import Test.Cabal.Prelude
main = setupAndCabalTest $ withSystemTempDirectory "cabal-testsuite.included-in-sdist" $ \dir -> do
let fn = dir </> "sources"
cabal "sdist" ["--list-sources=" ++ fn]
files <- liftIO $ fmap (fmap normalise . lines) $ readFile fn
assertBool "has */a.dat" ("*/a.dat" `elem` files)
assertBool "hasn't a/a.dat" $ not ("a/a.dat" `elem` files)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cabal-version: 2.2
name: star-in-data-dir
version: 0
data-dir: *
data-files: *.dat

executable dummy
default-language: Haskell2010
main-is: Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal sdist
Distribution quality errors:
No 'synopsis' or 'description' field.
The 'license' field is missing or is NONE.
Using a '*' character in 'data-dir', like *, can behave erratically with prior versions of Cabal. It is recommended that you set 'cabal-version: 3.0' to exclude old versions.
Distribution quality warnings:
No 'category' field.
No 'maintainer' field.
Note: the public hackage server would reject this package.
Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for star-in-data-dir-0...
Source tarball created: <ROOT>/warning-issued.cabal.dist/work/./dist/star-in-data-dir-0.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal sdist
Distribution quality errors:
No 'synopsis' or 'description' field.
The 'license' field is missing or is NONE.
Using a '*' character in 'data-dir', like *, can behave erratically with prior versions of Cabal. It is recommended that you set 'cabal-version: 3.0' to exclude old versions.
Distribution quality warnings:
No 'category' field.
No 'maintainer' field.
Note: the public hackage server would reject this package.
Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for star-in-data-dir-0...
Source tarball created: <ROOT>/warning-issued.dist/work/./dist/star-in-data-dir-0.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude
main = setupAndCabalTest $ do
output <- cabal' "sdist" []
assertOutputContains "Using a '*' character in 'data-dir'" output
1 change: 1 addition & 0 deletions cabal-testsuite/cabal-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ library
filepath,
regex-compat-tdfa,
regex-tdfa,
temporary,
text,
Cabal >= 2.3
ghc-options: -Wall -fwarn-tabs
Expand Down