From 82c679a31154cefdda1f6b9d53b7e695c98869fc Mon Sep 17 00:00:00 2001 From: Habib Alamin Date: Mon, 21 Oct 2024 00:42:51 +0100 Subject: [PATCH 1/2] Default to `tar` & `zip` over `libarchive` except on supported platforms `libarchive` (the Haskell package, not its upstream C library) vendors the `config.h` header files generated by autoconf for each platform it supports instead of using autoconf (or even CMake, which the C library offers as an option). So apart from those specific platforms, just use `tar` & `zip`. `lzma-static` currently does the same, but we're gonna fix it upstream then update the minimum version bounds on our dependency of it. --- cabal.project.release | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cabal.project.release b/cabal.project.release index 0acb162e..1a0ca762 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -2,9 +2,10 @@ import: cabal.project.common optimization: 2 --- The release project file always wants to build with -tar. --- The tar flag is only there to circumvent complicated errors during --- development, which sometimes happens due to libarchive. +-- The release project file always wants to build with -tar on the +-- platforms it supports (which are those it provides config.h files +-- for). The tar flag is only there to circumvent complicated errors +-- during development, which sometimes happens due to libarchive. package ghcup flags: +tui @@ -32,3 +33,6 @@ elif os(freebsd) xz -system-xz package * ghc-options: -split-sections +else + package ghcup + flags: +tar From 175da25ba8e93d6e5c60da8555938b7aef7227fa Mon Sep 17 00:00:00 2001 From: Habib Alamin Date: Mon, 21 Oct 2024 00:49:58 +0100 Subject: [PATCH 2/2] Add OpenBSD as an explicitly supported platform GHCup currently doesn't run on OpenBSD (or any platform not explicitly supported), even if it builds. This adds explicit support for OpenBSD. We may later not block it from running on unsupported platforms, even when we don't explicitly make sure our build scripts work for them or provide bindists or CI for them. --- lib-opt/GHCup/OptParse/ChangeLog.hs | 1 + lib/GHCup/Platform.hs | 10 ++++++++++ lib/GHCup/Types.hs | 2 ++ lib/GHCup/Types/JSON.hs | 2 ++ 4 files changed, 15 insertions(+) diff --git a/lib-opt/GHCup/OptParse/ChangeLog.hs b/lib-opt/GHCup/OptParse/ChangeLog.hs index 97bf9d23..797cfefa 100644 --- a/lib-opt/GHCup/OptParse/ChangeLog.hs +++ b/lib-opt/GHCup/OptParse/ChangeLog.hs @@ -136,6 +136,7 @@ changelog ChangeLogOptions{..} runAppState runLogger = do Darwin -> exec "open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing Linux _ -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing FreeBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing + OpenBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing Windows -> do let args = "start \"\" " ++ (T.unpack $ decUTF8Safe $ serializeURIRef' uri) c <- liftIO $ system $ args diff --git a/lib/GHCup/Platform.hs b/lib/GHCup/Platform.hs index 93dcd05d..17f1a296 100644 --- a/lib/GHCup/Platform.hs +++ b/lib/GHCup/Platform.hs @@ -119,11 +119,17 @@ getPlatform = do either (const Nothing) Just . versioning . decUTF8Safe' <$> getFreeBSDVersion pure $ PlatformResult { _platform = FreeBSD, _distroVersion = ver } + "openbsd" -> do + ver <- + either (const Nothing) Just . versioning . decUTF8Safe' + <$> getOpenBSDVersion + pure $ PlatformResult { _platform = OpenBSD, _distroVersion = ver } "mingw32" -> pure PlatformResult { _platform = Windows, _distroVersion = Nothing } what -> throwE $ NoCompatiblePlatform what lift $ logDebug $ "Identified Platform as: " <> T.pack (prettyShow pfr) pure pfr where + getOpenBSDVersion = lift $ fmap _stdOut $ executeOut "uname" ["-r"] Nothing getFreeBSDVersion = lift $ fmap _stdOut $ executeOut "freebsd-version" [] Nothing getDarwinVersion = lift $ fmap _stdOut $ executeOut "sw_vers" ["-productVersion"] @@ -306,6 +312,7 @@ getStackGhcBuilds PlatformResult{..} = do [] -> [] _ -> L.intercalate "-" c) libComponents + OpenBSD -> pure [] FreeBSD -> case _distroVersion of Just fVer @@ -343,6 +350,8 @@ getStackOSKey PlatformRequest { .. } = (A_64 , Darwin ) -> pure "macosx" (A_32 , FreeBSD) -> pure "freebsd32" (A_64 , FreeBSD) -> pure "freebsd64" + (A_32 , OpenBSD) -> pure "openbsd32" + (A_64 , OpenBSD) -> pure "openbsd64" (A_32 , Windows) -> pure "windows32" (A_64 , Windows) -> pure "windows64" (A_ARM , Linux _) -> pure "linux-armv7" @@ -350,6 +359,7 @@ getStackOSKey PlatformRequest { .. } = (A_Sparc, Linux _) -> pure "linux-sparc" (A_ARM64, Darwin ) -> pure "macosx-aarch64" (A_ARM64, FreeBSD) -> pure "freebsd-aarch64" + (A_ARM64, OpenBSD) -> pure "openbsd-aarch64" (arch', os') -> throwE $ UnsupportedSetupCombo arch' os' getStackPlatformKey :: (MonadReader env m, MonadFail m, HasLog env, MonadCatch m, MonadIO m) diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index 5e989c20..8b207e4f 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -227,6 +227,7 @@ data Platform = Linux LinuxDistro | Darwin -- ^ must exit | FreeBSD + | OpenBSD | Windows -- ^ must exit deriving (Eq, GHC.Generic, Ord, Show) @@ -237,6 +238,7 @@ platformToString :: Platform -> String platformToString (Linux distro) = "linux-" ++ distroToString distro platformToString Darwin = "darwin" platformToString FreeBSD = "freebsd" +platformToString OpenBSD = "openbsd" platformToString Windows = "windows" instance Pretty Platform where diff --git a/lib/GHCup/Types/JSON.hs b/lib/GHCup/Types/JSON.hs index 07126634..e395a942 100644 --- a/lib/GHCup/Types/JSON.hs +++ b/lib/GHCup/Types/JSON.hs @@ -144,12 +144,14 @@ instance ToJSONKey Platform where FreeBSD -> T.pack "FreeBSD" Linux (OtherLinux s) -> T.pack ("Linux_" <> s) Linux d -> T.pack ("Linux_" <> show d) + OpenBSD -> T.pack "OpenBSD" Windows -> T.pack "Windows" instance FromJSONKey Platform where fromJSONKey = FromJSONKeyTextParser $ \t -> if | T.pack "Darwin" == t -> pure Darwin | T.pack "FreeBSD" == t -> pure FreeBSD + | T.pack "OpenBSD" == t -> pure OpenBSD | T.pack "Windows" == t -> pure Windows | T.pack "Linux_" `T.isPrefixOf` t -> case T.stripPrefix (T.pack "Linux_") t