Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@dcoutts dcoutts authored
View
7 cabal-install/Distribution/Client/Configure.hs
@@ -82,7 +82,7 @@ configure verbosity packageDBs repos comp conf
configureCommand (const configFlags) extraArgs
Right installPlan -> case InstallPlan.ready installPlan of
- [pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _)) _ _ _)] ->
+ [pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _) _) _ _ _)] ->
configurePackage verbosity
(InstallPlan.planPlatform installPlan)
(InstallPlan.planCompiler installPlan)
@@ -138,7 +138,8 @@ planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex
localPkg = SourcePackage {
packageInfoId = packageId pkg,
Source.packageDescription = pkg,
- packageSource = LocalUnpackedPackage "."
+ packageSource = LocalUnpackedPackage ".",
+ packageDescrOverride = Nothing
}
testsEnabled = fromFlagOrDefault False $ configTests configFlags
@@ -194,7 +195,7 @@ configurePackage :: Verbosity
-> [String]
-> IO ()
configurePackage verbosity platform comp scriptOptions configFlags
- (ConfiguredPackage (SourcePackage _ gpkg _) flags stanzas deps) extraArgs =
+ (ConfiguredPackage (SourcePackage _ gpkg _ _) flags stanzas deps) extraArgs =
setupWrapper verbosity
scriptOptions (Just pkg) configureCommand configureFlags extraArgs
View
2  cabal-install/Distribution/Client/Dependency/Modular/IndexConversion.hs
@@ -92,7 +92,7 @@ convSPI os arch cid = mkIndex . convSPI' os arch cid
-- | Convert a single source package into the solver-specific format.
convSP :: OS -> Arch -> CompilerId -> SourcePackage -> (PN, I, PInfo)
-convSP os arch cid (SourcePackage (PackageIdentifier pn pv) gpd _pl) =
+convSP os arch cid (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
let i = I pv InRepo
in (pn, i, convGPD os arch cid (PI pn i) gpd)
View
8 cabal-install/Distribution/Client/Dependency/TopDown.hs
@@ -368,7 +368,7 @@ pruneBottomUp platform comp constraints =
[ (dep, Constraints.conflicting cs dep)
| dep <- missing ]
- configure cs (UnconfiguredPackage (SourcePackage _ pkg _) _ flags stanzas) =
+ configure cs (UnconfiguredPackage (SourcePackage _ pkg _ _) _ flags stanzas) =
finalizePackageDescription flags (dependencySatisfiable cs)
platform comp [] (enableStanzas stanzas pkg)
dependencySatisfiable cs =
@@ -397,7 +397,7 @@ configurePackage platform comp available spkg = case spkg of
InstalledAndSource ipkg apkg -> fmap (InstalledAndSource ipkg)
(configure apkg)
where
- configure (UnconfiguredPackage apkg@(SourcePackage _ p _) _ flags stanzas) =
+ configure (UnconfiguredPackage apkg@(SourcePackage _ p _ _) _ flags stanzas) =
case finalizePackageDescription flags dependencySatisfiable
platform comp [] (enableStanzas stanzas p) of
Left missing -> Left missing
@@ -481,7 +481,7 @@ topologicalSortNumbering installedPkgIndex sourcePkgIndex =
++ [ ((), packageName pkg, nub deps)
| pkgs@(pkg:_) <- PackageIndex.allPackagesByName sourcePkgIndex
, let deps = [ depName
- | SourcePackage _ pkg' _ <- pkgs
+ | SourcePackage _ pkg' _ _ <- pkgs
, Dependency depName _ <-
buildDepends (flattenPackageDescription pkg') ] ]
@@ -517,7 +517,7 @@ selectNeededSubset installedPkgIndex sourcePkgIndex = select mempty mempty
| pkg <- moreInstalled
, dep <- depends pkg ]
++ [ name
- | SourcePackage _ pkg _ <- moreSource
+ | SourcePackage _ pkg _ _ <- moreSource
, Dependency name _ <-
buildDepends (flattenPackageDescription pkg) ]
installedPkgIndex'' = foldl' (flip PackageIndex.insert)
View
25 cabal-install/Distribution/Client/IndexUtils.hs
@@ -169,11 +169,12 @@ readRepoIndex verbosity repo =
readPackageIndexCacheFile mkAvailablePackage indexFile cacheFile
where
- mkAvailablePackage pkgid pkg =
+ mkAvailablePackage pkgid pkgtxt pkg =
SourcePackage {
packageInfoId = pkgid,
packageDescription = pkg,
- packageSource = RepoTarballPackage repo pkgid Nothing
+ packageSource = RepoTarballPackage repo pkgid Nothing,
+ packageDescrOverride = Just pkgtxt
}
handleNotFound action = catchIO action $ \e -> if isDoesNotExistError e
@@ -339,7 +340,8 @@ updatePackageIndexCacheFile indexFile cacheFile = do
++ [ CachePackageId pkgid blockNo | (pkgid, _, blockNo) <- pkgs ]
readPackageIndexCacheFile :: Package pkg
- => (PackageId -> GenericPackageDescription -> pkg)
+ => (PackageId -> ByteString
+ -> GenericPackageDescription -> pkg)
-> FilePath
-> FilePath
-> IO (PackageIndex pkg, [Dependency])
@@ -350,7 +352,8 @@ readPackageIndexCacheFile mkPkg indexFile cacheFile = do
packageIndexFromCache :: Package pkg
- => (PackageId -> GenericPackageDescription -> pkg)
+ => (PackageId -> ByteString
+ -> GenericPackageDescription -> pkg)
-> Handle
-> [IndexCacheEntry]
-> IO (PackageIndex pkg, [Dependency])
@@ -368,20 +371,22 @@ packageIndexFromCache mkPkg hnd = accum mempty []
-- The magic here is that we use lazy IO to read the .cabal file
-- from the index tarball if it turns out that we need it.
-- Most of the time we only need the package id.
- pkg <- unsafeInterleaveIO $ do
- getPackageDescription blockno
- let srcpkg = mkPkg pkgid pkg
+ ~(pkg, pkgtxt) <- unsafeInterleaveIO $ do
+ pkgtxt <- getEntryContent blockno
+ pkg <- readPackageDescription pkgtxt
+ return (pkg, pkgtxt)
+
+ let srcpkg = mkPkg pkgid pkgtxt pkg
accum (srcpkg:srcpkgs) prefs entries
accum srcpkgs prefs (CachePreference pref : entries) =
accum srcpkgs (pref:prefs) entries
- getPackageDescription blockno = do
+ getEntryContent blockno = do
hSeek hnd AbsoluteSeek (fromIntegral (blockno * 512))
header <- BS.hGet hnd 512
size <- getEntrySize header
- content <- BS.hGet hnd (fromIntegral size)
- readPackageDescription content
+ BS.hGet hnd (fromIntegral size)
getEntrySize header =
case Tar.read header of
View
29 cabal-install/Distribution/Client/Install.hs
@@ -22,6 +22,8 @@ import Data.List
( unfoldr, nub, sort, (\\) )
import Data.Maybe
( isJust, fromMaybe, maybeToList )
+import qualified Data.ByteString.Lazy.Char8 as BS
+ ( unpack )
import Control.Exception as Exception
( bracket, handleJust )
#if MIN_VERSION_base(4,0,0)
@@ -95,7 +97,7 @@ import qualified Distribution.Simple.Setup as Cabal
( installCommand, InstallFlags(..), emptyInstallFlags
, emptyTestFlags, testCommand, Flag(..) )
import Distribution.Simple.Utils
- ( rawSystemExit, comparing )
+ ( rawSystemExit, comparing, writeFileAtomic )
import Distribution.Simple.InstallDirs as InstallDirs
( PathTemplate, fromPathTemplate, toPathTemplate, substPathTemplate
, initialPathTemplateEnv, installDirsTemplateEnv )
@@ -755,13 +757,13 @@ performInstallations verbosity
executeInstallPlan verbosity jobControl useLogFile installPlan $ \cpkg ->
installConfiguredPackage platform compid configFlags
- cpkg $ \configFlags' src pkg ->
+ cpkg $ \configFlags' src pkg pkgoverride ->
fetchSourcePackage verbosity fetchLimit src $ \src' ->
installLocalPackage verbosity buildLimit (packageId pkg) src' $ \mpath ->
installUnpackedPackage verbosity buildLimit installLock numJobs
(setupScriptOptions installedPkgIndex cacheLock)
miscOptions configFlags' installFlags haddockFlags
- compid pkg mpath useLogFile
+ compid pkg pkgoverride mpath useLogFile
where
platform = InstallPlan.planPlatform installPlan
@@ -930,16 +932,17 @@ executeInstallPlan verbosity jobCtl useLogFile plan0 installPkg =
installConfiguredPackage :: Platform -> CompilerId
-> ConfigFlags -> ConfiguredPackage
-> (ConfigFlags -> PackageLocation (Maybe FilePath)
- -> PackageDescription -> a)
+ -> PackageDescription
+ -> PackageDescriptionOverride -> a)
-> a
installConfiguredPackage platform comp configFlags
- (ConfiguredPackage (SourcePackage _ gpkg source) flags stanzas deps)
+ (ConfiguredPackage (SourcePackage _ gpkg source pkgoverride) flags stanzas deps)
installPkg = installPkg configFlags {
configConfigurationsFlags = flags,
configConstraints = map thisPackageVersion deps,
configBenchmarks = toFlag False,
configTests = toFlag (TestStanzas `elem` stanzas)
- } source pkg
+ } source pkg pkgoverride
where
pkg = case finalizePackageDescription flags
(const True)
@@ -1025,13 +1028,25 @@ installUnpackedPackage
-> HaddockFlags
-> CompilerId
-> PackageDescription
+ -> PackageDescriptionOverride
-> Maybe FilePath -- ^ Directory to change to before starting the installation.
-> UseLogFile -- ^ File to log output to (if any)
-> IO BuildResult
installUnpackedPackage verbosity buildLimit installLock numJobs
scriptOptions miscOptions
configFlags installConfigFlags haddockFlags
- compid pkg workingDir useLogFile =
+ compid pkg pkgoverride workingDir useLogFile = do
+
+ -- Override the .cabal file if necessary
+ case pkgoverride of
+ Nothing -> return ()
+ Just pkgtxt -> do
+ let descFilePath = fromMaybe "." workingDir
+ </> display (packageName pkgid) <.> "cabal"
+ info verbosity $
+ "Updating " ++ display (packageName pkgid) <.> "cabal"
+ ++ " with the latest revision from the index."
+ writeFileAtomic descFilePath (BS.unpack pkgtxt)
-- Configure phase
onFailure ConfigureFailed $ withJobLimit buildLimit $ do
View
2  cabal-install/Distribution/Client/InstallSymlink.hs
@@ -133,7 +133,7 @@ symlinkBinaries configFlags installFlags plan =
, PackageDescription.buildable (PackageDescription.buildInfo exe) ]
pkgDescription :: ConfiguredPackage -> PackageDescription
- pkgDescription (ConfiguredPackage (SourcePackage _ pkg _) flags stanzas _) =
+ pkgDescription (ConfiguredPackage (SourcePackage _ pkg _ _) flags stanzas _) =
case finalizePackageDescription flags
(const True)
platform compilerId [] (enableStanzas stanzas pkg) of
View
14 cabal-install/Distribution/Client/Targets.hs
@@ -472,9 +472,10 @@ readPackageTarget verbosity target = case target of
pkg <- readPackageDescription verbosity =<< findPackageDesc dir
return $ PackageTargetLocation $
SourcePackage {
- packageInfoId = packageId pkg,
- packageDescription = pkg,
- packageSource = fmap Just location
+ packageInfoId = packageId pkg,
+ packageDescription = pkg,
+ packageSource = fmap Just location,
+ packageDescrOverride = Nothing
}
LocalTarballPackage tarballFile ->
@@ -497,9 +498,10 @@ readPackageTarget verbosity target = case target of
Just pkg ->
return $ PackageTargetLocation $
SourcePackage {
- packageInfoId = packageId pkg,
- packageDescription = pkg,
- packageSource = fmap Just location
+ packageInfoId = packageId pkg,
+ packageDescription = pkg,
+ packageSource = fmap Just location,
+ packageDescrOverride = Nothing
}
extractTarballPackageCabalFile :: FilePath -> String
View
12 cabal-install/Distribution/Client/Types.hs
@@ -29,6 +29,7 @@ import Distribution.Version
import Data.Map (Map)
import Network.URI (URI)
+import Data.ByteString.Lazy (ByteString)
import Distribution.Compat.Exception
( SomeException )
@@ -94,12 +95,17 @@ instance PackageFixedDeps ConfiguredPackage where
-- | A package description along with the location of the package sources.
--
data SourcePackage = SourcePackage {
- packageInfoId :: PackageId,
- packageDescription :: GenericPackageDescription,
- packageSource :: PackageLocation (Maybe FilePath)
+ packageInfoId :: PackageId,
+ packageDescription :: GenericPackageDescription,
+ packageSource :: PackageLocation (Maybe FilePath),
+ packageDescrOverride :: PackageDescriptionOverride
}
deriving Show
+-- | We sometimes need to override the .cabal file in the tarball with
+-- the newer one from the package index.
+type PackageDescriptionOverride = Maybe ByteString
+
instance Package SourcePackage where packageId = packageInfoId
data OptionalStanza
Please sign in to comment.
Something went wrong with that request. Please try again.