Skip to content

Commit e7570cc

Browse files
authored
Merge pull request #1038 from haskell/cabal-3.6
Minimal migration to Cabal-3.6.3.0
2 parents 8504271 + fa633f5 commit e7570cc

File tree

9 files changed

+153
-25
lines changed

9 files changed

+153
-25
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
versions:
20+
- ghc: '9.2.2'
21+
cabal: '3.6'
2022
- ghc: '9.0.2'
2123
cabal: '3.6'
2224
- ghc: '8.10.7'

hackage-server.cabal

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ copyright: 2008-2015 Duncan Coutts,
2727
license: BSD-3-Clause
2828
license-file: LICENSE
2929

30-
tested-with: GHC == { 8.10.7, 8.8.4 }
30+
tested-with: GHC == { 9.2.2, 9.0.2, 8.10.7, 8.8.4 }
3131

3232
data-dir: datafiles
3333
data-files:
@@ -95,25 +95,25 @@ common defaults
9595
-- see `cabal.project.local-ghc-${VERSION}` files
9696
build-depends:
9797
, array >= 0.5 && < 0.6
98-
, base >= 4.13 && < 4.16
98+
, base >= 4.13 && < 4.17
9999
, binary >= 0.8 && < 0.9
100-
, bytestring >= 0.10 && < 0.11
100+
, bytestring >= 0.10 && < 0.12
101101
, containers ^>= 0.6.0
102102
, deepseq >= 1.4 && < 1.5
103103
, directory >= 1.3 && < 1.4
104104
, filepath >= 1.4 && < 1.5
105105
, mtl ^>= 2.2.1
106106
, pretty >= 1.1 && < 1.2
107107
, process >= 1.6 && < 1.7
108-
, text ^>= 1.2.2
109-
, time >= 1.9 && < 1.12
108+
, text ^>= 1.2.5.0
109+
, time >= 1.9 && < 1.13
110110
, transformers >= 0.5 && < 0.6
111111
, unix >= 2.7 && < 2.8
112112
, scientific
113113
-- other dependencies shared by most components
114114
build-depends:
115115
, aeson ^>= 2.0.3.0
116-
, Cabal ^>= 3.4.1.0
116+
, Cabal ^>= 3.6.3.0
117117
, fail ^>= 4.9.0
118118
-- we use Control.Monad.Except, introduced in mtl-2.2.1
119119
, network >= 3 && < 3.2
@@ -356,15 +356,15 @@ library lib-server
356356
-- NB: see also build-depends in `common defaults`!
357357
build-depends:
358358
, HStringTemplate ^>= 0.8
359-
, HTTP ^>= 4000.3.6
359+
, HTTP ^>= 4000.3.16
360360
, QuickCheck ^>= 2.14
361361
, acid-state ^>= 0.16
362362
, async ^>= 2.2.1
363363
-- requires bumping http-io-streams
364364
, attoparsec ^>= 0.14.4
365365
, base16-bytestring ^>= 1.0
366366
-- requires bumping http-io-streams
367-
, base64-bytestring ^>= 1.1
367+
, base64-bytestring ^>= 1.2.1.0
368368
--NOTE: blaze-builder-0.4 is now a compat package that uses bytestring-0.10 builder
369369
, blaze-builder ^>= 0.4
370370
, blaze-html ^>= 0.9
@@ -511,7 +511,7 @@ test-suite HighLevelTest
511511
-- component-specific dependencies
512512
, xml ^>= 1.3.14
513513
, io-streams ^>= 1.5.0.1
514-
, http-io-streams ^>= 0.1.0.0
514+
, http-io-streams ^>= 0.1.6.1
515515

516516
test-suite CreateUserTest
517517
import: test-defaults

src/Distribution/Server/Packages/Render.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ import Distribution.PackageDescription.Configuration
3131
import Distribution.Package
3232
import Distribution.Text
3333
import Distribution.Pretty (prettyShow)
34-
import Distribution.Version
34+
import Distribution.Version (noVersion)
35+
import Distribution.Types.VersionInterval.Legacy
36+
-- Andreas Abel, 2022-03-27:
37+
-- Note that this "Legacy" module is both new and deprecated in Cabal-3.6.
38+
-- However, the non-deprecated module "Distribution.Types.VersionInterval"
39+
-- does not define the functions anymore we rely on here, namely
40+
-- @{union,intersect}VersionIntervals@.
41+
-- I criticized this unfortunate development at length at:
42+
-- https://github.com/haskell/cabal/issues/7916
3543
import Distribution.ModuleName as ModuleName
3644
import Distribution.Types.ModuleReexport
3745

@@ -41,7 +49,9 @@ import Distribution.Server.Packages.Types
4149
import Distribution.Server.Packages.ModuleForest
4250
import qualified Distribution.Server.Users.Users as Users
4351
import Distribution.Server.Users.Types
52+
import Distribution.Utils.Path (getSymbolicPath)
4453
import Distribution.Utils.ShortText (fromShortText)
54+
4555
import qualified Data.TarIndex as TarIndex
4656
import Data.TarIndex (TarIndex, TarEntryOffset)
4757

@@ -95,7 +105,7 @@ doPackageRender users info = PackageRender
95105
, rendSublibraryDeps = (unUnqualComponentName *** depTree libBuildInfo)
96106
`map` condSubLibraries genDesc
97107
, rendLicenseName = prettyShow (license desc) -- maybe make this a bit more human-readable
98-
, rendLicenseFiles = licenseFiles desc
108+
, rendLicenseFiles = map getSymbolicPath $ licenseFiles desc
99109
, rendMaintainer = case fromShortText $ maintainer desc of
100110
"None" -> Nothing
101111
"none" -> Nothing

src/Distribution/Server/Util/ParseSpecVer.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ decodeVerFallback v0 = simpleParse v <|> parseSpecVR
239239
parseSpecVR = do
240240
vr <- simpleParse v
241241
case asVersionIntervals vr of
242-
[] -> Just $ mkVersion [0]
243-
((LowerBound version _, _):_) -> Just $ version
242+
VersionInterval (LowerBound version _) _ : _ -> Just version
243+
[] -> Just $ mkVersion [0]
244244

245245
v = BC8.unpack v0
246246

tests/PackageTestMain.hs

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- | Test that Hackage accepts or refuses certain packages.
2+
13
module Main
24
( main
35
) where
@@ -14,15 +16,19 @@ import Distribution.Server.Packages.Unpack
1416
import Distribution.Server.Packages.UnpackTest
1517

1618
import Test.Tasty (defaultMain, TestTree, testGroup)
17-
import Test.Tasty.HUnit (testCase, Assertion)
19+
import Test.Tasty.HUnit (testCase, Assertion, HasCallStack)
1820

1921
main :: IO ()
2022
main = defaultMain allTests
2123

2224
allTests :: TestTree
2325
allTests = testGroup "PackageTests"
2426
[ testGroup "Tar file permissions" tarPermissions
25-
, testGroup "Cabal package integrity tests" cabalPackageCheckTests]
27+
, testGroup "Cabal package integrity tests" cabalPackageCheckTests
28+
]
29+
30+
---------------------------------------------------------------------------
31+
-- * File permission tests
2632

2733
tarPermissions :: [TestTree]
2834
tarPermissions =
@@ -34,7 +40,8 @@ tarPermissions =
3440
(testPermissions "tests/permissions-tarballs/bad-file-perms.tar.gz" badFileMangler)
3541
, testCase
3642
"Bad Dir Permissions"
37-
(testPermissions "tests/permissions-tarballs/bad-dir-perms.tar.gz" badDirMangler)]
43+
(testPermissions "tests/permissions-tarballs/bad-dir-perms.tar.gz" badDirMangler)
44+
]
3845

3946
goodMangler :: (Tar.Entry -> Maybe CombinedTarErrs)
4047
goodMangler = const Nothing
@@ -51,45 +58,98 @@ badDirMangler entry =
5158
Tar.Directory -> Just $ PermissionsError (Tar.entryPath entry) 0o700
5259
_ -> Nothing
5360

61+
---------------------------------------------------------------------------
62+
-- * Package integry tests
63+
5464
cabalPackageCheckTests :: [TestTree]
5565
cabalPackageCheckTests =
66+
-- Failing tests
5667
[ testCase "Missing ./configure script" missingConfigureScriptTest
57-
, testCase "Missing directories in tar file" missingDirsInTarFileTest
5868
, testCase "Bad spec-version" badSpecVer
69+
-- Successful tests
70+
, testCase "Missing directories in tar file" missingDirsInTarFileTest
71+
, testCase "Accept GHC 9.2 LANGUAGE extensions" acceptGHC902LanguageExtensions
5972
]
6073

74+
---------------------------------------------------------------------------
75+
-- ** Tests that must fail
76+
77+
-- | If @build-type: Configure@, then there must be a @./configure@ script.
78+
6179
missingConfigureScriptTest :: Assertion
6280
missingConfigureScriptTest =
6381
do tar <- tarGzFile "missing-configure-0.1.0.0"
6482
now <- getCurrentTime
6583
case unpackPackage now "missing-configure-0.1.0.0.tar.gz" tar of
66-
Right _ -> HUnit.assertFailure "expected error"
84+
Right _ -> HUnit.assertFailure "error: unexpected success"
6785
Left err ->
6886
HUnit.assertBool
6987
("Error found, but not about missing ./configure: " ++ err)
7088
("The 'build-type' is 'Configure'" `isInfixOf` err)
7189

90+
-- | The @cabal-version@ must be valid.
91+
7292
badSpecVer :: Assertion
7393
badSpecVer =
7494
do tar <- tarGzFile "bad-specver-package-0"
7595
now <- getCurrentTime
7696
case unpackPackage now "bad-specver-package-0.tar.gz" tar of
77-
Right _ -> HUnit.assertFailure "expected error"
97+
Right _ -> HUnit.assertFailure "error: unexpected success"
7898
Left err ->
7999
HUnit.assertBool
80100
("Error found, but not about invalid spec version: " ++ err)
81101
("cabal spec version" `isInfixOf` err)
82102

103+
---------------------------------------------------------------------------
104+
-- ** Tests that must succeed
105+
83106
-- | Some tar files in hackage are missing directory entries.
84107
-- Ensure that they can be verified even without the directory entries.
108+
85109
missingDirsInTarFileTest :: Assertion
86110
missingDirsInTarFileTest =
87-
do tar <- fmap keepOnlyFiles (tarGzFile "correct-package-0.1.0.0")
88-
now <- getCurrentTime
89-
case unpackPackage now "correct-package-0.1.0.0.tar.gz" tar of
90-
Right _ -> return ()
91-
Left err ->
92-
HUnit.assertFailure ("Excpected success but got: " ++ show err)
111+
successTestTGZ pkg =<< do keepOnlyFiles <$> tarGzFile pkg
112+
where
113+
pkg = "correct-package-0.1.0.0"
114+
115+
-- | Hackage should accept GHC 9.2 language extensions (issue #1030).
116+
117+
acceptGHC902LanguageExtensions :: Assertion
118+
acceptGHC902LanguageExtensions = successTest "LANGUAGE-GHC-9.2"
119+
120+
---------------------------------------------------------------------------
121+
-- * Auxiliary functions to construct tests
122+
123+
-- | A generic successful test, given a directory with the package contents.
124+
--
125+
-- Note: the 'HasCallStack' constraint ensures that the assertion failure
126+
-- is thrown at the invocation site of this function.
127+
--
128+
successTest
129+
:: HasCallStack
130+
=> String -- ^ The directory which is also the package name.
131+
-> Assertion
132+
successTest pkg = successTestTGZ pkg =<< tarGzFile pkg
133+
134+
-- | A successful test, given the package name and its @.tgz@ stream.
135+
--
136+
-- Note: the 'HasCallStack' constraint ensures that the assertion failure
137+
-- is thrown at the invocation site of this function.
138+
--
139+
successTestTGZ
140+
:: HasCallStack
141+
=> String -- ^ The package name which is also the stem of the @.tgz@ file.
142+
-> ByteString -- ^ The content of the @.tgz@ archive.
143+
-> Assertion
144+
successTestTGZ pkg tar = do
145+
now <- getCurrentTime
146+
case unpackPackage now (pkg ++ ".tar.gz") tar of
147+
Right _ -> return ()
148+
Left err ->
149+
HUnit.assertFailure $ "Expected success, but got: " ++ show err
150+
151+
---------------------------------------------------------------------------
152+
-- * Tar utilities
93153

94154
tarGzFile :: String -> IO ByteString
95155
tarGzFile name = do
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: LANGUAGE-GHC
2+
version: 9.2
3+
synopsis: Test for LANGUAGE extensions (issue #1030)
4+
description: Test whether Hackage accepts the latest LANGUAGE extensions
5+
license: BSD3
6+
license-file: LICENSE
7+
author: Hackage Server Team
8+
maintainer: no@email.com
9+
category: Test case
10+
build-type: Simple
11+
cabal-version: >=1.10
12+
13+
executable foo
14+
main-is: Main.hs
15+
build-depends: base >=4.16 && <4.17
16+
default-language: GHC2021
17+
default-extensions:
18+
-- These LANGUAGE extensions are new in GHC 9.2:
19+
NoFieldSelectors
20+
OverloadedRecordDot
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2016, Hackage Server Team
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Hackage Server Team nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = putStrLn "Hello, Haskell!"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

0 commit comments

Comments
 (0)