Commit 51142b81 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Update to the development version of the Cabal lib

The branch of cabal-install that tracks Cabal-1.4 now lives at
http://darcs.haskell.org/cabal-branches/cabal-install-0.5/
parent 33a90e4f
......@@ -36,7 +36,7 @@ import Distribution.Client.Utils
import qualified Paths_cabal_install (version)
import Distribution.Package
( PackageIdentifier(PackageIdentifier), Package(packageId) )
( PackageIdentifier(..), PackageName(..), Package(packageId) )
import Distribution.PackageDescription
( FlagName(..), FlagAssignment )
--import Distribution.Version
......@@ -135,9 +135,6 @@ new os' arch' comp (ConfiguredPackage pkg flags deps) result =
testsOutcome = convertTestsOutcome
}
where
cabalInstallID =
PackageIdentifier "cabal-install" Paths_cabal_install.version
convertInstallOutcome = case result of
Left (BR.DependentFailed p) -> DependencyFailed p
Left (BR.UnpackFailed _) -> UnpackFailed
......@@ -156,6 +153,10 @@ new os' arch' comp (ConfiguredPackage pkg flags deps) result =
Right (BR.BuildOk _ BR.TestsFailed) -> Failed
Right (BR.BuildOk _ BR.TestsOk) -> Ok
cabalInstallID :: PackageIdentifier
cabalInstallID =
PackageIdentifier (PackageName "cabal-install") Paths_cabal_install.version
-- ------------------------------------------------------------
-- * External format
-- ------------------------------------------------------------
......@@ -226,7 +227,7 @@ parseList str =
-- Pretty-printing
show :: BuildReport -> String
show br = Disp.render (ppFields br fieldDescrs)
show = Disp.render . ppFields fieldDescrs
-- -----------------------------------------------------------------------------
-- Description of the fields, for parsing/printing
......
......@@ -17,11 +17,15 @@ module Distribution.Client.Check (
import Control.Monad ( when, unless )
import Distribution.PackageDescription ( readPackageDescription )
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.PackageDescription.Check
import Distribution.PackageDescription.Configuration ( flattenPackageDescription )
import Distribution.Verbosity ( Verbosity )
import Distribution.Simple.Utils ( defaultPackageDesc, toUTF8 )
import Distribution.PackageDescription.Configuration
( flattenPackageDescription )
import Distribution.Verbosity
( Verbosity )
import Distribution.Simple.Utils
( defaultPackageDesc, toUTF8 )
check :: Verbosity -> IO Bool
check verbosity = do
......
......@@ -32,7 +32,7 @@ import Distribution.Client.Dependency.Types
( PackageName, DependencyResolver, PackageVersionPreference(..)
, Progress(..), foldProgress )
import Distribution.Package
( PackageIdentifier(..), packageVersion, packageName
( PackageIdentifier(..), PackageName(..), packageVersion, packageName
, Dependency(..), Package(..), PackageFixedDeps(..) )
import Distribution.Version
( orLaterVersion )
......@@ -113,8 +113,8 @@ hideBrokenPackages index =
check p x = assert (p x) x
hideBasePackage :: Package p => PackageIndex p -> PackageIndex p
hideBasePackage = PackageIndex.deletePackageName "base"
. PackageIndex.deletePackageName "ghc-prim"
hideBasePackage = PackageIndex.deletePackageName (PackageName "base")
. PackageIndex.deletePackageName (PackageName "ghc-prim")
dependencyResolver
:: DependencyResolver
......
......@@ -265,9 +265,9 @@ annotateInstalledPackages dfsNumber installed = PackageIndex.fromList
| pkg <- PackageIndex.allPackages installed ]
where
transitiveDepends :: InstalledPackageInfo -> [PackageIdentifier]
transitiveDepends = map toPkgid . tail . Graph.reachable graph
transitiveDepends = map (packageId . toPkg) . tail . Graph.reachable graph
. fromJust . toVertex . packageId
(graph, toPkgid, toVertex) = PackageIndex.dependencyGraph installed
(graph, toPkg, toVertex) = PackageIndex.dependencyGraph installed
-- | Annotate each available packages with its topological sort number and any
......@@ -424,11 +424,11 @@ improvePlan installed selected = foldl' improve selected
reverseTopologicalOrder :: PackageFixedDeps pkg => PackageIndex pkg
-> [PackageIdentifier]
reverseTopologicalOrder index = map toPkgId
reverseTopologicalOrder index = map (packageId . toPkg)
. Graph.topSort
. Graph.transposeG
$ graph
where (graph, toPkgId, _) = PackageIndex.dependencyGraph index
where (graph, toPkg, _) = PackageIndex.dependencyGraph index
-- ------------------------------------------------------------
-- * Adding and recording constraints
......@@ -549,7 +549,7 @@ showFailure (ConfigureFailed pkg missingDeps) =
where
whyNot (Dependency name ver) [] =
"There is no available version of " ++ name
"There is no available version of " ++ display name
++ " that satisfies " ++ display ver
whyNot dep conflicts =
......@@ -574,7 +574,7 @@ showFailure (TopLevelDependencyConflict dep conflicts) =
| (pkg', reasons) <- conflicts, reason <- reasons ]
showFailure (TopLevelDependencyUnsatisfiable (Dependency name ver)) =
"There is no available version of " ++ name
"There is no available version of " ++ display name
++ " that satisfies " ++ display ver
-- ------------------------------------------------------------
......
......@@ -24,17 +24,15 @@ import Distribution.Client.Dependency.TopDown.Types
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Package
( PackageIdentifier, Package(packageId), packageVersion, packageName
( PackageIdentifier, Package(packageId), packageVersion
, Dependency(Dependency) )
import Distribution.Version
( withinRange )
import Distribution.Simple.Utils
( comparing )
import Distribution.Client.Utils
( mergeBy, MergeResult(..) )
import Data.List
( foldl', sortBy )
( foldl' )
import Data.Monoid
( Monoid(mempty) )
import Control.Exception
......@@ -95,20 +93,11 @@ transitionsTo constraints @(Constraints available excluded )
excludedLost = [ pkg | OnlyInLeft pkg <- excludedChange ]
excludedGained = [ pkg | OnlyInRight pkg <- excludedChange ]
availableChange = mergeBy (\a b -> packageId a `compare` packageId b)
(allPackagesInOrder available)
(allPackagesInOrder available')
(PackageIndex.allPackages available)
(PackageIndex.allPackages available')
excludedChange = mergeBy (\a b -> packageId a `compare` packageId b)
(allPackagesInOrder excluded)
(allPackagesInOrder excluded')
--FIXME: PackageIndex.allPackages returns in sorted order case-insensitively
-- but that's no good for our merge which uses Ord
allPackagesInOrder :: Package pkg => PackageIndex pkg -> [pkg]
allPackagesInOrder index =
concatMap snd
. sortBy (comparing fst)
$ [ (packageName pkg, grp)
| grp@(pkg:_) <- PackageIndex.allPackagesByName index ]
(PackageIndex.allPackages excluded)
(PackageIndex.allPackages excluded')
-- | We construct 'Constraints' with an initial 'PackageIndex' of all the
-- packages available.
......@@ -122,11 +111,11 @@ empty installed available = Constraints pkgs mempty
pkgs = PackageIndex.fromList
. map toInstalledOrAvailable
$ mergeBy (\a b -> packageId a `compare` packageId b)
(allPackagesInOrder installed)
(allPackagesInOrder available)
(PackageIndex.allPackages installed)
(PackageIndex.allPackages available)
toInstalledOrAvailable (OnlyInLeft i ) = InstalledOnly i
toInstalledOrAvailable (OnlyInRight a) = AvailableOnly a
toInstalledOrAvailable (InBoth i a) = InstalledAndAvailable i a
toInstalledOrAvailable (InBoth i a) = InstalledAndAvailable i a
-- | The package choices that are still available.
--
......
......@@ -26,6 +26,8 @@ import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import Distribution.Simple.PackageIndex
( PackageIndex )
import Distribution.Package
( PackageName )
import Distribution.Compiler
( CompilerId )
import Distribution.System
......@@ -33,8 +35,6 @@ import Distribution.System
import Prelude hiding (fail)
type PackageName = String
-- | A dependency resolver is a function that works out an installation plan
-- given the set of installed and available packages and a set of deps to
-- solve for.
......
......@@ -35,7 +35,7 @@ import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.HttpUtils (getHTTP, isOldHackageURI)
import Distribution.Package
( PackageIdentifier(..), Dependency(..) )
( PackageIdentifier, packageName, packageVersion, Dependency(..) )
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.Compiler
( Compiler(compilerId), PackageDB )
......@@ -191,8 +191,8 @@ packageFile repo pkgid = packageDir repo pkgid
-- the tarball for a given @PackageIdentifer@ is stored.
packageDir :: Repo -> PackageIdentifier -> FilePath
packageDir repo pkgid = repoLocalDir repo
</> pkgName pkgid
</> display (pkgVersion pkgid)
</> display (packageName pkgid)
</> display (packageVersion pkgid)
-- | Generate the URI of the tarball for a given package.
packageURI :: RemoteRepo -> PackageIdentifier -> URI
......@@ -200,8 +200,8 @@ packageURI repo pkgid | isOldHackageURI (remoteRepoURI repo) =
(remoteRepoURI repo) {
uriPath = FilePath.Posix.joinPath
[uriPath (remoteRepoURI repo)
,pkgName pkgid
,display (pkgVersion pkgid)
,display (packageName pkgid)
,display (packageVersion pkgid)
,display pkgid <.> "tar.gz"]
}
packageURI repo pkgid =
......
......@@ -23,15 +23,16 @@ import Distribution.Client.Types
, AvailablePackageSource(..), Repo(..), RemoteRepo(..) )
import Distribution.Package
( PackageIdentifier(..), Package(..), Dependency(Dependency) )
( PackageIdentifier(..), PackageName(..), Package(..)
, Dependency(Dependency) )
import Distribution.Simple.PackageIndex (PackageIndex)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
( parsePackageDescription )
import Distribution.ParseUtils
( ParseResult(..) )
import Distribution.Text
( simpleParse )
( display, simpleParse )
import Distribution.Verbosity (Verbosity)
import Distribution.Simple.Utils (die, warn, info, intercalate, fromUTF8)
......@@ -81,7 +82,7 @@ readRepoIndex verbosity repo =
= case splitDirectories (normalise fileName) of
[pkgname,vers,_] -> case simpleParse vers of
Just ver -> Just AvailablePackage {
packageInfoId = PackageIdentifier pkgname ver,
packageInfoId = PackageIdentifier (PackageName pkgname) ver,
packageDescription = descr,
packageSource = RepoTarballPackage repo
}
......@@ -126,9 +127,9 @@ disambiguateDependencies index deps = do
(_, Left name)) <- zip deps names ]
ambigious -> die $ unlines
[ if null matches
then "There is no package named " ++ name
else "The package name " ++ name ++ "is ambigious. "
++ "It could be: " ++ intercalate ", " matches
then "There is no package named " ++ display name
else "The package name " ++ display name ++ "is ambigious. "
++ "It could be: " ++ intercalate ", " (map display matches)
| (name, matches) <- ambigious ]
-- | Given an index of known packages and a package name, figure out which one it
......@@ -138,9 +139,9 @@ disambiguateDependencies index deps = do
-- that case it is ambigious.
--
disambiguatePackageName :: PackageIndex AvailablePackage
-> String
-> Either String [String]
disambiguatePackageName index name =
-> PackageName
-> Either PackageName [PackageName]
disambiguatePackageName index (PackageName name) =
case PackageIndex.searchByName index name of
PackageIndex.None -> Right []
PackageIndex.Unambiguous pkgs -> Left (pkgName (packageId (head pkgs)))
......
......@@ -71,16 +71,18 @@ import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.Setup
( flagToMaybe )
import Distribution.Simple.Utils
( defaultPackageDesc, inDir, rawSystemExit, withTempDirectory )
( defaultPackageDesc, rawSystemExit, withTempDirectory )
import Distribution.Simple.InstallDirs
( fromPathTemplate, toPathTemplate
, initialPathTemplateEnv, substPathTemplate )
import Distribution.Package
( PackageIdentifier(..), Package(..), thisPackageVersion
( PackageIdentifier, packageName, Package(..), thisPackageVersion
, Dependency(..) )
import qualified Distribution.PackageDescription as PackageDescription
import Distribution.PackageDescription
( PackageDescription, readPackageDescription )
( PackageDescription )
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.PackageDescription.Configuration
( finalizePackageDescription )
import Distribution.InstalledPackageInfo
......@@ -89,6 +91,8 @@ import Distribution.Version
( Version, VersionRange(AnyVersion, ThisVersion) )
import Distribution.Simple.Utils as Utils
( notice, info, warn, die, intercalate )
import Distribution.Client.Utils
( inDir )
import Distribution.System
( OS(Windows), buildOS, Arch, buildArch )
import Distribution.Text
......@@ -414,7 +418,7 @@ installAvailablePackage verbosity pkgid (RepoTarballPackage repo) installPkg = d
info verbosity $ "Extracting " ++ pkgPath ++ " to " ++ tmpDirPath ++ "..."
extractTarGzFile tmpDirPath pkgPath
let descFilePath = tmpDirPath </> display pkgid
</> pkgName pkgid <.> "cabal"
</> display (packageName pkgid) <.> "cabal"
exists <- doesFileExist descFilePath
when (not exists) $
die $ "Package .cabal file not found: " ++ show descFilePath
......
......@@ -48,8 +48,8 @@ import Distribution.Client.Types
( AvailablePackage(packageDescription), ConfiguredPackage(..)
, BuildFailure, BuildSuccess )
import Distribution.Package
( PackageIdentifier(..), Package(..), PackageFixedDeps(..)
, packageName, Dependency(..) )
( PackageIdentifier(..), PackageName(..), Package(..), packageName
, PackageFixedDeps(..), Dependency(..) )
import Distribution.Version
( Version, withinRange )
import Distribution.InstalledPackageInfo
......@@ -146,7 +146,7 @@ data InstallPlan = InstallPlan {
planIndex :: PackageIndex PlanPackage,
planGraph :: Graph,
planGraphRev :: Graph,
planPkgIdOf :: Graph.Vertex -> PackageIdentifier,
planPkgOf :: Graph.Vertex -> PlanPackage,
planVertexOf :: PackageIdentifier -> Graph.Vertex,
planOS :: OS,
planArch :: Arch,
......@@ -170,7 +170,7 @@ new os arch compiler index =
planIndex = index,
planGraph = graph,
planGraphRev = Graph.transposeG graph,
planPkgIdOf = vertexToPkgId,
planPkgOf = vertexToPkgId,
planVertexOf = fromMaybe noSuchPkgId . pkgIdToVertex,
planOS = os,
planArch = arch,
......@@ -240,14 +240,14 @@ failed pkgid buildResult buildResult' plan = assert (invariant plan') plan'
failures = PackageIndex.fromList
$ Failed pkg buildResult
: [ Failed pkg' buildResult'
| Just pkg' <- map (lookupConfiguredPackage' plan)
| Just pkg' <- map checkConfiguredPackage
$ packagesThatDependOn plan pkgid ]
-- | lookup the reachable packages in the reverse dependency graph
--
packagesThatDependOn :: InstallPlan
-> PackageIdentifier -> [PackageIdentifier]
packagesThatDependOn plan = map (planPkgIdOf plan)
-> PackageIdentifier -> [PlanPackage]
packagesThatDependOn plan = map (planPkgOf plan)
. tail
. Graph.reachable (planGraphRev plan)
. planVertexOf plan
......@@ -261,15 +261,13 @@ lookupConfiguredPackage plan pkgid =
Just (Configured pkg) -> pkg
_ -> internalError $ "not configured or no such pkg " ++ display pkgid
-- | lookup a package that we expect to be in the configured or failed state
-- | check a package that we expect to be in the configured or failed state
--
lookupConfiguredPackage' :: InstallPlan
-> PackageIdentifier -> Maybe ConfiguredPackage
lookupConfiguredPackage' plan pkgid =
case PackageIndex.lookupPackageId (planIndex plan) pkgid of
Just (Configured pkg) -> Just pkg
Just (Failed _ _) -> Nothing
_ -> internalError $ "not configured or no such pkg " ++ display pkgid
checkConfiguredPackage :: PlanPackage -> Maybe ConfiguredPackage
checkConfiguredPackage (Configured pkg) = Just pkg
checkConfiguredPackage (Failed _ _) = Nothing
checkConfiguredPackage pkg =
internalError $ "not configured or no such pkg " ++ display (packageId pkg)
-- ------------------------------------------------------------
-- * Checking valididy of plans
......@@ -288,7 +286,7 @@ data PlanProblem =
PackageInvalid ConfiguredPackage [PackageProblem]
| PackageMissingDeps PlanPackage [PackageIdentifier]
| PackageCycle [PlanPackage]
| PackageInconsistency String [(PackageIdentifier, Version)]
| PackageInconsistency PackageName [(PackageIdentifier, Version)]
| PackageStateInvalid PlanPackage PlanPackage
showPlanProblem :: PlanProblem -> String
......@@ -308,7 +306,7 @@ showPlanProblem (PackageCycle cycleGroup) =
++ intercalate ", " (map (display.packageId) cycleGroup)
showPlanProblem (PackageInconsistency name inconsistencies) =
"Package " ++ name
"Package " ++ display name
++ " is required by several packages,"
++ " but they require inconsistent versions:\n"
++ unlines [ " package " ++ display pkg ++ " requires "
......
......@@ -23,7 +23,8 @@ import Text.PrettyPrint.HughesPJ
import Distribution.Text
( Text(disp), display )
import Distribution.Package (PackageIdentifier(..), Package(..))
import Distribution.Package
( PackageIdentifier(..), PackageName(..), Package(..) )
import Distribution.License (License)
import qualified Distribution.PackageDescription as Available
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
......@@ -66,7 +67,7 @@ list verbosity packageDB repos comp conf listFlags pats = do
if simpleOutput
then putStr $ unlines
[ name pkg ++ " " ++ display version
[ display(name pkg) ++ " " ++ display version
| pkg <- matches
, version <- if onlyInstalled
then installedVersions pkg
......@@ -87,7 +88,7 @@ list verbosity packageDB repos comp conf listFlags pats = do
-- package name and covers all installed and avilable versions.
--
data PackageDisplayInfo = PackageDisplayInfo {
name :: String,
name :: PackageName,
installedVersions :: [Version],
availableVersions :: [Version],
homepage :: String,
......@@ -99,7 +100,7 @@ data PackageDisplayInfo = PackageDisplayInfo {
showPackageInfo :: PackageDisplayInfo -> String
showPackageInfo pkg =
renderStyle (style {lineLength = 80, ribbonsPerLine = 1}) $
text " *" <+> text (name pkg)
text " *" <+> disp (name pkg)
$+$
(nest 6 $ vcat [
maybeShow (availableVersions pkg)
......
......@@ -25,11 +25,13 @@ import qualified Distribution.Simple as Simple
import Distribution.Version
( Version(..), VersionRange(..), withinRange )
import Distribution.Package
( PackageIdentifier(..), Package(..), packageName, packageVersion
, Dependency(..) )
( PackageIdentifier(..), PackageName(..), Package(..), packageName
, packageVersion, Dependency(..) )
import Distribution.PackageDescription
( GenericPackageDescription(packageDescription)
, PackageDescription(..), BuildType(..), readPackageDescription )
, PackageDescription(..), BuildType(..) )
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import Distribution.Simple.Configure
......@@ -49,20 +51,20 @@ import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.Utils
( die, debug, info, cabalVersion, findPackageDesc, comparing
, createDirectoryIfMissingVerbose, inDir )
, createDirectoryIfMissingVerbose )
import Distribution.Client.Utils
( moreRecentFile, rewriteFile, inDir )
import Distribution.Text
( display )
import Distribution.Verbosity
( Verbosity )
import System.Directory ( doesFileExist, getModificationTime, getCurrentDirectory )
import System.Directory ( doesFileExist, getCurrentDirectory )
import System.FilePath ( (</>), (<.>) )
import System.IO.Error ( isDoesNotExistError )
import System.IO ( Handle )
import System.Exit ( ExitCode(..), exitWith )
import System.Process ( runProcess, waitForProcess )
import Control.Monad ( when, unless )
import Control.Exception ( evaluate )
import Data.List ( maximumBy )
import Data.Maybe ( fromMaybe, isJust )
import Data.Monoid ( Monoid(mempty) )
......@@ -192,7 +194,7 @@ externalSetupMethod verbosity options pkg bt mkargs = do
installedCabalVersion :: SetupScriptOptions -> Compiler
-> ProgramConfiguration -> IO Version
installedCabalVersion _ _ _ | packageName pkg == "Cabal" =
installedCabalVersion _ _ _ | packageName pkg == PackageName "Cabal" =
return (packageVersion pkg)
installedCabalVersion options' comp conf = do
index <- case usePackageIndex options' of
......@@ -201,7 +203,7 @@ externalSetupMethod verbosity options pkg bt mkargs = do
`fmap` getInstalledPackages verbosity comp UserPackageDB conf
-- user packages are *allowed* here, no portability problem
let cabalDep = Dependency "Cabal" (useCabalVersion options)
let cabalDep = Dependency (PackageName "Cabal") (useCabalVersion options)
case PackageIndex.lookupDependency index cabalDep of
[] -> die $ "The package requires Cabal library version "
++ display (useCabalVersion options)
......@@ -275,10 +277,10 @@ externalSetupMethod verbosity options pkg bt mkargs = do
ghcVerbosityOptions verbosity
++ ["--make", setupHsFile, "-o", setupProgFile
,"-odir", setupDir, "-hidir", setupDir]
++ if packageName pkg == "Cabal"
++ if packageName pkg == PackageName "Cabal"
then ["-i", "-i."]
else ["-i", "-package", display cabalPkgid ]
where cabalPkgid = PackageIdentifier "Cabal" cabalLibVersion
where cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion
invokeSetupScript :: [String] -> IO ()
invokeSetupScript args = do
......@@ -293,36 +295,3 @@ externalSetupMethod verbosity options pkg bt mkargs = do
Nothing (useLoggingHandle options) (useLoggingHandle options)
exitCode <- waitForProcess process
unless (exitCode == ExitSuccess) $ exitWith exitCode
-- ------------------------------------------------------------
-- * Utils
-- ------------------------------------------------------------
-- | Compare the modification times of two files to see if the first is newer
-- than the second. The first file must exist but the second need not.
-- The expected use case is when the second file is generated using the first.
-- In this use case, if the result is True then the second file is out of date.
--
moreRecentFile :: FilePath -> FilePath -> IO Bool
moreRecentFile a b = do
exists <- doesFileExist b
if not exists
then return True
else do tb <- getModificationTime b
ta <- getModificationTime a
return (ta > tb)
-- | Write a file but only if it would have new content. If we would be writing
-- the same as the existing content then leave the file as is so that we do not
-- update the file's modification time.
--
rewriteFile :: FilePath -> String -> IO ()
rewriteFile path newContent =
flip catch mightNotExist $ do
existingContent <- readFile path
evaluate (length existingContent)
unless (existingContent == newContent) $
writeFile path newContent
where
mightNotExist e | isDoesNotExistError e = writeFile path newContent
| otherwise = ioError e
......@@ -5,13 +5,16 @@ module Distribution.Client.SrcDist (
sdist
) where
import Distribution.Simple.SrcDist
( printPackageProblems, prepareTree, prepareSnapshotTree )
( printPackageProblems, prepareTree
, prepareSnapshotTree, snapshotPackage )
import Distribution.Client.Tar (createTarGzFile)
import Distribution.Package
( Package(..) )
import Distribution.PackageDescription
( PackageDescription, readPackageDescription )
( PackageDescription )
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.Simple.Utils
( withTempDirectory , defaultPackageDesc
, die, warn, notice, setupMessage )
......@@ -52,13 +55,14 @@ sdist flags = do
withTempDirectory verbosity tmpDir $ do
setupMessage verbosity "Building source dist for" (packageId pkg)
date <- toCalendarTime =<< getClockTime
let pkg' | snapshot = snapshotPackage date pkg
| otherwise = pkg
setupMessage verbosity "Building source dist for" (packageId pkg')
if snapshot
then getClockTime >>= toCalendarTime
>>= prepareSnapshotTree verbosity pkg mb_lbi
distPref tmpDir knownSuffixHandlers
else prepareTree verbosity pkg mb_lbi
distPref tmpDir knownSuffixHandlers
then prepareSnapshotTree verbosity pkg' mb_lbi distPref tmpDir pps
else prepareTree verbosity pkg' mb_lbi distPref tmpDir pps
targzFile <- createArchive verbosity pkg tmpDir distPref
notice verbosity $ "Source tarball created: " ++ targzFile
......@@ -66,6 +70,7 @@ sdist flags = do