[commit: packages/Cabal] ghc-head: Reowrk the logic a bit. (300f61d)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:24:07 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=300f61debb5232e8327c4f26b60eb2b0f452e3af

>---------------------------------------------------------------

commit 300f61debb5232e8327c4f26b60eb2b0f452e3af
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date:   Thu May 2 20:43:34 2013 +0200

    Reowrk the logic a bit.


>---------------------------------------------------------------

300f61debb5232e8327c4f26b60eb2b0f452e3af
 cabal-install/Distribution/Client/SrcDist.hs |   38 ++++++++++++++++----------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/cabal-install/Distribution/Client/SrcDist.hs b/cabal-install/Distribution/Client/SrcDist.hs
index 379c7c1..247790e 100644
--- a/cabal-install/Distribution/Client/SrcDist.hs
+++ b/cabal-install/Distribution/Client/SrcDist.hs
@@ -44,40 +44,48 @@ sdist flags exflags = do
   pkg <- return . flattenPackageDescription
          =<< readPackageDescription verbosity
          =<< defaultPackageDesc verbosity
-  let withDir = if isOutDirectory then (\f -> f tmpTargetDir)
+  let withDir = if not needMakeArchive then (\f -> f tmpTargetDir)
                 else withTempDirectory verbosity False tmpTargetDir "sdist."
-  -- Otherwise 'withTempDir' fails...
-  createDirectoryIfMissingVerbose verbosity True tmpTargetDir
+  -- 'withTempDir' fails if we don't create 'tmpTargetDir'...
+  when needMakeArchive $
+    createDirectoryIfMissingVerbose verbosity True tmpTargetDir
   withDir $ \tmpDir -> do
     let outDir = if isOutDirectory then tmpDir else tmpDir </> tarBallName pkg
-        flags' = (if isOutDirectory then flags
+        flags' = (if not needMakeArchive then flags
                   else flags { sDistDirectory = Flag outDir })
                  { sDistVerbosity = Flag $ if   verbosity == normal
                                            then lessVerbose verbosity
                                            else verbosity }
+    unless isListSources $
+      createDirectoryIfMissingVerbose verbosity True outDir
 
-    createDirectoryIfMissingVerbose verbosity True outDir
-
-    -- Run 'setup sdist --output-directory=tmpDir'
+    -- Run 'setup sdist --output-directory=tmpDir' (or
+    -- '--list-source'/'--output-directory=someOtherDir') in case we were passed
+    -- those options.
     setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags') []
 
-    -- And unless we were given --list-sources or --output-directory ourselves,
+    -- Unless we were given --list-sources or --output-directory ourselves,
     -- create an archive.
-    unless (isListSources || isOutDirectory) $
+    when needMakeArchive $
       createArchive verbosity pkg tmpDir distPref
 
     when isOutDirectory $
       notice verbosity $ "Source directory created: " ++ tmpTargetDir
 
+    when isListSources $
+      notice verbosity $ "List of package sources written to file '"
+                         ++ (fromFlag . sDistListSources $ flags) ++ "'"
+
   where
     flagEnabled f  = not . null . flagToList . f $ flags
 
-    isListSources  = flagEnabled sDistListSources
-    isOutDirectory = flagEnabled sDistDirectory
-    verbosity      = fromFlag (sDistVerbosity flags)
-    distPref       = fromFlag (sDistDistPref flags)
-    tmpTargetDir   = fromFlagOrDefault (srcPref distPref) (sDistDirectory flags)
-    setupOpts      = defaultSetupScriptOptions {
+    isListSources   = flagEnabled sDistListSources
+    isOutDirectory  = flagEnabled sDistDirectory
+    needMakeArchive = not (isListSources || isOutDirectory)
+    verbosity       = fromFlag (sDistVerbosity flags)
+    distPref        = fromFlag (sDistDistPref flags)
+    tmpTargetDir    = fromFlagOrDefault (srcPref distPref) (sDistDirectory flags)
+    setupOpts       = defaultSetupScriptOptions {
       -- The '--output-directory' sdist flag was introduced in Cabal 1.12, and
       -- '--list-sources' in 1.17.
       useCabalVersion = if isListSources





More information about the ghc-commits mailing list