Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

On install, update the .cabal file with the one from the index

(patch manually merged into the cabal-1.16 branch)

This allows us to make minor changes to packages after they have been
released, without changing the package .tar.gz file. We already keep
the .cabal file outsite the package in the index and use it for
dependency planning. This already lets us do fixes such as making
dependency constraints tighter. Currently we cannot make dep
constraints more relaxed however, since the original .cabal file is
the one used when we get to the actual configure step.

So with this change, we now use the updated .cabal file for the
configure and build too. So there's more fixes we can do post-release.
In particlar, in combination with easier editing on hackage, this
should help us address the problems around the PVP and open or closed
version constraints. It should allow a system of conservative upper
bounds, but allow editing them when new versions of deps are released
and we find that they happen to work fine.
  • Loading branch information...
commit 22d3772222ebb5dd49d60882845915999ebc97e2 1 parent e9c9b7a
Duncan Coutts dcoutts authored
7 cabal-install/Distribution/Client/Configure.hs
@@ -82,7 +82,7 @@ configure verbosity packageDBs repos comp conf
82 82 configureCommand (const configFlags) extraArgs
83 83
84 84 Right installPlan -> case InstallPlan.ready installPlan of
85   - [pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _)) _ _ _)] ->
  85 + [pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _) _) _ _ _)] ->
86 86 configurePackage verbosity
87 87 (InstallPlan.planPlatform installPlan)
88 88 (InstallPlan.planCompiler installPlan)
@@ -138,7 +138,8 @@ planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex
138 138 localPkg = SourcePackage {
139 139 packageInfoId = packageId pkg,
140 140 Source.packageDescription = pkg,
141   - packageSource = LocalUnpackedPackage "."
  141 + packageSource = LocalUnpackedPackage ".",
  142 + packageDescrOverride = Nothing
142 143 }
143 144
144 145 testsEnabled = fromFlagOrDefault False $ configTests configFlags
@@ -194,7 +195,7 @@ configurePackage :: Verbosity
194 195 -> [String]
195 196 -> IO ()
196 197 configurePackage verbosity platform comp scriptOptions configFlags
197   - (ConfiguredPackage (SourcePackage _ gpkg _) flags stanzas deps) extraArgs =
  198 + (ConfiguredPackage (SourcePackage _ gpkg _ _) flags stanzas deps) extraArgs =
198 199
199 200 setupWrapper verbosity
200 201 scriptOptions (Just pkg) configureCommand configureFlags extraArgs
2  cabal-install/Distribution/Client/Dependency/Modular/IndexConversion.hs
@@ -92,7 +92,7 @@ convSPI os arch cid = mkIndex . convSPI' os arch cid
92 92
93 93 -- | Convert a single source package into the solver-specific format.
94 94 convSP :: OS -> Arch -> CompilerId -> SourcePackage -> (PN, I, PInfo)
95   -convSP os arch cid (SourcePackage (PackageIdentifier pn pv) gpd _pl) =
  95 +convSP os arch cid (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
96 96 let i = I pv InRepo
97 97 in (pn, i, convGPD os arch cid (PI pn i) gpd)
98 98
8 cabal-install/Distribution/Client/Dependency/TopDown.hs
@@ -368,7 +368,7 @@ pruneBottomUp platform comp constraints =
368 368 [ (dep, Constraints.conflicting cs dep)
369 369 | dep <- missing ]
370 370
371   - configure cs (UnconfiguredPackage (SourcePackage _ pkg _) _ flags stanzas) =
  371 + configure cs (UnconfiguredPackage (SourcePackage _ pkg _ _) _ flags stanzas) =
372 372 finalizePackageDescription flags (dependencySatisfiable cs)
373 373 platform comp [] (enableStanzas stanzas pkg)
374 374 dependencySatisfiable cs =
@@ -397,7 +397,7 @@ configurePackage platform comp available spkg = case spkg of
397 397 InstalledAndSource ipkg apkg -> fmap (InstalledAndSource ipkg)
398 398 (configure apkg)
399 399 where
400   - configure (UnconfiguredPackage apkg@(SourcePackage _ p _) _ flags stanzas) =
  400 + configure (UnconfiguredPackage apkg@(SourcePackage _ p _ _) _ flags stanzas) =
401 401 case finalizePackageDescription flags dependencySatisfiable
402 402 platform comp [] (enableStanzas stanzas p) of
403 403 Left missing -> Left missing
@@ -481,7 +481,7 @@ topologicalSortNumbering installedPkgIndex sourcePkgIndex =
481 481 ++ [ ((), packageName pkg, nub deps)
482 482 | pkgs@(pkg:_) <- PackageIndex.allPackagesByName sourcePkgIndex
483 483 , let deps = [ depName
484   - | SourcePackage _ pkg' _ <- pkgs
  484 + | SourcePackage _ pkg' _ _ <- pkgs
485 485 , Dependency depName _ <-
486 486 buildDepends (flattenPackageDescription pkg') ] ]
487 487
@@ -517,7 +517,7 @@ selectNeededSubset installedPkgIndex sourcePkgIndex = select mempty mempty
517 517 | pkg <- moreInstalled
518 518 , dep <- depends pkg ]
519 519 ++ [ name
520   - | SourcePackage _ pkg _ <- moreSource
  520 + | SourcePackage _ pkg _ _ <- moreSource
521 521 , Dependency name _ <-
522 522 buildDepends (flattenPackageDescription pkg) ]
523 523 installedPkgIndex'' = foldl' (flip PackageIndex.insert)
25 cabal-install/Distribution/Client/IndexUtils.hs
@@ -169,11 +169,12 @@ readRepoIndex verbosity repo =
169 169 readPackageIndexCacheFile mkAvailablePackage indexFile cacheFile
170 170
171 171 where
172   - mkAvailablePackage pkgid pkg =
  172 + mkAvailablePackage pkgid pkgtxt pkg =
173 173 SourcePackage {
174 174 packageInfoId = pkgid,
175 175 packageDescription = pkg,
176   - packageSource = RepoTarballPackage repo pkgid Nothing
  176 + packageSource = RepoTarballPackage repo pkgid Nothing,
  177 + packageDescrOverride = Just pkgtxt
177 178 }
178 179
179 180 handleNotFound action = catchIO action $ \e -> if isDoesNotExistError e
@@ -339,7 +340,8 @@ updatePackageIndexCacheFile indexFile cacheFile = do
339 340 ++ [ CachePackageId pkgid blockNo | (pkgid, _, blockNo) <- pkgs ]
340 341
341 342 readPackageIndexCacheFile :: Package pkg
342   - => (PackageId -> GenericPackageDescription -> pkg)
  343 + => (PackageId -> ByteString
  344 + -> GenericPackageDescription -> pkg)
343 345 -> FilePath
344 346 -> FilePath
345 347 -> IO (PackageIndex pkg, [Dependency])
@@ -350,7 +352,8 @@ readPackageIndexCacheFile mkPkg indexFile cacheFile = do
350 352
351 353
352 354 packageIndexFromCache :: Package pkg
353   - => (PackageId -> GenericPackageDescription -> pkg)
  355 + => (PackageId -> ByteString
  356 + -> GenericPackageDescription -> pkg)
354 357 -> Handle
355 358 -> [IndexCacheEntry]
356 359 -> IO (PackageIndex pkg, [Dependency])
@@ -368,20 +371,22 @@ packageIndexFromCache mkPkg hnd = accum mempty []
368 371 -- The magic here is that we use lazy IO to read the .cabal file
369 372 -- from the index tarball if it turns out that we need it.
370 373 -- Most of the time we only need the package id.
371   - pkg <- unsafeInterleaveIO $ do
372   - getPackageDescription blockno
373   - let srcpkg = mkPkg pkgid pkg
  374 + ~(pkg, pkgtxt) <- unsafeInterleaveIO $ do
  375 + pkgtxt <- getEntryContent blockno
  376 + pkg <- readPackageDescription pkgtxt
  377 + return (pkg, pkgtxt)
  378 +
  379 + let srcpkg = mkPkg pkgid pkgtxt pkg
374 380 accum (srcpkg:srcpkgs) prefs entries
375 381
376 382 accum srcpkgs prefs (CachePreference pref : entries) =
377 383 accum srcpkgs (pref:prefs) entries
378 384
379   - getPackageDescription blockno = do
  385 + getEntryContent blockno = do
380 386 hSeek hnd AbsoluteSeek (fromIntegral (blockno * 512))
381 387 header <- BS.hGet hnd 512
382 388 size <- getEntrySize header
383   - content <- BS.hGet hnd (fromIntegral size)
384   - readPackageDescription content
  389 + BS.hGet hnd (fromIntegral size)
385 390
386 391 getEntrySize header =
387 392 case Tar.read header of
29 cabal-install/Distribution/Client/Install.hs
@@ -22,6 +22,8 @@ import Data.List
22 22 ( unfoldr, nub, sort, (\\) )
23 23 import Data.Maybe
24 24 ( isJust, fromMaybe, maybeToList )
  25 +import qualified Data.ByteString.Lazy.Char8 as BS
  26 + ( unpack )
25 27 import Control.Exception as Exception
26 28 ( bracket, handleJust )
27 29 #if MIN_VERSION_base(4,0,0)
@@ -95,7 +97,7 @@ import qualified Distribution.Simple.Setup as Cabal
95 97 ( installCommand, InstallFlags(..), emptyInstallFlags
96 98 , emptyTestFlags, testCommand, Flag(..) )
97 99 import Distribution.Simple.Utils
98   - ( rawSystemExit, comparing )
  100 + ( rawSystemExit, comparing, writeFileAtomic )
99 101 import Distribution.Simple.InstallDirs as InstallDirs
100 102 ( PathTemplate, fromPathTemplate, toPathTemplate, substPathTemplate
101 103 , initialPathTemplateEnv, installDirsTemplateEnv )
@@ -755,13 +757,13 @@ performInstallations verbosity
755 757
756 758 executeInstallPlan verbosity jobControl useLogFile installPlan $ \cpkg ->
757 759 installConfiguredPackage platform compid configFlags
758   - cpkg $ \configFlags' src pkg ->
  760 + cpkg $ \configFlags' src pkg pkgoverride ->
759 761 fetchSourcePackage verbosity fetchLimit src $ \src' ->
760 762 installLocalPackage verbosity buildLimit (packageId pkg) src' $ \mpath ->
761 763 installUnpackedPackage verbosity buildLimit installLock numJobs
762 764 (setupScriptOptions installedPkgIndex cacheLock)
763 765 miscOptions configFlags' installFlags haddockFlags
764   - compid pkg mpath useLogFile
  766 + compid pkg pkgoverride mpath useLogFile
765 767
766 768 where
767 769 platform = InstallPlan.planPlatform installPlan
@@ -930,16 +932,17 @@ executeInstallPlan verbosity jobCtl useLogFile plan0 installPkg =
930 932 installConfiguredPackage :: Platform -> CompilerId
931 933 -> ConfigFlags -> ConfiguredPackage
932 934 -> (ConfigFlags -> PackageLocation (Maybe FilePath)
933   - -> PackageDescription -> a)
  935 + -> PackageDescription
  936 + -> PackageDescriptionOverride -> a)
934 937 -> a
935 938 installConfiguredPackage platform comp configFlags
936   - (ConfiguredPackage (SourcePackage _ gpkg source) flags stanzas deps)
  939 + (ConfiguredPackage (SourcePackage _ gpkg source pkgoverride) flags stanzas deps)
937 940 installPkg = installPkg configFlags {
938 941 configConfigurationsFlags = flags,
939 942 configConstraints = map thisPackageVersion deps,
940 943 configBenchmarks = toFlag False,
941 944 configTests = toFlag (TestStanzas `elem` stanzas)
942   - } source pkg
  945 + } source pkg pkgoverride
943 946 where
944 947 pkg = case finalizePackageDescription flags
945 948 (const True)
@@ -1025,13 +1028,25 @@ installUnpackedPackage
1025 1028 -> HaddockFlags
1026 1029 -> CompilerId
1027 1030 -> PackageDescription
  1031 + -> PackageDescriptionOverride
1028 1032 -> Maybe FilePath -- ^ Directory to change to before starting the installation.
1029 1033 -> UseLogFile -- ^ File to log output to (if any)
1030 1034 -> IO BuildResult
1031 1035 installUnpackedPackage verbosity buildLimit installLock numJobs
1032 1036 scriptOptions miscOptions
1033 1037 configFlags installConfigFlags haddockFlags
1034   - compid pkg workingDir useLogFile =
  1038 + compid pkg pkgoverride workingDir useLogFile = do
  1039 +
  1040 + -- Override the .cabal file if necessary
  1041 + case pkgoverride of
  1042 + Nothing -> return ()
  1043 + Just pkgtxt -> do
  1044 + let descFilePath = fromMaybe "." workingDir
  1045 + </> display (packageName pkgid) <.> "cabal"
  1046 + info verbosity $
  1047 + "Updating " ++ display (packageName pkgid) <.> "cabal"
  1048 + ++ " with the latest revision from the index."
  1049 + writeFileAtomic descFilePath (BS.unpack pkgtxt)
1035 1050
1036 1051 -- Configure phase
1037 1052 onFailure ConfigureFailed $ withJobLimit buildLimit $ do
2  cabal-install/Distribution/Client/InstallSymlink.hs
@@ -133,7 +133,7 @@ symlinkBinaries configFlags installFlags plan =
14 cabal-install/Distribution/Client/Targets.hs
@@ -472,9 +472,10 @@ readPackageTarget verbosity target = case target of
472 472 pkg <- readPackageDescription verbosity =<< findPackageDesc dir
473 473 return $ PackageTargetLocation $
474 474 SourcePackage {
475   - packageInfoId = packageId pkg,
476   - packageDescription = pkg,
477   - packageSource = fmap Just location
  475 + packageInfoId = packageId pkg,
  476 + packageDescription = pkg,
  477 + packageSource = fmap Just location,
  478 + packageDescrOverride = Nothing
478 479 }
479 480
480 481 LocalTarballPackage tarballFile ->
@@ -497,9 +498,10 @@ readPackageTarget verbosity target = case target of
497 498 Just pkg ->
498 499 return $ PackageTargetLocation $
499 500 SourcePackage {
500   - packageInfoId = packageId pkg,
501   - packageDescription = pkg,
502   - packageSource = fmap Just location
  501 + packageInfoId = packageId pkg,
  502 + packageDescription = pkg,
  503 + packageSource = fmap Just location,
  504 + packageDescrOverride = Nothing
503 505 }
504 506
505 507 extractTarballPackageCabalFile :: FilePath -> String
12 cabal-install/Distribution/Client/Types.hs
@@ -29,6 +29,7 @@ import Distribution.Version
29 29
30 30 import Data.Map (Map)
31 31 import Network.URI (URI)
  32 +import Data.ByteString.Lazy (ByteString)
32 33 import Distribution.Compat.Exception
33 34 ( SomeException )
34 35
@@ -94,12 +95,17 @@ instance PackageFixedDeps ConfiguredPackage where
94 95 -- | A package description along with the location of the package sources.
95 96 --
96 97 data SourcePackage = SourcePackage {
97   - packageInfoId :: PackageId,
98   - packageDescription :: GenericPackageDescription,
99   - packageSource :: PackageLocation (Maybe FilePath)
  98 + packageInfoId :: PackageId,
  99 + packageDescription :: GenericPackageDescription,
  100 + packageSource :: PackageLocation (Maybe FilePath),
  101 + packageDescrOverride :: PackageDescriptionOverride
100 102 }
101 103 deriving Show
102 104
  105 +-- | We sometimes need to override the .cabal file in the tarball with
  106 +-- the newer one from the package index.
  107 +type PackageDescriptionOverride = Maybe ByteString
  108 +
103 109 instance Package SourcePackage where packageId = packageInfoId
104 110
105 111 data OptionalStanza

0 comments on commit 22d3772

Please sign in to comment.
Something went wrong with that request. Please try again.