Skip to content

Commit

Permalink
Allow for old versions of bytestring
Browse files Browse the repository at this point in the history
BS.dropEnd requires >=bytestring-0.11.1, but this doesn't get bundled
with GHC until v9.2.1. Allow for old bytestring/behavior so that
previous versions of GHC can still use haskell-updater.

Signed-off-by: hololeap <hololeap@users.noreply.github.com>
  • Loading branch information
hololeap committed Jul 22, 2023
1 parent c6a28ff commit 19d05bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Distribution/Gentoo/GHC.hs
Expand Up @@ -236,12 +236,17 @@ checkLibDirs v thisGhc libDirs =

isValid dir = any (`isGhcLibDir` dir) libDirs

#if MIN_VERSION_bytestring(1,11,1)
-- Correct the path for hadrian-based installations
-- See https://github.com/gentoo-haskell/haskell-updater/issues/20
thisGhc' = if BS.isSuffixOf (BS.pack "/lib") thisGhc then BS.dropEnd 4 thisGhc else thisGhc

-- Invalid if it's this GHC
isInvalid fp = fp == thisGhc' || BS.isPrefixOf (thisGhc' `BS.snoc` pathSeparator) fp
#else
-- Versions of GHC with old 'bytestring' can use the old behavior
isInvalid fp = fp == thisGhc || BS.isPrefixOf (thisGhc `BS.snoc` pathSeparator) fp
#endif

-- A valid GHC library directory starting at libdir has a name of
-- "ghc", then a hyphen and then a version number.
Expand Down
6 changes: 5 additions & 1 deletion haskell-updater.cabal
Expand Up @@ -63,11 +63,15 @@ executable haskell-updater
autogen-modules: Paths_haskell_updater
build-depends:
, base >=4.12 && <5
, bytestring >=0.11.1.0
, bytestring
, Cabal >=1.8
, containers
, directory >=1.2.5.0
, filepath
, process

-- Only force new bytestring on versions of GHC that come bundled with it
if impl(ghc >= 9.2.1)
build-depends:
, bytestring >=0.11.1.0
default-language: Haskell2010

0 comments on commit 19d05bc

Please sign in to comment.