From 1ca628aba197c94d0ff98bdd7da1828695d91f4e Mon Sep 17 00:00:00 2001 From: puffnfresh Date: Thu, 18 Jun 2020 07:52:34 -0400 Subject: [PATCH 1/6] Fix dlSubdir of ghc-8.10.1-x86_64-unknown-linux for Linux_Alpine --- ghcup-0.0.2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcup-0.0.2.json b/ghcup-0.0.2.json index 8bd5bd6..96c441e 100644 --- a/ghcup-0.0.2.json +++ b/ghcup-0.0.2.json @@ -687,7 +687,7 @@ "Linux_Alpine": { "unknown_versioning": { "dlHash": "cb13b645d103e2fba2eb8dfcc4e5f2fbd9550c00c4df42f342b4210436dcb8a8", - "dlSubdir": "ghc-8.10.1", + "dlSubdir": "ghc-8.10.1-x86_64-unknown-linux", "dlUri": "https://downloads.haskell.org/~ghc/8.10.1/ghc-8.10.1-x86_64-alpine3.10-linux-integer-simple.tar.xz" } }, From a186b077637acb5aa2eae3485d01001bd39a61f3 Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Thu, 18 Jun 2020 14:03:25 +0000 Subject: [PATCH 2/6] Support Hadrian provided bindists Fixes #31 --- lib/GHCup/Utils.hs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 43d9f32..73d900c 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -54,7 +54,7 @@ import System.IO.Error import System.Posix.FilePath ( getSearchPath , takeFileName ) -import System.Posix.Files.ByteString ( readSymbolicLink ) +import System.Posix.Files.ByteString ( getFileStatus, isSymbolicLink, readSymbolicLink ) import Text.Regex.Posix import URI.ByteString @@ -417,13 +417,20 @@ ghcToolFiles ver = do ([s|^([a-zA-Z0-9_-]*[a-zA-Z0-9_]-)?ghc$|] :: ByteString) ) - (Just symver) <- - (B.stripPrefix (toFilePath ghcbin <> "-") . takeFileName) - <$> (liftIO $ readSymbolicLink $ toFilePath (bindir ghcbin)) - when (B.null symver) - (throwIO $ userError $ "Fatal: ghc symlink target is broken") + let ghcbinPath = toFilePath (bindir ghcbin) + ghcIsLink <- isSymbolicLink <$> (liftIO $ getFileStatus ghcbinPath) + onlyUnversioned <- if ghcIsLink + then do + (Just symver) <- + (B.stripPrefix (toFilePath ghcbin <> "-") . takeFileName) + <$> (liftIO $ readSymbolicLink ghcbinPath) + when (B.null symver) + (throwIO $ userError $ "Fatal: ghc symlink target is broken") + pure $ filter (\x -> not $ symver `B.isSuffixOf` toFilePath x) + else + pure id - pure . filter (\x -> not $ symver `B.isSuffixOf` toFilePath x) $ files + pure $ onlyUnversioned files -- | This file, when residing in ~/.ghcup/ghc// signals that From d276bfb3ec7042ec4342e03c2ac3aa1ad2316002 Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Fri, 19 Jun 2020 23:06:46 +0000 Subject: [PATCH 3/6] Extract Hadrian logic to isHadrian function with comment --- lib/GHCup/Utils.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 73d900c..09f1294 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -418,19 +418,23 @@ ghcToolFiles ver = do ) let ghcbinPath = toFilePath (bindir ghcbin) - ghcIsLink <- isSymbolicLink <$> (liftIO $ getFileStatus ghcbinPath) - onlyUnversioned <- if ghcIsLink - then do + ghcIsHadrian <- liftIO $ isHadrian ghcbinPath + onlyUnversioned <- if ghcIsHadrian + then pure id + else do (Just symver) <- (B.stripPrefix (toFilePath ghcbin <> "-") . takeFileName) <$> (liftIO $ readSymbolicLink ghcbinPath) when (B.null symver) (throwIO $ userError $ "Fatal: ghc symlink target is broken") pure $ filter (\x -> not $ symver `B.isSuffixOf` toFilePath x) - else - pure id pure $ onlyUnversioned files + where + -- GHC is moving some builds to Hadrian for bindists, which doesn't create versioned binaries + -- https://gitlab.haskell.org/haskell/ghcup-hs/issues/31 + isHadrian :: ByteString -> IO Bool + isHadrian = (not . isSymbolicLink <$>) . getFileStatus -- | This file, when residing in ~/.ghcup/ghc// signals that From 3055529d4ceab463d92c3a5bbd0a10a0d7fabd9f Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Fri, 19 Jun 2020 23:17:34 +0000 Subject: [PATCH 4/6] Update GHCupDownloads with ghcup-0.0.2.json content --- lib/GHCup/Data/GHCupDownloads.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GHCup/Data/GHCupDownloads.hs b/lib/GHCup/Data/GHCupDownloads.hs index e2d692f..77f83ab 100644 --- a/lib/GHCup/Data/GHCupDownloads.hs +++ b/lib/GHCup/Data/GHCupDownloads.hs @@ -883,7 +883,7 @@ ghc_8101_64_darwin = DownloadInfo ghc_8101_64_alpine :: DownloadInfo ghc_8101_64_alpine = DownloadInfo [uri|https://downloads.haskell.org/~ghc/8.10.1/ghc-8.10.1-x86_64-alpine3.10-linux-integer-simple.tar.xz|] - (Just [rel|ghc-8.10.1|]) + (Just [rel|ghc-8.10.1-x86_64-unknown-linux|]) "cb13b645d103e2fba2eb8dfcc4e5f2fbd9550c00c4df42f342b4210436dcb8a8" From febe6fcb35fe6fab31ae9c5c568d18ed8eaa88f3 Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Sat, 20 Jun 2020 03:38:34 +0000 Subject: [PATCH 5/6] Fix behaviour of non-Hadrian builds getFileStatus will resolve symbolic links. getSymbolicLinkStatus doesn't. --- lib/GHCup/Utils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 09f1294..6a6104b 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -54,7 +54,7 @@ import System.IO.Error import System.Posix.FilePath ( getSearchPath , takeFileName ) -import System.Posix.Files.ByteString ( getFileStatus, isSymbolicLink, readSymbolicLink ) +import System.Posix.Files.ByteString ( getSymbolicLinkStatus, isSymbolicLink, readSymbolicLink ) import Text.Regex.Posix import URI.ByteString @@ -434,7 +434,7 @@ ghcToolFiles ver = do -- GHC is moving some builds to Hadrian for bindists, which doesn't create versioned binaries -- https://gitlab.haskell.org/haskell/ghcup-hs/issues/31 isHadrian :: ByteString -> IO Bool - isHadrian = (not . isSymbolicLink <$>) . getFileStatus + isHadrian = (not . isSymbolicLink <$>) . getSymbolicLinkStatus -- | This file, when residing in ~/.ghcup/ghc// signals that From 7ec6e8604cd142ffa8fe7e8aa42efb8e0b29dabf Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 20 Jun 2020 14:37:38 +0200 Subject: [PATCH 6/6] Slight style changes --- lib/GHCup/Utils.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 6a6104b..eef7b50 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -54,7 +54,7 @@ import System.IO.Error import System.Posix.FilePath ( getSearchPath , takeFileName ) -import System.Posix.Files.ByteString ( getSymbolicLinkStatus, isSymbolicLink, readSymbolicLink ) +import System.Posix.Files.ByteString ( readSymbolicLink ) import Text.Regex.Posix import URI.ByteString @@ -417,24 +417,26 @@ ghcToolFiles ver = do ([s|^([a-zA-Z0-9_-]*[a-zA-Z0-9_]-)?ghc$|] :: ByteString) ) - let ghcbinPath = toFilePath (bindir ghcbin) - ghcIsHadrian <- liftIO $ isHadrian ghcbinPath + let ghcbinPath = bindir ghcbin + ghcIsHadrian <- liftIO $ isHadrian ghcbinPath onlyUnversioned <- if ghcIsHadrian then pure id else do (Just symver) <- (B.stripPrefix (toFilePath ghcbin <> "-") . takeFileName) - <$> (liftIO $ readSymbolicLink ghcbinPath) + <$> (liftIO $ readSymbolicLink $ toFilePath ghcbinPath) when (B.null symver) (throwIO $ userError $ "Fatal: ghc symlink target is broken") pure $ filter (\x -> not $ symver `B.isSuffixOf` toFilePath x) pure $ onlyUnversioned files - where - -- GHC is moving some builds to Hadrian for bindists, which doesn't create versioned binaries + where + -- GHC is moving some builds to Hadrian for bindists, + -- which doesn't create versioned binaries. -- https://gitlab.haskell.org/haskell/ghcup-hs/issues/31 - isHadrian :: ByteString -> IO Bool - isHadrian = (not . isSymbolicLink <$>) . getSymbolicLinkStatus + isHadrian :: Path Abs -- ^ ghcbin path + -> IO Bool + isHadrian = fmap (/= SymbolicLink) . getFileType -- | This file, when residing in ~/.ghcup/ghc// signals that