Skip to content

Commit 890a2d0

Browse files
committed
Merge pull request #2003 from commercialhaskell/hotfix/2000-dont-delete-ssh
v1.0.4.3 hotfix for deletion of ~/.ssh
2 parents 1f00206 + 1c7ba8c commit 890a2d0

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.0.4.3
4+
5+
Bug fixes
6+
7+
* Don't delete contents of ~/.ssh when using `stack clean --full` with Docker
8+
enabled [#2000](https://github.com/commercialhaskell/stack/issues/2000)
9+
310
## 1.0.4.2
411

512
Build with path-io-1.0.0. There are no changes in behaviour from 1.0.4,

src/Stack/Docker.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ runContainerAndExit getCmdArgs
260260
<*> hIsTerminalDevice stderr
261261
<*> (parseAbsDir =<< getHomeDirectory)
262262
isStdoutTerminal <- asks getTerminal
263-
let sshDir = homeDir </> sshRelDir
264-
sshDirExists <- doesDirExist sshDir
265263
let dockerHost = lookup "DOCKER_HOST" env
266264
dockerCertPath = lookup "DOCKER_CERT_PATH" env
267265
bamboo = lookup "bamboo_buildKey" env
@@ -309,6 +307,19 @@ runContainerAndExit getCmdArgs
309307
liftIO
310308
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
311309
mapM_ (ensureDir) [sandboxHomeDir, stackRoot])
310+
-- Since $HOME is now mounted in the same place in the container we can
311+
-- just symlink $HOME/.ssh to the right place for the stack docker user
312+
let sshDir = homeDir </> sshRelDir
313+
sshDirExists <- doesDirExist sshDir
314+
sshSandboxDirExists <-
315+
liftIO
316+
(Files.fileExist
317+
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
318+
when (sshDirExists && not sshSandboxDirExists)
319+
(liftIO
320+
(Files.createSymbolicLink
321+
(toFilePathNoTrailingSep sshDir)
322+
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
312323
containerID <- (trim . decodeUtf8) <$> readDockerProcess
313324
envOverride
314325
(concat
@@ -320,17 +331,14 @@ runContainerAndExit getCmdArgs
320331
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
321332
,"-e","PATH=" ++ T.unpack newPathEnv
322333
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
334+
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toFilePathNoTrailingSep homeDir
323335
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot
324336
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
325337
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
326338
,"-w",toFilePathNoTrailingSep pwd]
327339
,case muserEnv of
328340
Nothing -> []
329341
Just userEnv -> ["-e","USER=" ++ userEnv]
330-
,if sshDirExists
331-
then ["-v",toFilePathNoTrailingSep sshDir ++ ":" ++
332-
toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)]
333-
else []
334342
,case msshAuthSock of
335343
Nothing -> []
336344
Just sshAuthSock ->

stack.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: stack
2-
version: 1.0.4.2
2+
version: 1.0.4.3
33
synopsis: The Haskell Tool Stack
44
description: Please see the README.md for usage information, and
55
the wiki on Github for more details. Also, note that

0 commit comments

Comments
 (0)