From e43ec4dc4c0f7126b58c3bdf5b583781fcac1ac1 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 18 Jun 2018 16:26:36 +0300 Subject: [PATCH 01/22] Use a fixed temp dir on AppVeyor This is a workaround for haskell/cabal#5386 and #3944 --- doc/appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/appveyor.yml b/doc/appveyor.yml index dcb68600cb..45695b43bd 100644 --- a/doc/appveyor.yml +++ b/doc/appveyor.yml @@ -12,6 +12,10 @@ environment: global: STACK_ROOT: "c:\\sr" + # Override the temp directory to avoid sed escaping issues + # See https://github.com/haskell/cabal/issues/5386 + TMP: "c:\\tmp" + matrix: - ARGS: "" #- ARGS: "--resolver lts-2" From b05eda92e820397379036d8f1c0d12134fe67062 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Sun, 24 Jun 2018 09:30:50 -0700 Subject: [PATCH 02/22] mkdocs.yml: fix 'edit on github' link (fixes #4098) --- mkdocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 6555a06639..b7a26c771d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,8 @@ site_name: The Haskell Tool Stack site_description: The Haskell Tool Stack site_author: Stack contributors -repo_url: https://github.com/commercialhaskell/stack/tree/master/doc +repo_url: https://github.com/commercialhaskell/stack/ +edit_uri: edit/master/doc/ copyright: Copyright (c) 2015-2018, Stack contributors docs_dir: doc site_dir: _site From 6a591d86859029a553f6ab415a89f4f544576230 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Sun, 24 Jun 2018 16:19:57 -0700 Subject: [PATCH 03/22] mkdocs.yml: edit link edits stable branch --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index b7a26c771d..a9782602e5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -2,7 +2,7 @@ site_name: The Haskell Tool Stack site_description: The Haskell Tool Stack site_author: Stack contributors repo_url: https://github.com/commercialhaskell/stack/ -edit_uri: edit/master/doc/ +edit_uri: edit/stable/doc/ copyright: Copyright (c) 2015-2018, Stack contributors docs_dir: doc site_dir: _site From 14f91a0859a94c41a46fc4141f8f8f2bbebf19f9 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 28 Jun 2018 12:16:06 +0300 Subject: [PATCH 04/22] Not pedantic on Windows --- doc/appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/appveyor.yml b/doc/appveyor.yml index 45695b43bd..945cded89f 100644 --- a/doc/appveyor.yml +++ b/doc/appveyor.yml @@ -33,4 +33,4 @@ test_script: # The ugly echo "" hack is to avoid complaints about 0 being an invalid file # descriptor -- echo "" | stack %ARGS% --no-terminal test --pedantic +- echo "" | stack %ARGS% --no-terminal test From cdb0a948a910c8d200cbb4c4aaba1a60837fbc43 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 28 Jun 2018 12:16:14 +0300 Subject: [PATCH 05/22] Don't use solver on Travis --- doc/travis-complex.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/travis-complex.yml b/doc/travis-complex.yml index e278d06a3c..46bf888cc5 100644 --- a/doc/travis-complex.yml +++ b/doc/travis-complex.yml @@ -176,9 +176,14 @@ install: case "$BUILD" in stack) # Add in extra-deps for older snapshots, as necessary - stack --no-terminal --install-ghc $ARGS test --bench --dry-run || ( \ - stack --no-terminal $ARGS build cabal-install && \ - stack --no-terminal $ARGS solver --update-config) + # + # This is disabled by default, as relying on the solver like this can + # make builds unreliable. Instead, if you have this situation, it's + # recommended that you maintain multiple stack-lts-X.yaml files. + + #stack --no-terminal --install-ghc $ARGS test --bench --dry-run || ( \ + # stack --no-terminal $ARGS build cabal-install && \ + # stack --no-terminal $ARGS solver --update-config) # Build the dependencies stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies From c7d2ef6f1e21708b29de651c993e78cbbcdc1770 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 9 Jul 2018 18:38:15 +0300 Subject: [PATCH 06/22] Add LTS-12 to CI configs --- doc/appveyor.yml | 1 + doc/travis-complex.yml | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/doc/appveyor.yml b/doc/appveyor.yml index 945cded89f..34c446de06 100644 --- a/doc/appveyor.yml +++ b/doc/appveyor.yml @@ -24,6 +24,7 @@ environment: #- ARGS: "--resolver lts-7" - ARGS: "--resolver lts-9" - ARGS: "--resolver lts-11" + - ARGS: "--resolver lts-12" #- ARGS: "--resolver nightly" test_script: diff --git a/doc/travis-complex.yml b/doc/travis-complex.yml index 46bf888cc5..c162d149de 100644 --- a/doc/travis-complex.yml +++ b/doc/travis-complex.yml @@ -100,6 +100,10 @@ matrix: compiler: ": #stack 8.2.2" addons: {apt: {packages: [libgmp-dev]}} + - env: BUILD=stack ARGS="--resolver lts-12" + compiler: ": #stack 8.4.3" + addons: {apt: {packages: [libgmp-dev]}} + # Nightly builds are allowed to fail - env: BUILD=stack ARGS="--resolver nightly" compiler: ": #stack nightly" @@ -135,6 +139,10 @@ matrix: compiler: ": #stack 8.2.2 osx" os: osx + - env: BUILD=stack ARGS="--resolver lts-12" + compiler: ": #stack 8.4.3 osx" + os: osx + - env: BUILD=stack ARGS="--resolver nightly" compiler: ": #stack nightly osx" os: osx From 2730ce95789d50d3af19594a4a287b4d8ab20e33 Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Fri, 13 Jul 2018 13:07:07 -0500 Subject: [PATCH 07/22] Warning about GHCJS use when constructing a build plan --- src/Stack/Init.hs | 1 - src/Stack/Setup/Installed.hs | 12 ++++++++++++ src/main/Main.hs | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index 4413e01afa..df066a9123 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -262,7 +262,6 @@ renderStackYaml p ignoredPackages dupPackages = , "resolver: lts-3.5" , "resolver: nightly-2015-09-21" , "resolver: ghc-7.10.2" - , "resolver: ghcjs-0.1.0_ghc-7.10.2" , "" , "The location of a snapshot can be provided as a file or url. Stack assumes" , "a snapshot provided as a file might change, whereas a url resource does not." diff --git a/src/Stack/Setup/Installed.hs b/src/Stack/Setup/Installed.hs index c8ac8d24b9..e7ceb2995b 100644 --- a/src/Stack/Setup/Installed.hs +++ b/src/Stack/Setup/Installed.hs @@ -88,6 +88,17 @@ listInstalled programsPath = do x <- T.stripSuffix ".installed" $ T.pack $ toFilePath $ filename fp parseToolText x +-- | See https://github.com/commercialhaskell/stack/issues/4086. +warnAboutGHCJS :: HasLogFunc env => RIO env () +warnAboutGHCJS = + logWarn $ "Building a GHCJS project. " <> fromString ghcjsWarning + +ghcjsWarning :: String +ghcjsWarning = unwords + [ "Note that GHCJS support in Stack is DEPRECATED and it will be removed " + , "in a future release of Stack." + ] + getCompilerVersion :: (HasProcessContext env, HasLogFunc env) => WhichCompiler @@ -102,6 +113,7 @@ getCompilerVersion wc = logDebug $ "GHC version is: " <> display x return x Ghcjs -> do + warnAboutGHCJS logDebug "Asking GHCJS for its version" -- Output looks like -- diff --git a/src/main/Main.hs b/src/main/Main.hs index 3532d784e9..c043494039 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -830,8 +830,8 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = (ExecCmd cmd, args) -> return (cmd, args) (ExecRun, args) -> getRunCmd args (ExecGhc, args) -> getGhcCmd "" eoPackages args - -- NOTE: this won't currently work for GHCJS, because it doesn't have - -- a runghcjs binary. It probably will someday, though. + -- NOTE: This doesn't work for GHCJS, because it doesn't have + -- a runghcjs binary. (ExecRunGhc, args) -> getGhcCmd "run" eoPackages args munlockFile lk -- Unlock before transferring control away. From ddef05c8b24669596250f45020f22e453106865a Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Mon, 16 Jul 2018 10:11:02 -0500 Subject: [PATCH 08/22] Changelog for GHCJS deprecation --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 33d7688cd1..e7c399bccd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,8 @@ Release notes: Major changes: +* `GHCJS` support is being deprecated after the next major Stack release. At time of writing the upcoming release is 1.8. A warning notifying the user of the deprecation will be incorporated into 1.8. + Behavior changes: * `ghc-options` from `stack.yaml` are now appended to `ghc-options` from From 7372dd96145d3b4c191256fdc02fca4dc163f06f Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Mon, 16 Jul 2018 10:13:59 -0500 Subject: [PATCH 09/22] Expanded .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 04ac0d0465..9e82459c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ tags /.git/ /stack.cabal /etc/scripts/stack-scripts.cabal +.hspec-failures +better-cache/ +subs/ From 729a052cede11855644bf00c4b7661a89148bdc7 Mon Sep 17 00:00:00 2001 From: Matchwood Date: Tue, 17 Jul 2018 11:17:59 +0100 Subject: [PATCH 10/22] Change ghcjs warning from deprecated to experimental and add subsystem maintainer --- ChangeLog.md | 2 +- README.md | 4 ++++ src/Stack/Setup/Installed.hs | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b8ffc85d9f..422a36697d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,7 +7,7 @@ Release notes: Major changes: -* `GHCJS` support is being deprecated after the next major Stack release. At time of writing the upcoming release is 1.8. A warning notifying the user of the deprecation will be incorporated into 1.8. +* `GHCJS` support is being downgraded to 'experimental'. At time of writing the upcoming release is 1.8. A warning notifying the user of the experimental status of `GHCJS` will be incorporated into 1.8. Behavior changes: diff --git a/README.md b/README.md index 7c2f279c8c..71d585cc93 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,7 @@ Stack is a cross-platform program for developing Haskell projects. It is intende See [haskellstack.org](http://haskellstack.org) or the [doc](./doc) directory for more information. + +### Subsystem maintainers + +* GHJCS - [Matchwood](https://github.com/matchwood) \ No newline at end of file diff --git a/src/Stack/Setup/Installed.hs b/src/Stack/Setup/Installed.hs index e7ceb2995b..794f657db0 100644 --- a/src/Stack/Setup/Installed.hs +++ b/src/Stack/Setup/Installed.hs @@ -95,8 +95,7 @@ warnAboutGHCJS = ghcjsWarning :: String ghcjsWarning = unwords - [ "Note that GHCJS support in Stack is DEPRECATED and it will be removed " - , "in a future release of Stack." + [ "Note that GHCJS support in Stack is EXPERIMENTAL" ] getCompilerVersion From cbd391a724ac410333799dc3b37a92f10abe87ed Mon Sep 17 00:00:00 2001 From: Matchwood Date: Tue, 17 Jul 2018 11:41:03 +0100 Subject: [PATCH 11/22] Change docs to reflect experimental nature of ghcjs support and add note on matchwood ghcjs versions for lts 8 and 9 --- doc/ghcjs.md | 15 +++++++++++---- mkdocs.yml | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/ghcjs.md b/doc/ghcjs.md index 42ea64c090..ccbc542faa 100644 --- a/doc/ghcjs.md +++ b/doc/ghcjs.md @@ -1,8 +1,8 @@
-# GHCJS +# GHCJS (experimental) -To use GHCJS with stack, place a GHCJS version in the [`compiler`](yaml_configuration.md#compiler) field of `stack.yaml`. After this, all stack commands should work with GHCJS! In particular: +To use GHCJS with stack, place a GHCJS version in the [`compiler`](yaml_configuration.md#compiler) field of `stack.yaml`. After this, some stack commands should work with GHCJS. In particular: * `stack setup` will install GHCJS from source and boot it, which takes a long time. @@ -21,7 +21,13 @@ then you may need to install a different version of `node`. See ## Example Configurations -### Recent versions of GHCJS, repacked for stack +### GHCJS repacked for snapsnots lts-8 and lts-9 + +Please see the [ghcjs-stack-dist repository](https://github.com/matchwood/ghcjs-stack-dist) for `lts-8` and `lts-9` configurations and refer to the [README](https://github.com/matchwood/ghcjs-stack-dist/blob/master/README.md) for common issues. + +Support for `> lts-9` snapshots (`GHC 8.2` and above) is currently [work in progress](https://github.com/matchwood/ghcjs-stack-dist/issues/10). + +### GHCJS repacked for snapsnots < lts-8 These versions of GHCJS were created by [Marcin Tolysz](https://github.com/tolysz), and were particularly crafted to @@ -55,7 +61,7 @@ setup-info: url: http://ghcjs.tolysz.org/ghc-8.0-2017-02-05-lts-7.19-9007019.tar.gz sha1: d2cfc25f9cda32a25a87d9af68891b2186ee52f9 ``` -The later can be generated via: https://github.com/tolysz/prepare-ghcjs +The latter can be generated via: https://github.com/tolysz/prepare-ghcjs the former is a bit more manual. Those bundles are only tested against the latest `node-7.4.0`. In order to correctly boot and use ghcjs, one might need to install `alex` `happy` `hscolour` `hsc2hs` with the normal ghc. @@ -64,6 +70,7 @@ Older resolvers: |resolver|ghcjs|url|sha1| |---|---|---|---| +| lts-7.19 |0.2.1| http://ghcjs.tolysz.org/ghc-8.0-2017-02-05-lts-7.19-9007019.tar.gz | d2cfc25f9cda32a25a87d9af68891b2186ee52f9 | | lts-7.15 |0.2.1| http://ghcjs.tolysz.org/ghc-8.0-2017-01-11-lts-7.15-9007015.tar.gz | 30d34e9d704bdb799066387dfa1ba98b8884d932 | | lts-7.14 |0.2.1| http://ghcjs.tolysz.org/ghc-8.0-2016-12-25-lts-7.14-9007014.tar.gz | 530c4ee5e19e2874e128431c7ad421e336df0303 | | lts-7.13 |0.2.1| http://ghcjs.tolysz.org/ghc-8.0-2016-12-18-lts-7.13-9007013.tar.gz | 0d2ebe0931b29adca7cb9d9b9f77d60095bfb864 | diff --git a/mkdocs.yml b/mkdocs.yml index 6555a06639..fe9ae1e3f3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -23,7 +23,7 @@ pages: - Build command: build_command.md - Dependency visualization: dependency_visualization.md - Docker integration: docker_integration.md - - GHCJS: ghcjs.md + - GHCJS (experimental): ghcjs.md - Nix integration: nix_integration.md - Non-standard project initialization: nonstandard_project_init.md - Shell auto-completion: shell_autocompletion.md From 92367bc65a636986e44a8266af221eeafbc6f896 Mon Sep 17 00:00:00 2001 From: Matchwood Date: Tue, 17 Jul 2018 11:59:46 +0100 Subject: [PATCH 12/22] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71d585cc93..0fca83bb90 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ information. ### Subsystem maintainers -* GHJCS - [Matchwood](https://github.com/matchwood) \ No newline at end of file +* GHCJS - [Matchwood](https://github.com/matchwood) \ No newline at end of file From d9d39592b5600978b00b4c648cd37f7f6edfdc5d Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 18 Jul 2018 07:12:50 +0300 Subject: [PATCH 13/22] Pass --quickjump to Haddock for GHC 8.4 and later --- ChangeLog.md | 1 + src/Stack/Build/Execute.hs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 422a36697d..3ec636719c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -77,6 +77,7 @@ Other enhancements: * `stack ghci` now asks which main target to load before doing the build, rather than after * Bump to hpack 0.29.0 +* With GHC 8.4 and later, Haddock is given the `--quickjump` flag. Bug fixes: diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index f90a1fa79d..e5d128650f 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1496,12 +1496,22 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} installedMap ("Warning: haddock not generating hyperlinked sources because 'HsColour' not\n" <> "found on PATH (use 'stack install hscolour' to install).") return ["--hyperlink-source" | hscolourExists] + + -- For GHC 8.4 and later, provide the --quickjump option. + actualCompiler <- view actualCompilerVersionL + let quickjump = + case actualCompiler of + GhcVersion ghcVer + | ghcVer >= $(mkVersion "8.4") -> ["--haddock-option=--quickjump"] + _ -> [] + cabal KeepTHLoading $ concat [ ["haddock", "--html", "--hoogle", "--html-location=../$pkg-$version/"] , sourceFlag , ["--internal" | boptsHaddockInternal eeBuildOpts] , [ "--haddock-option=" <> opt | opt <- hoAdditionalArgs (boptsHaddockOpts eeBuildOpts) ] + , quickjump ] let hasLibrary = From 0503c5b2a99a186e6aaed2741e48120bbd6e6b04 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Thu, 19 Jul 2018 21:10:55 +1000 Subject: [PATCH 14/22] Fix behavior of --no-signature to turn signing off The --no-signature switch should enable signing rather than disable it; consequently, the default for 'stack upload' should be to sign the package. --- src/Stack/Options/SDistParser.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stack/Options/SDistParser.hs b/src/Stack/Options/SDistParser.hs index d9a1c30829..0839d5362a 100644 --- a/src/Stack/Options/SDistParser.hs +++ b/src/Stack/Options/SDistParser.hs @@ -15,7 +15,7 @@ sdistOptsParser signDefault = SDistOpts <$> optional pvpBoundsOption <*> ignoreCheckSwitch <*> (if signDefault - then switch (long "no-signature" <> help "Do not sign & upload signatures") + then not <$> switch (long "no-signature" <> help "Do not sign & upload signatures") else switch (long "sign" <> help "Sign & upload signatures")) <*> strOption (long "sig-server" <> metavar "URL" <> showDefault <> From a4f268ca2d88ec45098ecd9530a56930fb609c68 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Thu, 19 Jul 2018 21:19:12 +1000 Subject: [PATCH 15/22] Update changelog --- ChangeLog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 3ec636719c..e51f477662 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -40,6 +40,9 @@ Behavior changes: * Mustache templating is not applied to large files (over 50kb) to avoid performance degredation. See: [#4133](https://github.com/commercialhaskell/stack/issues/4133). +* `stack upload` signs the package by default, as documented. `--no-signature` + turns the signing off. + [#3739](https://github.com/commercialhaskell/stack/issues/3739) Other enhancements: @@ -129,6 +132,9 @@ Bug fixes: #3942). * Fix invalid "While building Setup.hs" when Cabal calls fail. See: [#3934](https://github.com/commercialhaskell/stack/issues/3934) +* `stack upload` signs the package by default, as documented. `--no-signature` + turns the signing off. + [#3739](https://github.com/commercialhaskell/stack/issues/3739) ## v1.7.1 From 332abaf69613ab929b94b70a2da8915f63792ae0 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Sat, 21 Jul 2018 10:15:11 +1000 Subject: [PATCH 16/22] Add an option to set Hackage URL for uploading --- doc/yaml_configuration.md | 11 +++++++++++ src/Stack/Config.hs | 1 + src/Stack/Types/Config.hs | 8 ++++++++ src/Stack/Upload.hs | 22 ++++++++++++++-------- src/main/Main.hs | 7 ++++--- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/doc/yaml_configuration.md b/doc/yaml_configuration.md index a34c871e80..89d0b6b24c 100644 --- a/doc/yaml_configuration.md +++ b/doc/yaml_configuration.md @@ -878,6 +878,17 @@ save-hackage-creds: true Since 1.5.0 +### hackage-base-url + +Sets the address of the Hackage server to upload the package to. Default is +`https://hackage.haskell.org/`. + +```yaml +hackage-base-url: https://hackage.example.com/ +``` + +Since 1.8.0 + ### ignore-revision-mismatch Cabal files in packages can be specified via exact revisions to deal diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs index a142b2cb5e..0ed4b7a7af 100644 --- a/src/Stack/Config.hs +++ b/src/Stack/Config.hs @@ -373,6 +373,7 @@ configFromConfigMonoid configDefaultTemplate = getFirst configMonoidDefaultTemplate configDumpLogs = fromFirst DumpWarningLogs configMonoidDumpLogs configSaveHackageCreds = fromFirst True configMonoidSaveHackageCreds + configHackageBaseUrl = fromFirst "https://hackage.haskell.org/" configMonoidHackageBaseUrl clIgnoreRevisionMismatch = fromFirst False configMonoidIgnoreRevisionMismatch configAllowDifferentUser <- diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index b982dddb79..1163245a54 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -338,6 +338,8 @@ data Config = -- command disallows this. ,configSaveHackageCreds :: !Bool -- ^ Should we save Hackage credentials to a file? + ,configHackageBaseUrl :: !Text + -- ^ Hackage base URL used when uploading packages ,configRunner :: !Runner ,configCabalLoader :: !CabalLoader } @@ -778,6 +780,8 @@ data ConfigMonoid = -- ^ See 'configDumpLogs' , configMonoidSaveHackageCreds :: !(First Bool) -- ^ See 'configSaveHackageCreds' + , configMonoidHackageBaseUrl :: !(First Text) + -- ^ See 'configHackageBaseUrl' , configMonoidIgnoreRevisionMismatch :: !(First Bool) -- ^ See 'configIgnoreRevisionMismatch' } @@ -875,6 +879,7 @@ parseConfigMonoidObject rootDir obj = do configMonoidAllowDifferentUser <- First <$> obj ..:? configMonoidAllowDifferentUserName configMonoidDumpLogs <- First <$> obj ..:? configMonoidDumpLogsName configMonoidSaveHackageCreds <- First <$> obj ..:? configMonoidSaveHackageCredsName + configMonoidHackageBaseUrl <- First <$> obj ..:? configMonoidHackageBaseUrlName configMonoidIgnoreRevisionMismatch <- First <$> obj ..:? configMonoidIgnoreRevisionMismatchName return ConfigMonoid {..} @@ -1015,6 +1020,9 @@ configMonoidDumpLogsName = "dump-logs" configMonoidSaveHackageCredsName :: Text configMonoidSaveHackageCredsName = "save-hackage-creds" +configMonoidHackageBaseUrlName :: Text +configMonoidHackageBaseUrlName = "hackage-base-url" + configMonoidIgnoreRevisionMismatchName :: Text configMonoidIgnoreRevisionMismatchName = "ignore-revision-mismatch" diff --git a/src/Stack/Upload.hs b/src/Stack/Upload.hs index d791d281a9..d942808f07 100644 --- a/src/Stack/Upload.hs +++ b/src/Stack/Upload.hs @@ -126,13 +126,14 @@ applyCreds creds req0 = do -- sending a file like 'upload', this sends a lazy bytestring. -- -- Since 0.1.2.1 -uploadBytes :: HackageCreds +uploadBytes :: String -- ^ Hackage base URL + -> HackageCreds -> String -- ^ tar file name -> L.ByteString -- ^ tar file contents -> IO () -uploadBytes creds tarName bytes = do +uploadBytes baseUrl creds tarName bytes = do let req1 = setRequestHeader "Accept" ["text/plain"] - "https://hackage.haskell.org/packages/" + (fromString $ baseUrl <> "packages/") formData = [partFileRequestBody "package" tarName (RequestBodyLBS bytes)] req2 <- formDataBody formData req1 req3 <- applyCreds creds req2 @@ -166,16 +167,21 @@ printBody res = runConduit $ getResponseBody res .| CB.sinkHandle stdout -- | Upload a single tarball with the given @Uploader@. -- -- Since 0.1.0.0 -upload :: HackageCreds -> FilePath -> IO () -upload creds fp = uploadBytes creds (takeFileName fp) =<< L.readFile fp +upload :: String -- ^ Hackage base URL + -> HackageCreds + -> FilePath + -> IO () +upload baseUrl creds fp = uploadBytes baseUrl creds (takeFileName fp) =<< L.readFile fp -uploadRevision :: HackageCreds +uploadRevision :: String -- ^ Hackage base URL + -> HackageCreds -> PackageIdentifier -> L.ByteString -> IO () -uploadRevision creds ident cabalFile = do +uploadRevision baseUrl creds ident cabalFile = do req0 <- parseRequest $ concat - [ "https://hackage.haskell.org/package/" + [ baseUrl + , "package/" , packageIdentifierString ident , "/" , packageNameString $ packageIdentifierName ident diff --git a/src/main/Main.hs b/src/main/Main.hs index c043494039..977139d172 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -717,6 +717,7 @@ uploadCmd sdistOpts go = do ] liftIO exitFailure config <- view configL + let hackageUrl = T.unpack $ configHackageBaseUrl config getCreds <- liftIO (runOnce (Upload.loadCreds config)) mapM_ (resolveFile' >=> checkSDistTarball sdistOpts) files forM_ @@ -725,7 +726,7 @@ uploadCmd sdistOpts go = do do tarFile <- resolveFile' file liftIO $ do creds <- getCreds - Upload.upload creds (toFilePath tarFile) + Upload.upload hackageUrl creds (toFilePath tarFile) when (sdoptsSign sdistOpts) (void $ @@ -739,8 +740,8 @@ uploadCmd sdistOpts go = do checkSDistTarball' sdistOpts tarName tarBytes liftIO $ do creds <- getCreds - Upload.uploadBytes creds tarName tarBytes - forM_ mcabalRevision $ uncurry $ Upload.uploadRevision creds + Upload.uploadBytes hackageUrl creds tarName tarBytes + forM_ mcabalRevision $ uncurry $ Upload.uploadRevision hackageUrl creds tarPath <- parseRelFile tarName when (sdoptsSign sdistOpts) From c62071170cb982bb1fb3fbd5e88cdd1516f1acdc Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Sat, 21 Jul 2018 20:14:14 +1000 Subject: [PATCH 17/22] Integration test for uploading --- test/integration/tests/upload/Main.hs | 34 +++++++++++++++++++ .../tests/upload/files/FakeHackage.hs | 8 +++++ .../tests/upload/files/FakeHackageStart.hs | 2 ++ test/integration/tests/upload/files/Foo.hs | 1 + test/integration/tests/upload/files/LICENSE | 1 + .../integration/tests/upload/files/stack.yaml | 4 +++ .../tests/upload/files/uploadtest.cabal | 14 ++++++++ 7 files changed, 64 insertions(+) create mode 100644 test/integration/tests/upload/Main.hs create mode 100644 test/integration/tests/upload/files/FakeHackage.hs create mode 100644 test/integration/tests/upload/files/FakeHackageStart.hs create mode 100644 test/integration/tests/upload/files/Foo.hs create mode 100644 test/integration/tests/upload/files/LICENSE create mode 100644 test/integration/tests/upload/files/stack.yaml create mode 100644 test/integration/tests/upload/files/uploadtest.cabal diff --git a/test/integration/tests/upload/Main.hs b/test/integration/tests/upload/Main.hs new file mode 100644 index 0000000000..f8dc66d824 --- /dev/null +++ b/test/integration/tests/upload/Main.hs @@ -0,0 +1,34 @@ +import Control.Concurrent + +import StackTest + +import System.Directory (createDirectoryIfMissing) +import System.Environment (getEnv, setEnv) +import System.FilePath (()) +import System.Process + +main :: IO () +main = + withFakeHackage $ do + stackRoot <- getEnv "STACK_ROOT" + -- Ensure there are credentials available for uploading + createDirectoryIfMissing True (stackRoot "upload") + writeFile + (stackRoot "upload" "credentials.json") + "{\"username\":\"fake\",\"password\":\"fake\"}" + -- Upload + stack ["upload", "--no-signature", "."] + +-- | Start a fake Hackage server to test the upload +withFakeHackage :: IO a -> IO a +withFakeHackage act = do + stackEnv <- stackExe + -- Build the dependencies for the fake server + stack $ withNetworkArgs ++ ["FakeHackageStart.hs"] + -- Start the fake server + withCreateProcess (proc stackEnv $ withNetworkArgs ++ ["FakeHackage.hs"]) $ \_ _ _ _ -> do + -- Wait for the fake server to start accepting requests + threadDelay 2000000 + act + where + withNetworkArgs = ["runghc", "--package", "network-simple"] diff --git a/test/integration/tests/upload/files/FakeHackage.hs b/test/integration/tests/upload/files/FakeHackage.hs new file mode 100644 index 0000000000..8b2ae4092f --- /dev/null +++ b/test/integration/tests/upload/files/FakeHackage.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Network.Simple.TCP + +-- | Fake server that always responds with HTTP OK +main = + serve (Host "127.0.0.1") "12415" $ \(socket, _) -> + send socket "HTTP/1.1 200 OK\r\n\r\n" diff --git a/test/integration/tests/upload/files/FakeHackageStart.hs b/test/integration/tests/upload/files/FakeHackageStart.hs new file mode 100644 index 0000000000..53d5853101 --- /dev/null +++ b/test/integration/tests/upload/files/FakeHackageStart.hs @@ -0,0 +1,2 @@ +-- | Module to force downloading all the dependencies to avoid race conditions +main = pure () diff --git a/test/integration/tests/upload/files/Foo.hs b/test/integration/tests/upload/files/Foo.hs new file mode 100644 index 0000000000..efbf93bbde --- /dev/null +++ b/test/integration/tests/upload/files/Foo.hs @@ -0,0 +1 @@ +module Foo where diff --git a/test/integration/tests/upload/files/LICENSE b/test/integration/tests/upload/files/LICENSE new file mode 100644 index 0000000000..11c892df1d --- /dev/null +++ b/test/integration/tests/upload/files/LICENSE @@ -0,0 +1 @@ +Upload test license diff --git a/test/integration/tests/upload/files/stack.yaml b/test/integration/tests/upload/files/stack.yaml new file mode 100644 index 0000000000..4778629d76 --- /dev/null +++ b/test/integration/tests/upload/files/stack.yaml @@ -0,0 +1,4 @@ +resolver: lts-11.6 +packages: + - . +hackage-base-url: http://localhost:12415/ diff --git a/test/integration/tests/upload/files/uploadtest.cabal b/test/integration/tests/upload/files/uploadtest.cabal new file mode 100644 index 0000000000..d815cddd6c --- /dev/null +++ b/test/integration/tests/upload/files/uploadtest.cabal @@ -0,0 +1,14 @@ +build-type: Simple +name: uploadtest +version: 0.0.0 +category: test +maintainer: uploadtest@example.com +cabal-version: 1.20 +synopsis: Upload test +description: Upload test description +license: BSD3 +license-file: LICENSE +library + build-depends: base >= 4.7 && < 5 + exposed-modules: Foo + default-language: Haskell2010 From 34b0fc7bd617f672bcba64f43cb1e6610b93eb31 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Sat, 21 Jul 2018 20:30:53 +1000 Subject: [PATCH 18/22] Test signing failure with broken GPG --- test/integration/tests/upload/Main.hs | 15 +++++++++++++-- .../tests/upload/files/gpg-disabled/gpg | 4 ++++ .../tests/upload/files/gpg-disabled/gpg2 | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 test/integration/tests/upload/files/gpg-disabled/gpg create mode 120000 test/integration/tests/upload/files/gpg-disabled/gpg2 diff --git a/test/integration/tests/upload/Main.hs b/test/integration/tests/upload/Main.hs index f8dc66d824..fbc2f46891 100644 --- a/test/integration/tests/upload/Main.hs +++ b/test/integration/tests/upload/Main.hs @@ -2,7 +2,8 @@ import Control.Concurrent import StackTest -import System.Directory (createDirectoryIfMissing) +import System.Directory (createDirectoryIfMissing, + getCurrentDirectory) import System.Environment (getEnv, setEnv) import System.FilePath (()) import System.Process @@ -10,14 +11,24 @@ import System.Process main :: IO () main = withFakeHackage $ do + disableGpg stackRoot <- getEnv "STACK_ROOT" -- Ensure there are credentials available for uploading createDirectoryIfMissing True (stackRoot "upload") writeFile (stackRoot "upload" "credentials.json") "{\"username\":\"fake\",\"password\":\"fake\"}" - -- Upload + -- Test the upload with no signing stack ["upload", "--no-signature", "."] + -- Test failure signing + stackErr ["upload", "."] + +-- | Ensure gpg is unusable by putting a broken one on PATH +disableGpg :: IO () +disableGpg = do + originalPath <- getEnv "PATH" + cwd <- getCurrentDirectory + setEnv "PATH" $ (cwd "gpg-disabled") ++ ":" ++ originalPath -- | Start a fake Hackage server to test the upload withFakeHackage :: IO a -> IO a diff --git a/test/integration/tests/upload/files/gpg-disabled/gpg b/test/integration/tests/upload/files/gpg-disabled/gpg new file mode 100755 index 0000000000..7a54effe96 --- /dev/null +++ b/test/integration/tests/upload/files/gpg-disabled/gpg @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "Should not be used!" >&2 +exit 1 diff --git a/test/integration/tests/upload/files/gpg-disabled/gpg2 b/test/integration/tests/upload/files/gpg-disabled/gpg2 new file mode 120000 index 0000000000..a7506d694e --- /dev/null +++ b/test/integration/tests/upload/files/gpg-disabled/gpg2 @@ -0,0 +1 @@ +gpg \ No newline at end of file From b4d1f0c8816b7e6fe917c358f7188aed6420186c Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Sun, 22 Jul 2018 09:35:43 +1000 Subject: [PATCH 19/22] Remove unneeded LICENSE file in the integration test --- test/integration/tests/upload/files/LICENSE | 1 - test/integration/tests/upload/files/uploadtest.cabal | 1 - 2 files changed, 2 deletions(-) delete mode 100644 test/integration/tests/upload/files/LICENSE diff --git a/test/integration/tests/upload/files/LICENSE b/test/integration/tests/upload/files/LICENSE deleted file mode 100644 index 11c892df1d..0000000000 --- a/test/integration/tests/upload/files/LICENSE +++ /dev/null @@ -1 +0,0 @@ -Upload test license diff --git a/test/integration/tests/upload/files/uploadtest.cabal b/test/integration/tests/upload/files/uploadtest.cabal index d815cddd6c..fbf051d525 100644 --- a/test/integration/tests/upload/files/uploadtest.cabal +++ b/test/integration/tests/upload/files/uploadtest.cabal @@ -7,7 +7,6 @@ cabal-version: 1.20 synopsis: Upload test description: Upload test description license: BSD3 -license-file: LICENSE library build-depends: base >= 4.7 && < 5 exposed-modules: Foo From 2e21dfdf57c82ba863a98c8fa550e4b65ed95e3c Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Sun, 22 Jul 2018 09:41:55 +1000 Subject: [PATCH 20/22] Add hackage-base-url to changelog --- ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index e51f477662..dc41fa824d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -81,6 +81,9 @@ Other enhancements: rather than after * Bump to hpack 0.29.0 * With GHC 8.4 and later, Haddock is given the `--quickjump` flag. +* It is possible to specify the Hackage base URL to upload packages to, instead + of the default of `https://hackage.haskell.org/`, by using `hackage-base-url` + configuration option. Bug fixes: From 4d664ba9a56780c2e54476464627b7c14bc4cbb8 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 24 Jul 2018 06:32:40 -0700 Subject: [PATCH 21/22] 3942-solver-error-output test: use https URL for repo instead of ssh --- .../tests/3942-solver-error-output/files/test-stack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/tests/3942-solver-error-output/files/test-stack.yml b/test/integration/tests/3942-solver-error-output/files/test-stack.yml index d0479c6cd0..e74b7e7774 100644 --- a/test/integration/tests/3942-solver-error-output/files/test-stack.yml +++ b/test/integration/tests/3942-solver-error-output/files/test-stack.yml @@ -2,7 +2,7 @@ resolver: lts-11.6 packages: - location: - git: git@github.com:cjdev/cloudseeder.git + git: https://github.com/cjdev/cloudseeder.git commit: c7068f25c41bcc0b4bdfc9b38ee5b05b5caefae5 extra-dep: true From 4e3b5fa38e851212e655dc574178756b647cb0ac Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 24 Jul 2018 19:14:34 +0300 Subject: [PATCH 22/22] Add uninstall section, fixes #4170 --- doc/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/README.md b/doc/README.md index d6e4bd5c6d..5b6c807c41 100644 --- a/doc/README.md +++ b/doc/README.md @@ -191,3 +191,7 @@ project meeting the needs of Haskell users of all stripes. If you'd like to get involved with Stack, check out the [newcomer friendly](https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3a%22newcomer+friendly%22) label on the Github issue tracker. + +#### How to uninstall +Removing ``~/.stack`` and ``/usr/local/bin/stack`` should be sufficient. You may want to delete ``.stack-work`` folders in any Haskell projects that you have built. +