Skip to content

Commit

Permalink
Use 7zip to unpack GHCJS sdists on windows #749
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Oct 7, 2015
1 parent c11ad03 commit 20d27a8
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ downloadAndInstallCompiler si wanted@(GhcjsVersion version _) versionCheck _mbin
Just pairs -> getWantedCompilerInfo "source" versionCheck wanted id pairs
$logInfo "Preparing to install GHCJS to an isolated location."
$logInfo "This will not interfere with any system-level installation."
downloadAndInstallTool si downloadInfo (ToolGhcjs selectedVersion) (installGHCJSPosix version)
downloadAndInstallTool si downloadInfo (ToolGhcjs selectedVersion) (installGHCJS version)

getWantedCompilerInfo :: (Ord k, MonadThrow m)
=> Text
Expand Down Expand Up @@ -751,32 +751,20 @@ installGHCPosix version _ archiveFile archiveType destDir = do
$logStickyDone $ "Installed GHC."
$logDebug $ "GHC installed to " <> T.pack (toFilePath destDir)

installGHCJSPosix :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
=> Version
-> SetupInfo
-> Path Abs File
-> ArchiveType
-> Path Abs Dir
-> m ()
installGHCJSPosix version _ archiveFile archiveType destDir = do
installGHCJS :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
=> Version
-> SetupInfo
-> Path Abs File
-> ArchiveType
-> Path Abs Dir
-> m ()
installGHCJS version si archiveFile archiveType destDir = do
platform <- asks getPlatform
menv0 <- getMinimalEnvOverride
-- This ensures that locking is disabled for the invocations of stack below.
let removeLockVar = Map.delete "STACK_LOCK"
menv <- mkEnvOverride platform (removeLockVar (removeHaskellEnvVars (unEnvOverride menv0)))
$logDebug $ "menv = " <> T.pack (show (unEnvOverride menv))
zipTool' <-
case archiveType of
TarXz -> return "xz"
TarBz2 -> return "bzip2"
TarGz -> return "gzip"
SevenZ -> error "Don't know how to deal with .7z files on non-Windows"
(zipTool, tarTool) <- checkDependencies $ (,)
<$> checkDependency zipTool'
<*> checkDependency "tar"

$logDebug $ "ziptool: " <> T.pack zipTool
$logDebug $ "tar: " <> T.pack tarTool

-- NOTE: this is a bit of a hack - instead of using a temp directory, put
-- the source tarball in the destination directory. This way, the absolute
Expand All @@ -791,9 +779,28 @@ installGHCJSPosix version _ archiveFile archiveType destDir = do
createTree srcDir
stackYaml <- ghcjsStackYaml version destDir

platform <- asks getPlatform
runUnpack <- case platform of
Platform _ Cabal.Windows -> do
run7z <- setup7z si
return $ run7z srcDir archiveFile
_ -> do
zipTool' <-
case archiveType of
TarXz -> return "xz"
TarBz2 -> return "bzip2"
TarGz -> return "gzip"
SevenZ -> error "Don't know how to deal with .7z files on non-Windows"
(zipTool, tarTool) <- checkDependencies $ (,)
<$> checkDependency zipTool'
<*> checkDependency "tar"
$logDebug $ "ziptool: " <> T.pack zipTool
$logDebug $ "tar: " <> T.pack tarTool
return $ readInNull srcDir tarTool menv ["xf", toFilePath archiveFile] Nothing

$logSticky $ T.concat ["Unpacking GHCJS into ", (T.pack . toFilePath $ srcDir), " ..."]
$logDebug $ "Unpacking " <> T.pack (toFilePath archiveFile)
readInNull srcDir tarTool menv ["xf", toFilePath archiveFile] Nothing
runUnpack

$logSticky "Installing GHCJS (this will take a long time) ..."
let destBinDir = destDir Path.</> $(mkRelDir "bin")
Expand Down

0 comments on commit 20d27a8

Please sign in to comment.