Skip to content

Commit d1eef3f

Browse files
snoybergborsboom
authored andcommitted
Use unpacked dir name (fixes 5545)
1 parent 9c69ea3 commit d1eef3f

File tree

2 files changed

+19
-28
lines changed

2 files changed

+19
-28
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Bug fixes:
1717

1818
* GHC source builds work properly for recent GHC versions again. See
1919
[#5528](https://github.com/commercialhaskell/stack/issues/5528)
20+
* `stack setup` always looks for the unpacked directory name to support
21+
different tar file naming conventions. See
22+
[#5545](https://github.com/commercialhaskell/stack/issues/5545)
2023

2124
## v2.7.1
2225

src/Stack/Setup.hs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ ensureMsys sopts getSetupInfo' = do
525525
Just x -> return x
526526
Nothing -> throwString $ "MSYS2 not found for " ++ T.unpack osKey
527527
let tool = Tool (PackageIdentifier (mkPackageName "msys2") version)
528-
Just <$> downloadAndInstallTool (configLocalPrograms config) info tool (installMsys2Windows osKey si)
528+
Just <$> downloadAndInstallTool (configLocalPrograms config) info tool (installMsys2Windows si)
529529
| otherwise -> do
530530
logWarn "Continuing despite missing tool: msys2"
531531
return Nothing
@@ -875,8 +875,8 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla
875875
}
876876
ghcdlinfo = GHCDownloadInfo mempty mempty dlinfo
877877
installer
878-
| osIsWindows = installGHCWindows Nothing
879-
| otherwise = installGHCPosix Nothing ghcdlinfo
878+
| osIsWindows = installGHCWindows
879+
| otherwise = installGHCPosix ghcdlinfo
880880
si <- runMemoized getSetupInfo'
881881
_ <- downloadAndInstallTool
882882
(configLocalPrograms config)
@@ -1139,8 +1139,8 @@ downloadAndInstallCompiler ghcBuild si wanted@(WCGhc version) versionCheck mbind
11391139
config <- view configL
11401140
let installer =
11411141
case configPlatform config of
1142-
Platform _ Cabal.Windows -> installGHCWindows (Just selectedVersion)
1143-
_ -> installGHCPosix (Just selectedVersion) downloadInfo
1142+
Platform _ Cabal.Windows -> installGHCWindows
1143+
_ -> installGHCPosix downloadInfo
11441144
logInfo $
11451145
"Preparing to install GHC" <>
11461146
(case ghcVariant of
@@ -1312,15 +1312,14 @@ data ArchiveType
13121312
| SevenZ
13131313

13141314
installGHCPosix :: HasConfig env
1315-
=> Maybe Version
1316-
-> GHCDownloadInfo
1315+
=> GHCDownloadInfo
13171316
-> SetupInfo
13181317
-> Path Abs File
13191318
-> ArchiveType
13201319
-> Path Abs Dir
13211320
-> Path Abs Dir
13221321
-> RIO env ()
1323-
installGHCPosix mversion downloadInfo _ archiveFile archiveType tempDir destDir = do
1322+
installGHCPosix downloadInfo _ archiveFile archiveType tempDir destDir = do
13241323
platform <- view platformL
13251324
menv0 <- view processContextL
13261325
menv <- mkProcessContext (removeHaskellEnvVars (view envVarsL menv0))
@@ -1383,11 +1382,7 @@ installGHCPosix mversion downloadInfo _ archiveFile archiveType tempDir destDir
13831382
logDebug $ "Unpacking " <> fromString (toFilePath archiveFile)
13841383
runStep "unpacking" tempDir mempty tarTool [compOpt : "xf", toFilePath archiveFile]
13851384

1386-
dir <- case mversion of
1387-
Just version -> do
1388-
relDir <- parseRelDir $ "ghc-" ++ versionString version
1389-
return (tempDir </> relDir)
1390-
Nothing -> expectSingleUnpackedDir archiveFile tempDir
1385+
dir <- expectSingleUnpackedDir archiveFile tempDir
13911386

13921387
logSticky "Configuring GHC ..."
13931388
runStep "configuring" dir
@@ -1433,36 +1428,32 @@ instance Alternative (CheckDependency env) where
14331428
Right x' -> return $ Right x'
14341429

14351430
installGHCWindows :: HasBuildConfig env
1436-
=> Maybe Version
1437-
-> SetupInfo
1431+
=> SetupInfo
14381432
-> Path Abs File
14391433
-> ArchiveType
14401434
-> Path Abs Dir
14411435
-> Path Abs Dir
14421436
-> RIO env ()
1443-
installGHCWindows mversion si archiveFile archiveType _tempDir destDir = do
1444-
tarComponent <- mapM (\v -> parseRelDir $ "ghc-" ++ versionString v) mversion
1445-
withUnpackedTarball7z "GHC" si archiveFile archiveType tarComponent destDir
1437+
installGHCWindows si archiveFile archiveType _tempDir destDir = do
1438+
withUnpackedTarball7z "GHC" si archiveFile archiveType destDir
14461439
logInfo $ "GHC installed to " <> fromString (toFilePath destDir)
14471440

14481441
installMsys2Windows :: HasBuildConfig env
1449-
=> Text -- ^ OS Key
1450-
-> SetupInfo
1442+
=> SetupInfo
14511443
-> Path Abs File
14521444
-> ArchiveType
14531445
-> Path Abs Dir
14541446
-> Path Abs Dir
14551447
-> RIO env ()
1456-
installMsys2Windows osKey si archiveFile archiveType _tempDir destDir = do
1448+
installMsys2Windows si archiveFile archiveType _tempDir destDir = do
14571449
exists <- liftIO $ D.doesDirectoryExist $ toFilePath destDir
14581450
when exists $ liftIO (D.removeDirectoryRecursive $ toFilePath destDir) `catchIO` \e -> do
14591451
logError $
14601452
"Could not delete existing msys directory: " <>
14611453
fromString (toFilePath destDir)
14621454
throwM e
14631455

1464-
msys <- parseRelDir $ "msys" ++ T.unpack (fromMaybe "32" $ T.stripPrefix "windows" osKey)
1465-
withUnpackedTarball7z "MSYS2" si archiveFile archiveType (Just msys) destDir
1456+
withUnpackedTarball7z "MSYS2" si archiveFile archiveType destDir
14661457

14671458

14681459
-- I couldn't find this officially documented anywhere, but you need to run
@@ -1491,10 +1482,9 @@ withUnpackedTarball7z :: HasBuildConfig env
14911482
-> SetupInfo
14921483
-> Path Abs File -- ^ Path to archive file
14931484
-> ArchiveType
1494-
-> Maybe (Path Rel Dir) -- ^ Name of directory expected in archive. If Nothing, expects a single folder.
14951485
-> Path Abs Dir -- ^ Destination directory.
14961486
-> RIO env ()
1497-
withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do
1487+
withUnpackedTarball7z name si archiveFile archiveType destDir = do
14981488
suffix <-
14991489
case archiveType of
15001490
TarXz -> return ".xz"
@@ -1512,9 +1502,7 @@ withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do
15121502
liftIO $ ignoringAbsence (removeDirRecur destDir)
15131503
run7z tmpDir archiveFile
15141504
run7z tmpDir (tmpDir </> tarFile)
1515-
absSrcDir <- case msrcDir of
1516-
Just srcDir -> return $ tmpDir </> srcDir
1517-
Nothing -> expectSingleUnpackedDir archiveFile tmpDir
1505+
absSrcDir <- expectSingleUnpackedDir archiveFile tmpDir
15181506
renameDir absSrcDir destDir
15191507

15201508
expectSingleUnpackedDir :: (MonadIO m, MonadThrow m) => Path Abs File -> Path Abs Dir -> m (Path Abs Dir)

0 commit comments

Comments
 (0)