Commit 83983fcc authored by mimi.vx's avatar mimi.vx
Browse files

Allow base16-bytestring 1.0 and newer

parent 20bfbbf3
...@@ -267,7 +267,7 @@ executable cabal ...@@ -267,7 +267,7 @@ executable cabal
async >= 2.0 && < 2.3, async >= 2.0 && < 2.3,
array >= 0.4 && < 0.6, array >= 0.4 && < 0.6,
base >= 4.8 && < 4.15, base >= 4.8 && < 4.15,
base16-bytestring >= 0.1.1 && < 0.2, base16-bytestring >= 0.1.1 && < 1.1.0.0,
binary >= 0.7.3 && < 0.9, binary >= 0.7.3 && < 0.9,
bytestring >= 0.10.6.0 && < 0.11, bytestring >= 0.10.6.0 && < 0.11,
Cabal == 3.5.*, Cabal == 3.5.*,
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
module Distribution.Client.HashValue ( module Distribution.Client.HashValue (
...@@ -71,10 +72,14 @@ hashFromTUF (Sec.Hash hashstr) = ...@@ -71,10 +72,14 @@ hashFromTUF (Sec.Hash hashstr) =
--TODO: [code cleanup] either we should get TUF to use raw bytestrings or --TODO: [code cleanup] either we should get TUF to use raw bytestrings or
-- perhaps we should also just use a base16 string as the internal rep. -- perhaps we should also just use a base16 string as the internal rep.
case Base16.decode (BS.pack hashstr) of case Base16.decode (BS.pack hashstr) of
#if MIN_VERSION_base16_bytestring(1,0,0)
Right hash -> HashValue hash
Left _ -> error "hashFromTUF: cannot decode base16"
#else
(hash, trailing) | not (BS.null hash) && BS.null trailing (hash, trailing) | not (BS.null hash) && BS.null trailing
-> HashValue hash -> HashValue hash
_ -> error "hashFromTUF: cannot decode base16 hash" _ -> error "hashFromTUF: cannot decode base16 hash"
#endif
-- | Truncate a 32 byte SHA256 hash to -- | Truncate a 32 byte SHA256 hash to
-- --
......
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | Separate module for HTTP actions, using a proxy server if one exists. -- | Separate module for HTTP actions, using a proxy server if one exists.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -182,7 +183,11 @@ downloadURI transport verbosity uri path = do ...@@ -182,7 +183,11 @@ downloadURI transport verbosity uri path = do
fragmentParser = do fragmentParser = do
_ <- P.string "#sha256=" _ <- P.string "#sha256="
str <- some P.hexDigit str <- some P.hexDigit
#if MIN_VERSION_base16_bytestring(1,0,0)
return (Base16.decodeLenient (BS8.pack str))
#else
return (fst (Base16.decode (BS8.pack str))) return (fst (Base16.decode (BS8.pack str)))
#endif
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- Utilities for repo url management -- Utilities for repo url management
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment