Commit d0e1c513 authored by mimi.vx's avatar mimi.vx Committed by Francesco Gazzetta
Browse files

Allow base16-bytestring 1.0 and newer

(cherry picked from commit 83983fcc)
parent 6577a66a
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Client.HashValue (
......@@ -71,10 +72,14 @@ hashFromTUF (Sec.Hash hashstr) =
--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.
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
-> HashValue hash
_ -> error "hashFromTUF: cannot decode base16 hash"
#endif
-- | Truncate a 32 byte SHA256 hash to
--
......
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- | Separate module for HTTP actions, using a proxy server if one exists.
-----------------------------------------------------------------------------
......@@ -182,7 +183,11 @@ downloadURI transport verbosity uri path = do
fragmentParser = do
_ <- P.string "#sha256="
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)))
#endif
------------------------------------------------------------------------------
-- Utilities for repo url management
......
......@@ -337,7 +337,7 @@ executable cabal
async >= 2.0 && < 2.3,
array >= 0.4 && < 0.6,
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,
bytestring >= 0.10.6.0 && < 0.11,
Cabal == 3.4.*,
......
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