Skip to content

Commit 7fec503

Browse files
Make Setup.hs copy/install work when data-files uses **. (#6127)
Treating globs like filenames was always illegitimate, but this code was broken further by the addition of recursive globs. I had a look around for other dubious code along these lines, and it looks like this site is the only problematic one. Fixes #6125.
1 parent ed3ae13 commit 7fec503

File tree

8 files changed

+44
-7
lines changed

8 files changed

+44
-7
lines changed

Cabal/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
* Uniformly provide 'Semigroup' instances for `base < 4.9` via `semigroups` package
3535
* Setting `debug-info` now implies `library-stripping: False` and
3636
`executable-stripping: False) ([#2702](https://github.com/haskell/cabal/issues/2702))
37+
* `Setup.hs copy` and `install` now work in the presence of
38+
`data-files` that use `**` syntax
39+
([#6125](https://github.com/haskell/cabal/issues/6125)).
3740

3841
----
3942

Cabal/Distribution/Simple/Install.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ copyComponent _ _ _ (CTest _) _ _ = return ()
223223
--
224224
installDataFiles :: Verbosity -> PackageDescription -> FilePath -> IO ()
225225
installDataFiles verbosity pkg_descr destDataDir =
226-
flip traverse_ (dataFiles pkg_descr) $ \ file -> do
226+
flip traverse_ (dataFiles pkg_descr) $ \ glob -> do
227227
let srcDataDirRaw = dataDir pkg_descr
228228
srcDataDir = if null srcDataDirRaw
229229
then "."
230230
else srcDataDirRaw
231-
files <- matchDirFileGlob verbosity (specVersion pkg_descr) srcDataDir file
232-
let dir = takeDirectory file
233-
createDirectoryIfMissingVerbose verbosity True (destDataDir </> dir)
234-
sequence_ [ installOrdinaryFile verbosity (srcDataDir </> file')
235-
(destDataDir </> file')
236-
| file' <- files ]
231+
files <- matchDirFileGlob verbosity (specVersion pkg_descr) srcDataDir glob
232+
for_ files $ \ file' -> do
233+
let src = srcDataDir </> file'
234+
dst = destDataDir </> file'
235+
createDirectoryIfMissingVerbose verbosity True (takeDirectory dst)
236+
installOrdinaryFile verbosity src dst
237237

238238
-- | Install the files listed in install-includes for a library
239239
--
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main = return ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html>Some random data.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cabal-version: 2.4
2+
name: myprog
3+
version: 0
4+
data-files: data/**/*.html
5+
6+
executable myprog
7+
build-depends: base
8+
main-is: Main.hs
9+
default-language: Haskell2010
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Setup configure
2+
Resolving dependencies...
3+
Configuring myprog-0...
4+
# Setup build
5+
Preprocessing executable 'myprog' for myprog-0..
6+
Building executable 'myprog' for myprog-0..
7+
# Setup copy
8+
Installing executable myprog in <PATH>
9+
Warning: The directory <ROOT>/setup.cabal.dist/usr/bin is not in the system search path.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Setup configure
2+
Configuring myprog-0...
3+
# Setup build
4+
Preprocessing executable 'myprog' for myprog-0..
5+
Building executable 'myprog' for myprog-0..
6+
# Setup copy
7+
Installing executable myprog in <PATH>
8+
Warning: The directory <ROOT>/setup.dist/usr/bin is not in the system search path.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Test.Cabal.Prelude
2+
main = setupAndCabalTest $ do
3+
withPackageDb $ do
4+
setup "configure" []
5+
setup "build" ["myprog"]
6+
setup "copy" ["myprog"]

0 commit comments

Comments
 (0)