From cbb5d34ff939d1f5c8d7ff40e8daf4011a129dab Mon Sep 17 00:00:00 2001 From: achernyak Date: Sat, 30 Jan 2016 17:43:01 -0600 Subject: [PATCH 01/13] init accepts list of directories to search --- src/Stack/Init.hs | 20 +++++++++++--------- src/Stack/Options.hs | 44 +++++++++++++++++++++++++------------------- src/main/Main.hs | 15 +++++++++++++-- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index e8c69ccced..30290f0035 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -13,15 +13,15 @@ import Control.Monad (when) import Control.Monad.Catch (MonadMask, throwM) import Control.Monad.IO.Class import Control.Monad.Logger -import Control.Monad.Reader (asks, MonadReader) +import Control.Monad.Reader (MonadReader, asks) import Control.Monad.Trans.Control (MonadBaseControl) import qualified Data.ByteString.Builder as B -import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Char8 as BC +import qualified Data.ByteString.Lazy as L +import qualified Data.Foldable as F import Data.Function (on) import qualified Data.HashMap.Strict as HM import qualified Data.IntMap as IntMap -import qualified Data.Foldable as F import Data.List (intersect, maximumBy) import Data.List.Extra (nubOrd) import Data.Map (Map) @@ -35,14 +35,14 @@ import Network.HTTP.Client.Conduit (HasHttpManager) import Path import Path.IO import Stack.BuildPlan +import Stack.Config (getSnapshots, + makeConcreteResolver) import Stack.Constants import Stack.Solver import Stack.Types -import Stack.Types.Internal ( HasTerminal, HasReExec - , HasLogLevel) +import Stack.Types.Internal (HasLogLevel, HasReExec, + HasTerminal) import System.Directory (makeRelativeToCurrentDirectory) -import Stack.Config ( getSnapshots - , makeConcreteResolver) import qualified System.FilePath as FP -- | Generate stack.yaml @@ -437,12 +437,14 @@ getRecommendedSnapshots snapshots = do ] data InitOpts = InitOpts - { useSolver :: Bool + { useSolver :: Bool -- ^ Use solver to determine required external dependencies - , omitPackages :: Bool + , omitPackages :: Bool -- ^ Exclude conflicting or incompatible user packages , forceOverwrite :: Bool -- ^ Overwrite existing stack.yaml , includeSubDirs :: Bool -- ^ If True, include all .cabal files found in any sub directories + , searchDirs :: ![T.Text] + -- ^ List of sub directories to search for .cabal files } diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index 420f189462..beb81827e2 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE OverloadedStrings,RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} module Stack.Options (BuildCommand(..) @@ -26,32 +27,32 @@ module Stack.Options ,globalOptsFromMonoid ) where -import Control.Monad.Logger (LogLevel(..)) -import Data.Char (isSpace, toLower) -import Data.List (intercalate) -import Data.List.Split (splitOn) -import qualified Data.Map as Map -import Data.Map.Strict (Map) -import qualified Data.Map.Strict as M +import Control.Monad.Logger (LogLevel (..)) +import Data.Char (isSpace, toLower) +import Data.List (intercalate) +import Data.List.Split (splitOn) +import qualified Data.Map as Map +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as M import Data.Maybe import Data.Monoid -import qualified Data.Set as Set -import qualified Data.Text as T -import Data.Text.Read (decimal) -import Distribution.Version (anyVersion) +import qualified Data.Set as Set +import qualified Data.Text as T +import Data.Text.Read (decimal) +import Distribution.Version (anyVersion) import Options.Applicative import Options.Applicative.Args import Options.Applicative.Builder.Extra -import Options.Applicative.Types (fromM, oneM, readerAsk) -import Stack.Clean (CleanOpts(..)) -import Stack.Config (packagesParser) +import Options.Applicative.Types (fromM, oneM, readerAsk) +import Stack.Clean (CleanOpts (..)) +import Stack.Config (packagesParser) import Stack.ConfigCmd -import Stack.Constants (stackProgName) -import Stack.Coverage (HpcReportOpts(..)) +import Stack.Constants (stackProgName) +import Stack.Coverage (HpcReportOpts (..)) import Stack.Docker -import qualified Stack.Docker as Docker +import qualified Stack.Docker as Docker import Stack.Dot -import Stack.Ghci (GhciOpts(..)) +import Stack.Ghci (GhciOpts (..)) import Stack.Init import Stack.New import Stack.Nix @@ -676,7 +677,12 @@ initOptsParser :: Parser InitOpts initOptsParser = InitOpts <$> solver <*> omitPackages <*> overwrite <*> fmap not ignoreSubDirs + <*> searchDirs where + searchDirs = + many (textArgument + (metavar "SEARCH-DIRECTORIES" <> + help "Directories which are searched for cabal files. If non specified, uses current directory.")) ignoreSubDirs = switch (long "ignore-subdirs" <> help "Do not search for .cabal files in sub directories") overwrite = switch (long "force" <> diff --git a/src/main/Main.hs b/src/main/Main.hs index 56e9987ce5..ff069917ae 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -1175,8 +1175,19 @@ withMiniConfigAndLock go inner = -- | Project initialization initCmd :: InitOpts -> GlobalOpts -> IO () initCmd initOpts go = do - pwd <- getWorkingDir - withMiniConfigAndLock go (initProject pwd initOpts (globalResolver go)) + let selectedDirs = searchDirs initOpts + if null selectedDirs + then do + pwd <- getWorkingDir + checkDir pwd + else checkSubDirs selectedDirs + where checkSubDirs = mapM_ (liftM checkDir . parseRelAsAbsDir . T.unpack) + checkDir dir = + withMiniConfigAndLock go $ + initProject dir initOpts $ + globalResolver go + + -- | Create a project directory structure and initialize the stack config. newCmd :: (NewOpts,InitOpts) -> GlobalOpts -> IO () From 6fc13cde2b8f00a858d57a66b3725692de91fc2a Mon Sep 17 00:00:00 2001 From: achernyak Date: Mon, 8 Feb 2016 20:03:28 -0600 Subject: [PATCH 02/13] reworked --- src/Stack/Init.hs | 16 +++++++++++----- src/main/Main.hs | 19 ++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index 30290f0035..c74bba7e77 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -9,7 +9,7 @@ module Stack.Init import Control.Exception (assert) import Control.Exception.Enclosed (catchAny) -import Control.Monad (when) +import Control.Monad (liftM, when) import Control.Monad.Catch (MonadMask, throwM) import Control.Monad.IO.Class import Control.Monad.Logger @@ -52,12 +52,13 @@ initProject , HasHttpManager env , HasLogLevel env , HasReExec env , HasTerminal env) => Path Abs Dir + -> [Path Abs Dir] -> InitOpts -> Maybe AbstractResolver -> m () -initProject currDir initOpts mresolver = do +initProject currDir searchDirs' initOpts mresolver = do let dest = currDir stackDotYaml - dest' = toFilePath dest + dest' = toFilePath currDir reldest <- liftIO $ makeRelativeToCurrentDirectory dest' @@ -69,8 +70,13 @@ initProject currDir initOpts mresolver = do let noPkgMsg = "In order to init, you should have an existing .cabal \ \file. Please try \"stack new\" instead." - - cabalfps <- findCabalFiles (includeSubDirs initOpts) currDir + let findCabalFiles' = findCabalFiles (includeSubDirs initOpts) + cabalfps <- if null searchDirs' + then + findCabalFiles' currDir + else + liftM concat $ + mapM findCabalFiles' searchDirs' (bundle, dupPkgs) <- cabalPackagesCheck cabalfps noPkgMsg Nothing (r, flags, extraDeps, rbundle) <- getDefaultResolver dest initOpts diff --git a/src/main/Main.hs b/src/main/Main.hs index ff069917ae..2c57043498 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -1176,25 +1176,18 @@ withMiniConfigAndLock go inner = initCmd :: InitOpts -> GlobalOpts -> IO () initCmd initOpts go = do let selectedDirs = searchDirs initOpts - if null selectedDirs - then do - pwd <- getWorkingDir - checkDir pwd - else checkSubDirs selectedDirs - where checkSubDirs = mapM_ (liftM checkDir . parseRelAsAbsDir . T.unpack) - checkDir dir = - withMiniConfigAndLock go $ - initProject dir initOpts $ - globalResolver go - - + selectedDirs' <- mapM (parseRelAsAbsDir . T.unpack) selectedDirs + pwd <- getWorkingDir + withMiniConfigAndLock go $ + initProject pwd selectedDirs' initOpts $ + globalResolver go -- | Create a project directory structure and initialize the stack config. newCmd :: (NewOpts,InitOpts) -> GlobalOpts -> IO () newCmd (newOpts,initOpts) go@GlobalOpts{..} = do withMiniConfigAndLock go $ do dir <- new newOpts - initProject dir initOpts globalResolver + initProject dir [] initOpts globalResolver -- | List the available templates. templatesCmd :: () -> GlobalOpts -> IO () From 293b264c364b396411c961bfea10ab1bb609d642 Mon Sep 17 00:00:00 2001 From: achernyak Date: Mon, 8 Feb 2016 20:21:52 -0600 Subject: [PATCH 03/13] update to path-io --- src/Stack/Init.hs | 3 +-- src/main/Main.hs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index 47136a27a5..1700dee196 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -76,8 +76,7 @@ initProject currDir searchDirs' initOpts mresolver = do then findCabalFiles' currDir else - liftM concat $ - mapM findCabalFiles' searchDirs' + liftM concat $ mapM findCabalFiles' searchDirs' (bundle, dupPkgs) <- cabalPackagesCheck cabalfps noPkgMsg Nothing (r, flags, extraDeps, rbundle) <- getDefaultResolver dest initOpts diff --git a/src/main/Main.hs b/src/main/Main.hs index 5e57129541..835f7e6da3 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -1174,10 +1174,10 @@ withMiniConfigAndLock go inner = initCmd :: InitOpts -> GlobalOpts -> IO () initCmd initOpts go = do let selectedDirs = searchDirs initOpts - selectedDirs' <- mapM (parseRelAsAbsDir . T.unpack) selectedDirs - pwd <- getWorkingDir + selectedDirs' <- mapM (resolveDir' . T.unpack) selectedDirs + workDir <- getCurrentDir withMiniConfigAndLock go $ - initProject pwd selectedDirs' initOpts $ + initProject workDir selectedDirs' initOpts $ globalResolver go -- | Create a project directory structure and initialize the stack config. From 9287fdf9061371773a35c77f22681feea264f59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20D=C3=A9trez?= Date: Tue, 9 Feb 2016 10:24:23 +0100 Subject: [PATCH 04/13] Fix url Page has moved from the wiki to the doc. --- doc/install_and_upgrade.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/install_and_upgrade.md b/doc/install_and_upgrade.md index 108cfdbc1d..840aa91f49 100644 --- a/doc/install_and_upgrade.md +++ b/doc/install_and_upgrade.md @@ -299,8 +299,7 @@ To get tab-completion of commands on bash, just run the following (or add it to eval "$(stack --bash-completion-script stack)" -For more information and other shells, see [the shell auto-completion wiki -page](https://github.com/commercialhaskell/stack/wiki/Shell-autocompletion) +For more information and other shells, see [the shell auto-completion page](shell_autocompletion.html) ## Upgrade From 3e0538aea237fed06446abcaa847f2c321d1245a Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 9 Feb 2016 06:13:02 -0800 Subject: [PATCH 05/13] Allow aeson (>= 0.8.0.2 && < 0.10) || (>= 0.11 && < 0.12) Also bump to lts-5, since lts-4 used aeson-0.10 --- stack.cabal | 2 +- stack.yaml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/stack.cabal b/stack.cabal index c9b7b298e5..48c95f8864 100644 --- a/stack.cabal +++ b/stack.cabal @@ -136,7 +136,7 @@ library Data.Set.Monad Distribution.Version.Extra build-depends: Cabal >= 1.18.1.5 - , aeson >= 0.8.0.2 && < 0.11 + , aeson (>= 0.8.0.2 && < 0.10) || (>= 0.11 && < 0.12) , ansi-terminal >= 0.6.2.3 , async >= 2.0.2 && < 2.2 , attoparsec >= 0.12.1.5 && < 0.14 diff --git a/stack.yaml b/stack.yaml index df7a55812b..6268756340 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-4.0 +resolver: lts-5.0 image: containers: - base: "fpco/ubuntu-with-libgmp:14.04" @@ -9,6 +9,3 @@ nix: enable: false packages: - zlib -extra-deps: -# Should be removed once gitrev is updated in stackage (lts-5) -- gitrev-1.2.0 From 260ea31e787593fe27d002985f45739d8a04a498 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Tue, 9 Feb 2016 17:46:13 +0100 Subject: [PATCH 06/13] Amend changelog regarding #471 --- ChangeLog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index bb0abaf84a..9b9e0acc6f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,12 @@ Other enhancements: work [#1358](https://github.com/commercialhaskell/stack/issues/1358) * Docker: strip suffix from docker --version [#1653](https://github.com/commercialhaskell/stack/issues/1653) +* On each run, stack will test the stack root directory (~/.stack), and the + project and package work directories (.stack-work) for whether they are + owned by the current user and abort if they are not. This precaution can + be disabled with the `--allow-different-user` flag or `allow-different-user` + option in the global config (~/.stack/config.yaml). + [#471](https://github.com/commercialhaskell/stack/issues/471) Bug fixes: From 75059c305e341c871f715798f0c1d8a4bfb90a85 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 9 Feb 2016 13:38:18 -0800 Subject: [PATCH 07/13] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f78691f485..1d0e0f8c51 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,7 +50,9 @@ If you would like to help with documentation, please note that for most cases th The documentation is rendered on [haskellstack.org](http://haskellstack.org) by readthedocs.org using Sphinx and CommonMark. Since links and formatting vary from GFM, please check the documentation there before submitting a PR to fix -those. +those. In particular, links to other documentation files intentionally have +`.html` extensions instead of `.md`, unfortunately (see +[#1506](https://github.com/commercialhaskell/stack/issues/1506) for details). If your changes move or rename files, or subsume Wiki content, please continue to leave a file/page in the old location temporarily, in addition to the new location. This will allow users time to update any shared links to the old location. Please also update any links in other files, or on the Wiki, to point to the new file location. From 86954bcf5db6d8e62a7f9e63f0d9e81e0d25d99e Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 9 Feb 2016 15:46:27 -0800 Subject: [PATCH 08/13] etc/scripts/README.md: update targets --- etc/scripts/README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/etc/scripts/README.md b/etc/scripts/README.md index dd00366faa..c2fc5c0c69 100644 --- a/etc/scripts/README.md +++ b/etc/scripts/README.md @@ -94,11 +94,9 @@ addition, the following options are accepted: * `check`: run pre-release checks. * `build`: build and sign the binary distribution. * `upload`: upload the binary distribution to the Github release. -* `ubuntu-packages`: build Ubuntu .deb packages. -* `ubuntu-upload`: upload Ubuntu .deb packages to private package repository. -* `debian-packages`: build Debian .deb packages. -* `debian-upload`: upload Debian .deb packages to private package repository. -* `centos-packages`: build CentOS .rpm packages. -* `centos-upload`: upload CentOS .rpm packages to private package repository. -* `fedora-packages`: build Fedora .rpm packages. -* `fedora-upload`: upload Fedora .rpm packages to private package repository. +* `build--`: build package for Linux distribution. +* `upload--`: upload package for Linux distribution to private package repository. +* `clean`: delete the build artifacts. + +`` can have one of these values: `ubuntu`, `debian`, `centos`, `fedora`. +`` is the version of the distribution (e.g., `14.04` for Ubuntu). From efcadefa276b6d2174988b2e1a06abd619c14578 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 9 Feb 2016 21:06:04 -0800 Subject: [PATCH 09/13] Use "-RTS" w/ profiling to allow extra args #1772 --- src/Stack/Options.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index dcf94cedef..b433693634 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -109,7 +109,7 @@ buildOptsParser cmd = | otherwise = opts where bopts = boptsBenchmarkOpts opts topts = boptsTestOpts opts - additionalArgs = "+RTS" : catMaybes [trac, prof] + additionalArgs = "+RTS" : catMaybes [trac, prof, Just "-RTS"] trac = if tracing then Just "-xc" else Nothing From 5390df6278d298020e68cc1cb531da13562837c1 Mon Sep 17 00:00:00 2001 From: Martin Kolinek Date: Wed, 10 Feb 2016 14:59:39 +0100 Subject: [PATCH 10/13] Fix withUnpackedTarball7z to find name of srcDir after unpacking #1774 --- src/Stack/Setup.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index c9e6a5e56c..0d5407b6e7 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -1105,12 +1105,12 @@ withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do let tmpName = toFilePathNoTrailingSep (dirname destDir) ++ "-tmp" ensureDir (parent destDir) withTempDir (parent destDir) tmpName $ \tmpDir -> do - absSrcDir <- case msrcDir of - Just srcDir -> return $ tmpDir srcDir - Nothing -> expectSingleUnpackedDir archiveFile tmpDir ignoringAbsence (removeDirRecur destDir) run7z (parent archiveFile) archiveFile run7z tmpDir tarFile + absSrcDir <- case msrcDir of + Just srcDir -> return $ tmpDir srcDir + Nothing -> expectSingleUnpackedDir archiveFile tmpDir removeFile tarFile `catchIO` \e -> $logWarn (T.concat [ "Exception when removing " From 4fc1b8d7ed4feeaf73466005fcd5490eb9130186 Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Thu, 11 Feb 2016 17:23:43 +0600 Subject: [PATCH 11/13] =?UTF-8?q?Add=20upper=20bound=20to=20=E2=80=98path-?= =?UTF-8?q?io=E2=80=99=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There will be breaking changes in version 1.0.0 that affect some functions that Stack uses, so it's better to have this upper bound for now. --- stack.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.cabal b/stack.cabal index 16f79c7054..1c22da20b2 100644 --- a/stack.cabal +++ b/stack.cabal @@ -175,7 +175,7 @@ library , mtl >= 2.1.3.1 , optparse-applicative >= 0.11 && < 0.13 , path >= 0.5.1 - , path-io >= 0.3.1 + , path-io >= 0.3.1 && < 1.0.0 , persistent >= 2.1.2 , persistent-sqlite >= 2.1.4 , persistent-template >= 2.1.1 From ad7ff506eabec17d4609558d011656aedee67347 Mon Sep 17 00:00:00 2001 From: achernyak Date: Thu, 11 Feb 2016 18:08:13 -0600 Subject: [PATCH 12/13] completed change --- src/Stack/Init.hs | 12 ++++-------- src/Stack/Options.hs | 4 ++-- src/main/Main.hs | 6 ++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index 1700dee196..47478d6425 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -35,8 +35,6 @@ import Network.HTTP.Client.Conduit (HasHttpManager) import Path import Path.IO import Stack.BuildPlan -import Stack.Config (getSnapshots, - makeConcreteResolver) import Stack.Config (getSnapshots, makeConcreteResolver) import Stack.Constants @@ -53,16 +51,14 @@ initProject , HasHttpManager env , HasLogLevel env , HasReExec env , HasTerminal env) => Path Abs Dir - -> [Path Abs Dir] -> InitOpts -> Maybe AbstractResolver -> m () -initProject currDir searchDirs' initOpts mresolver = do +initProject currDir initOpts mresolver = do let dest = currDir stackDotYaml - dest' = toFilePath currDir + dirs <- mapM (resolveDir' . T.unpack) (searchDirs initOpts) reldest <- toFilePath `liftM` makeRelativeToCurrentDir dest - exists <- doesFileExist dest when (not (forceOverwrite initOpts) && exists) $ do error ("Stack configuration file " <> reldest <> @@ -72,11 +68,11 @@ initProject currDir searchDirs' initOpts mresolver = do let noPkgMsg = "In order to init, you should have an existing .cabal \ \file. Please try \"stack new\" instead." let findCabalFiles' = findCabalFiles (includeSubDirs initOpts) - cabalfps <- if null searchDirs' + cabalfps <- if null dirs then findCabalFiles' currDir else - liftM concat $ mapM findCabalFiles' searchDirs' + liftM concat $ mapM findCabalFiles' dirs (bundle, dupPkgs) <- cabalPackagesCheck cabalfps noPkgMsg Nothing (r, flags, extraDeps, rbundle) <- getDefaultResolver dest initOpts diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index a58efd6259..5dbf481e76 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -687,8 +687,8 @@ initOptsParser = where searchDirs = many (textArgument - (metavar "SEARCH-DIRECTORIES" <> - help "Directories which are searched for cabal files. If non specified, uses current directory.")) + (metavar "DIRS" <> + help "Directories to include, default is current directory.")) ignoreSubDirs = switch (long "ignore-subdirs" <> help "Do not search for .cabal files in sub directories") overwrite = switch (long "force" <> diff --git a/src/main/Main.hs b/src/main/Main.hs index 835f7e6da3..ee5819e582 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -1173,11 +1173,9 @@ withMiniConfigAndLock go inner = -- | Project initialization initCmd :: InitOpts -> GlobalOpts -> IO () initCmd initOpts go = do - let selectedDirs = searchDirs initOpts - selectedDirs' <- mapM (resolveDir' . T.unpack) selectedDirs workDir <- getCurrentDir withMiniConfigAndLock go $ - initProject workDir selectedDirs' initOpts $ + initProject workDir initOpts $ globalResolver go -- | Create a project directory structure and initialize the stack config. @@ -1185,7 +1183,7 @@ newCmd :: (NewOpts,InitOpts) -> GlobalOpts -> IO () newCmd (newOpts,initOpts) go@GlobalOpts{..} = do withMiniConfigAndLock go $ do dir <- new newOpts - initProject dir [] initOpts globalResolver + initProject dir initOpts globalResolver -- | List the available templates. templatesCmd :: () -> GlobalOpts -> IO () From 1cd7d08246d54519d7cef06e32c270c02402c3b9 Mon Sep 17 00:00:00 2001 From: achernyak Date: Thu, 11 Feb 2016 18:27:22 -0600 Subject: [PATCH 13/13] reset --- CONTRIBUTING.md | 4 +--- ChangeLog.md | 6 ----- doc/install_and_upgrade.md | 3 ++- etc/scripts/README.md | 14 +++++++----- src/Stack/Init.hs | 30 +++++++++++++++---------- src/Stack/Options.hs | 46 +++++++++++++++++++++----------------- src/Stack/Setup.hs | 6 ++--- src/main/Main.hs | 6 +++-- stack.cabal | 4 ++-- 9 files changed, 64 insertions(+), 55 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d0e0f8c51..f78691f485 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,9 +50,7 @@ If you would like to help with documentation, please note that for most cases th The documentation is rendered on [haskellstack.org](http://haskellstack.org) by readthedocs.org using Sphinx and CommonMark. Since links and formatting vary from GFM, please check the documentation there before submitting a PR to fix -those. In particular, links to other documentation files intentionally have -`.html` extensions instead of `.md`, unfortunately (see -[#1506](https://github.com/commercialhaskell/stack/issues/1506) for details). +those. If your changes move or rename files, or subsume Wiki content, please continue to leave a file/page in the old location temporarily, in addition to the new location. This will allow users time to update any shared links to the old location. Please also update any links in other files, or on the Wiki, to point to the new file location. diff --git a/ChangeLog.md b/ChangeLog.md index 9b9e0acc6f..bb0abaf84a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,12 +26,6 @@ Other enhancements: work [#1358](https://github.com/commercialhaskell/stack/issues/1358) * Docker: strip suffix from docker --version [#1653](https://github.com/commercialhaskell/stack/issues/1653) -* On each run, stack will test the stack root directory (~/.stack), and the - project and package work directories (.stack-work) for whether they are - owned by the current user and abort if they are not. This precaution can - be disabled with the `--allow-different-user` flag or `allow-different-user` - option in the global config (~/.stack/config.yaml). - [#471](https://github.com/commercialhaskell/stack/issues/471) Bug fixes: diff --git a/doc/install_and_upgrade.md b/doc/install_and_upgrade.md index 840aa91f49..108cfdbc1d 100644 --- a/doc/install_and_upgrade.md +++ b/doc/install_and_upgrade.md @@ -299,7 +299,8 @@ To get tab-completion of commands on bash, just run the following (or add it to eval "$(stack --bash-completion-script stack)" -For more information and other shells, see [the shell auto-completion page](shell_autocompletion.html) +For more information and other shells, see [the shell auto-completion wiki +page](https://github.com/commercialhaskell/stack/wiki/Shell-autocompletion) ## Upgrade diff --git a/etc/scripts/README.md b/etc/scripts/README.md index c2fc5c0c69..dd00366faa 100644 --- a/etc/scripts/README.md +++ b/etc/scripts/README.md @@ -94,9 +94,11 @@ addition, the following options are accepted: * `check`: run pre-release checks. * `build`: build and sign the binary distribution. * `upload`: upload the binary distribution to the Github release. -* `build--`: build package for Linux distribution. -* `upload--`: upload package for Linux distribution to private package repository. -* `clean`: delete the build artifacts. - -`` can have one of these values: `ubuntu`, `debian`, `centos`, `fedora`. -`` is the version of the distribution (e.g., `14.04` for Ubuntu). +* `ubuntu-packages`: build Ubuntu .deb packages. +* `ubuntu-upload`: upload Ubuntu .deb packages to private package repository. +* `debian-packages`: build Debian .deb packages. +* `debian-upload`: upload Debian .deb packages to private package repository. +* `centos-packages`: build CentOS .rpm packages. +* `centos-upload`: upload CentOS .rpm packages to private package repository. +* `fedora-packages`: build Fedora .rpm packages. +* `fedora-upload`: upload Fedora .rpm packages to private package repository. diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index a5d73e4c8c..47478d6425 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -13,15 +13,15 @@ import Control.Monad import Control.Monad.Catch (MonadMask, throwM) import Control.Monad.IO.Class import Control.Monad.Logger -import Control.Monad.Reader (asks, MonadReader) +import Control.Monad.Reader (MonadReader, asks) import Control.Monad.Trans.Control (MonadBaseControl) import qualified Data.ByteString.Builder as B -import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Char8 as BC +import qualified Data.ByteString.Lazy as L +import qualified Data.Foldable as F import Data.Function (on) import qualified Data.HashMap.Strict as HM import qualified Data.IntMap as IntMap -import qualified Data.Foldable as F import Data.List (intersect, maximumBy) import Data.List.Extra (nubOrd) import Data.Map (Map) @@ -35,13 +35,13 @@ import Network.HTTP.Client.Conduit (HasHttpManager) import Path import Path.IO import Stack.BuildPlan +import Stack.Config (getSnapshots, + makeConcreteResolver) import Stack.Constants import Stack.Solver import Stack.Types -import Stack.Types.Internal ( HasTerminal, HasReExec - , HasLogLevel) -import Stack.Config ( getSnapshots - , makeConcreteResolver) +import Stack.Types.Internal (HasLogLevel, HasReExec, + HasTerminal) import qualified System.FilePath as FP -- | Generate stack.yaml @@ -57,8 +57,8 @@ initProject initProject currDir initOpts mresolver = do let dest = currDir stackDotYaml + dirs <- mapM (resolveDir' . T.unpack) (searchDirs initOpts) reldest <- toFilePath `liftM` makeRelativeToCurrentDir dest - exists <- doesFileExist dest when (not (forceOverwrite initOpts) && exists) $ do error ("Stack configuration file " <> reldest <> @@ -67,8 +67,12 @@ initProject currDir initOpts mresolver = do let noPkgMsg = "In order to init, you should have an existing .cabal \ \file. Please try \"stack new\" instead." - - cabalfps <- findCabalFiles (includeSubDirs initOpts) currDir + let findCabalFiles' = findCabalFiles (includeSubDirs initOpts) + cabalfps <- if null dirs + then + findCabalFiles' currDir + else + liftM concat $ mapM findCabalFiles' dirs (bundle, dupPkgs) <- cabalPackagesCheck cabalfps noPkgMsg Nothing (r, flags, extraDeps, rbundle) <- getDefaultResolver dest initOpts @@ -435,12 +439,14 @@ getRecommendedSnapshots snapshots = do ] data InitOpts = InitOpts - { useSolver :: Bool + { useSolver :: Bool -- ^ Use solver to determine required external dependencies - , omitPackages :: Bool + , omitPackages :: Bool -- ^ Exclude conflicting or incompatible user packages , forceOverwrite :: Bool -- ^ Overwrite existing stack.yaml , includeSubDirs :: Bool -- ^ If True, include all .cabal files found in any sub directories + , searchDirs :: ![T.Text] + -- ^ List of sub directories to search for .cabal files } diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index b433693634..5dbf481e76 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE OverloadedStrings,RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} module Stack.Options (BuildCommand(..) @@ -26,32 +27,32 @@ module Stack.Options ,globalOptsFromMonoid ) where -import Control.Monad.Logger (LogLevel(..)) -import Data.Char (isSpace, toLower) -import Data.List (intercalate) -import Data.List.Split (splitOn) -import qualified Data.Map as Map -import Data.Map.Strict (Map) -import qualified Data.Map.Strict as M +import Control.Monad.Logger (LogLevel (..)) +import Data.Char (isSpace, toLower) +import Data.List (intercalate) +import Data.List.Split (splitOn) +import qualified Data.Map as Map +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as M import Data.Maybe import Data.Monoid -import qualified Data.Set as Set -import qualified Data.Text as T -import Data.Text.Read (decimal) -import Distribution.Version (anyVersion) +import qualified Data.Set as Set +import qualified Data.Text as T +import Data.Text.Read (decimal) +import Distribution.Version (anyVersion) import Options.Applicative import Options.Applicative.Args import Options.Applicative.Builder.Extra -import Options.Applicative.Types (fromM, oneM, readerAsk) -import Stack.Clean (CleanOpts(..)) -import Stack.Config (packagesParser) +import Options.Applicative.Types (fromM, oneM, readerAsk) +import Stack.Clean (CleanOpts (..)) +import Stack.Config (packagesParser) import Stack.ConfigCmd -import Stack.Constants (stackProgName) -import Stack.Coverage (HpcReportOpts(..)) +import Stack.Constants (stackProgName) +import Stack.Coverage (HpcReportOpts (..)) import Stack.Docker -import qualified Stack.Docker as Docker +import qualified Stack.Docker as Docker import Stack.Dot -import Stack.Ghci (GhciOpts(..)) +import Stack.Ghci (GhciOpts (..)) import Stack.Init import Stack.New import Stack.Nix @@ -109,7 +110,7 @@ buildOptsParser cmd = | otherwise = opts where bopts = boptsBenchmarkOpts opts topts = boptsTestOpts opts - additionalArgs = "+RTS" : catMaybes [trac, prof, Just "-RTS"] + additionalArgs = "+RTS" : catMaybes [trac, prof] trac = if tracing then Just "-xc" else Nothing @@ -682,7 +683,12 @@ initOptsParser :: Parser InitOpts initOptsParser = InitOpts <$> solver <*> omitPackages <*> overwrite <*> fmap not ignoreSubDirs + <*> searchDirs where + searchDirs = + many (textArgument + (metavar "DIRS" <> + help "Directories to include, default is current directory.")) ignoreSubDirs = switch (long "ignore-subdirs" <> help "Do not search for .cabal files in sub directories") overwrite = switch (long "force" <> diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index 0d5407b6e7..c9e6a5e56c 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -1105,12 +1105,12 @@ withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do let tmpName = toFilePathNoTrailingSep (dirname destDir) ++ "-tmp" ensureDir (parent destDir) withTempDir (parent destDir) tmpName $ \tmpDir -> do - ignoringAbsence (removeDirRecur destDir) - run7z (parent archiveFile) archiveFile - run7z tmpDir tarFile absSrcDir <- case msrcDir of Just srcDir -> return $ tmpDir srcDir Nothing -> expectSingleUnpackedDir archiveFile tmpDir + ignoringAbsence (removeDirRecur destDir) + run7z (parent archiveFile) archiveFile + run7z tmpDir tarFile removeFile tarFile `catchIO` \e -> $logWarn (T.concat [ "Exception when removing " diff --git a/src/main/Main.hs b/src/main/Main.hs index 27e745b531..ee5819e582 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -1173,8 +1173,10 @@ withMiniConfigAndLock go inner = -- | Project initialization initCmd :: InitOpts -> GlobalOpts -> IO () initCmd initOpts go = do - pwd <- getCurrentDir - withMiniConfigAndLock go (initProject pwd initOpts (globalResolver go)) + workDir <- getCurrentDir + withMiniConfigAndLock go $ + initProject workDir initOpts $ + globalResolver go -- | Create a project directory structure and initialize the stack config. newCmd :: (NewOpts,InitOpts) -> GlobalOpts -> IO () diff --git a/stack.cabal b/stack.cabal index 1c22da20b2..3649b33c7b 100644 --- a/stack.cabal +++ b/stack.cabal @@ -135,7 +135,7 @@ library System.Process.Read System.Process.Run build-depends: Cabal >= 1.18.1.5 - , aeson (>= 0.8.0.2 && < 0.10) || (>= 0.11 && < 0.12) + , aeson >= 0.8.0.2 && < 0.11 , ansi-terminal >= 0.6.2.3 , async >= 2.0.2 && < 2.2 , attoparsec >= 0.12.1.5 && < 0.14 @@ -175,7 +175,7 @@ library , mtl >= 2.1.3.1 , optparse-applicative >= 0.11 && < 0.13 , path >= 0.5.1 - , path-io >= 0.3.1 && < 1.0.0 + , path-io >= 0.3.1 , persistent >= 2.1.2 , persistent-sqlite >= 2.1.4 , persistent-template >= 2.1.1