Skip to content

Commit 2916a26

Browse files
Add flag to enable/disable building of sdist tarball
1 parent bccfc5f commit 2916a26

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Stack/Options/SDistParser.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ sdistOptsParser signDefault = SDistOpts <$>
1919
strOption
2020
(long "sig-server" <> metavar "URL" <> showDefault <>
2121
value "https://sig.commercialhaskell.org" <>
22-
help "URL")
22+
help "URL") <*>
23+
buildPackageOption
2324
where
2425
ignoreCheckSwitch =
2526
switch (long "ignore-check"
2627
<> help "Do not check package for common mistakes")
28+
buildPackageOption =
29+
boolFlags False "build-package" "building of the resulting package" idm

src/Stack/SDist.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import qualified Codec.Archive.Tar.Entry as Tar
1919
import qualified Codec.Compression.GZip as GZip
2020
import Control.Applicative
2121
import Control.Concurrent.Execute (ActionContext(..))
22-
import Control.Monad (unless, void, liftM, filterM, foldM)
22+
import Control.Monad (unless, void, liftM, filterM, foldM, when)
2323
import Control.Monad.Catch
2424
import Control.Monad.IO.Class
2525
import Control.Monad.Logger
@@ -90,6 +90,8 @@ data SDistOpts = SDistOpts
9090
-- ^ Whether to sign the package
9191
, sdoptsSignServerUrl :: String
9292
-- ^ The URL of the signature server
93+
, sdoptsBuildTarball :: Bool
94+
-- ^ Whether to build the tarball
9395
}
9496

9597
newtype CheckException
@@ -343,7 +345,7 @@ checkSDistTarball opts tarball = withTempTarGzContents tarball $ \pkgDir' -> do
343345
pkgDir <- (pkgDir' </>) `liftM`
344346
(parseRelDir . FP.takeBaseName . FP.takeBaseName . toFilePath $ tarball)
345347
-- ^ drop ".tar" ^ drop ".gz"
346-
buildExtractedTarball pkgDir
348+
when (sdoptsBuildTarball opts) (buildExtractedTarball pkgDir)
347349
unless (sdoptsIgnoreCheck opts) (checkPackageInExtractedTarball pkgDir)
348350

349351
checkPackageInExtractedTarball :: (StackM env m, HasEnvConfig env, MonadBaseUnlift IO m)

src/main/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ upgradeCmd upgradeOpts' go = withGlobalConfigAndLock go $
657657

658658
-- | Upload to Hackage
659659
uploadCmd :: SDistOpts -> GlobalOpts -> IO ()
660-
uploadCmd (SDistOpts [] _ _ _ _) _ = throwString "Error: To upload the current package, please run 'stack upload .'"
660+
uploadCmd (SDistOpts [] _ _ _ _ _) _ = throwString "Error: To upload the current package, please run 'stack upload .'"
661661
uploadCmd sdistOpts go = do
662662
let partitionM _ [] = return ([], [])
663663
partitionM f (x:xs) = do

0 commit comments

Comments
 (0)