Skip to content

Commit 0b06a13

Browse files
authored
Properly link filename compatibility checks into cabal check (#7479)
* Properly link filename compatibility checks into `cabal check` * Improve consistency and clarity of Check error messages
1 parent aff39d0 commit 0b06a13

File tree

9 files changed

+93
-100
lines changed

9 files changed

+93
-100
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'cpp-options': -traditional is not portable C-preprocessor flag
1+
'cpp-options: -traditional' is not a portable C-preprocessor flag.

Cabal-tests/tests/ParserTests/regressions/denormalised-paths.cabal

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ tested-with:
2929
|| ==8.8.1
3030

3131
extra-source-files:
32+
-- this is fine
33+
files/**/*.md
34+
-- collection of invalid paths
3235
files/**/*.txt/
3336
files/../foo.txt
37+
files/<>/*.txt
3438

3539
source-repository head
3640
type: git
@@ -69,3 +73,6 @@ library
6973

7074
-- this is the only case catched by Cabal-3.0.2.0
7175
hs-source-dirs: ../../assoc/src
76+
77+
-- globs not allowed in field
78+
c-sources: c/**/*.c
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
The 'subdir' field of a source-repository is not a good relative path: "trailing same directory segment: ."
2+
The paths 'files/<>/*.txt', 'c/**/*.c', 'C:foo/bar', '||s' are invalid on Windows, which would cause portability problems for this package. Windows file names cannot contain any of the characters ":*?<>|" and there a few reserved names including "aux", "nul", "con", "prn", "com1-9", "lpt1-9" and "clock$".
23
'hs-source-dirs: ../../assoc/src' is a relative path outside of the source tree. This will not work when generating a tarball with 'sdist'.
3-
'extra-source-files: files/**/*.txt/' is not good relative path: trailing slash
4-
'extra-source-files: files/../foo.txt' is not good relative path: parent directory segment: ..
5-
'license-file: LICENSE2/' is not good relative path: trailing slash
6-
'license-file: .' is not good relative path: trailing dot segment
7-
'hs-source-dirs: src/.' is not good relative path: trailing same directory segment: .
8-
'hs-source-dirs: src/../src' is not good relative path: parent directory segment: ..
9-
'hs-source-dirs: src/../../assoc/src' is not good relative path: parent directory segment: ..
10-
'hs-source-dirs: C:foo/bar' is not good relative path: reserved character ':'
11-
'hs-source-dirs: ||s' is not good relative path: reserved character '|'
12-
'hs-source-dirs: ../../assoc/src' is not good relative path: parent directory segment: ..
4+
'extra-source-files: files/**/*.txt/' is not a good relative path: "trailing slash"
5+
'extra-source-files: files/../foo.txt' is not a good relative path: "parent directory segment: .."
6+
'license-file: LICENSE2/' is not a good relative path: "trailing slash"
7+
'license-file: .' is not a good relative path: "trailing dot segment"
8+
'hs-source-dirs: src/.' is not a good relative path: "trailing same directory segment: ."
9+
'hs-source-dirs: src/../src' is not a good relative path: "parent directory segment: .."
10+
'hs-source-dirs: src/../../assoc/src' is not a good relative path: "parent directory segment: .."
11+
'hs-source-dirs: ../../assoc/src' is not a good relative path: "parent directory segment: .."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
The package uses RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, and also Paths_ autogen module. That configuration is known to cause compile failures with Cabal < 2.2. To use these default-extensions with Paths_ autogen module specify at least 'cabal-version: 2.2'.
1+
Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module Paths_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a Paths_* autogen module, specify at least 'cabal-version: 2.2'.

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 62 additions & 82 deletions
Large diffs are not rendered by default.

cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ On executable 'Exe' an 'autogen-module' is not on 'other-modules'
1414
On test suite 'Test' an 'autogen-module' is not on 'other-modules'
1515
On benchmark 'Bench' an 'autogen-module' is not on 'other-modules'
1616
Packages using 'cabal-version: 2.0' and the autogenerated module Paths_* must include it also on the 'autogen-modules' field besides 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
17-
The filename ./my.cabal does not match package name (expected: AutogenModules.cabal)
17+
The filename './my.cabal' does not match package name (expected: 'AutogenModules.cabal')
1818
Note: the public hackage server would reject this package.
1919
Building source dist for AutogenModules-0.1...
2020
cabal: Error: Could not find module: MyLibHelperModule with any suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the module is autogenerated it should be added to 'autogen-modules'.

cabal-testsuite/PackageTests/AutogenModules/Package/setup.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ On executable 'Exe' an 'autogen-module' is not on 'other-modules'
1414
On test suite 'Test' an 'autogen-module' is not on 'other-modules'
1515
On benchmark 'Bench' an 'autogen-module' is not on 'other-modules'
1616
Packages using 'cabal-version: 2.0' and the autogenerated module Paths_* must include it also on the 'autogen-modules' field besides 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
17-
The filename ./my.cabal does not match package name (expected: AutogenModules.cabal)
17+
The filename './my.cabal' does not match package name (expected: 'AutogenModules.cabal')
1818
Note: the public hackage server would reject this package.
1919
Building source dist for AutogenModules-0.1...
2020
setup: Error: Could not find module: MyLibHelperModule with any suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the module is autogenerated it should be added to 'autogen-modules'.

changelog.d/path-validation

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: Fix bugs in filename validation
2+
packages: Cabal
3+
prs: #7429 #7479
4+
issues: #7426
5+
6+
description: {
7+
8+
- Relative paths starting with single-character directories are now properly allowed
9+
- `cabal check` rejects paths which are invalid on Windows or in tarballs
10+
11+
}

changelog.d/rel-path-check

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)