Added a comment: Patch to fix aws head build issue

This commit is contained in:
alpernebbi 2016-12-10 13:08:58 +00:00 committed by admin
parent efa71e70a4
commit bbc5e4f4f3

View file

@ -0,0 +1,149 @@
[[!comment format=mdwn
username="alpernebbi"
avatar="http://cdn.libravatar.org/avatar/daf2abb14f39e28ad75d5f9a03fcd106"
subject="Patch to fix aws head build issue"
date="2016-12-10T13:08:58Z"
content="""
I think I fixed this. I'm attaching the output of `git format-patch origin/master`.
In an Arch Linux chroot with their [PKGBUILD](https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/git-annex) (with a small modification to apply the patch), `haskell-http-client 0.5.3.3-1` and `http-conduit 2.2.3-5` both the build and the tests are successful.
It's also successful in a Debian Sid chroot, where `sudo apt build-dep git-annex` gives me `libghc-http-client-dev 0.4.31.1-3+b2`, `libghc-http-conduit-dev 2.1.11-3+b2`.
### Patch
[[!format patch \"\"\"
From 2ce09420aa8f3d916c6562abea4ed8911a186902 Mon Sep 17 00:00:00 2001
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Date: Sat, 10 Dec 2016 15:24:27 +0300
Subject: [PATCH] Remove http-conduit (<2.2.0) constraint
Since https://github.com/aristidb/aws/issues/206 is resolved, this
constraint is no longer necessary. However, http-conduit (>=2.2.0)
requires http-client (>=0.5.0) which introduces some breaking changes.
This commit also implements those changes depending on the version.
Fixes: https://git-annex.branchable.com/bugs/Build_with_aws_head_fails/
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
---
Remote/S3.hs | 8 +++++++-
Remote/WebDAV.hs | 17 +++++++++++++++++
Utility/Url.hs | 8 ++++++++
git-annex.cabal | 3 +--
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Remote/S3.hs b/Remote/S3.hs
index 4c1bd57..9563b5a 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -49,6 +49,12 @@ import Annex.Content
import Annex.Url (withUrlOptions)
import Utility.Url (checkBoth, managerSettings, closeManager)
+#if MIN_VERSION_http_client(0,5,0)
+import Network.HTTP.Client (responseTimeoutNone)
+#else
+responseTimeoutNone = Nothing
+#endif
+
type BucketName = String
remote :: RemoteType
@@ -430,7 +436,7 @@ withS3HandleMaybe c gc u a = do
where
s3cfg = s3Configuration c
httpcfg = managerSettings
- { managerResponseTimeout = Nothing }
+ { managerResponseTimeout = responseTimeoutNone }
s3Configuration :: RemoteConfig -> S3.S3Configuration AWS.NormalQuery
s3Configuration c = cfg
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index 19dbaa8..14947f1 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -5,6 +5,7 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Remote.WebDAV (remote, davCreds, configUrl) where
@@ -34,6 +35,10 @@ import Utility.Url (URLString, matchStatusCodeException)
import Annex.UUID
import Remote.WebDAV.DavLocation
+#if MIN_VERSION_http_client(0,5,0)
+import Network.HTTP.Client (HttpExceptionContent(..), responseStatus)
+#endif
+
remote :: RemoteType
remote = RemoteType {
typename = \"webdav\",
@@ -302,6 +307,17 @@ goDAV (DavHandle ctx user pass _) a = choke $ run $ prettifyExceptions $ do
{- Catch StatusCodeException and trim it to only the statusMessage part,
- eliminating a lot of noise, which can include the whole request that
- failed. The rethrown exception is no longer a StatusCodeException. -}
+#if MIN_VERSION_http_client(0,5,0)
+prettifyExceptions :: DAVT IO a -> DAVT IO a
+prettifyExceptions a = catchJust (matchStatusCodeException (const True)) a go
+ where
+ go (HttpExceptionRequest _ (StatusCodeException response message)) = error $ unwords
+ [ \"DAV failure:\"
+ , show (responseStatus response)
+ , show (message)
+ ]
+ go e = throwM e
+#else
prettifyExceptions :: DAVT IO a -> DAVT IO a
prettifyExceptions a = catchJust (matchStatusCodeException (const True)) a go
where
@@ -311,6 +327,7 @@ prettifyExceptions a = catchJust (matchStatusCodeException (const True)) a go
, show (statusMessage status)
]
go e = throwM e
+#endif
prepDAV :: DavUser -> DavPass -> DAVT IO ()
prepDAV user pass = do
diff --git a/Utility/Url.hs b/Utility/Url.hs
index 9b68871..d0e1b37 100644
--- a/Utility/Url.hs
+++ b/Utility/Url.hs
@@ -350,8 +350,16 @@ hUserAgent = \"User-Agent\"
-
- > catchJust (matchStatusCodeException (== notFound404))
-}
+#if MIN_VERSION_http_client(0,5,0)
+matchStatusCodeException :: (Status -> Bool) -> HttpException -> Maybe HttpException
+matchStatusCodeException want e@(HttpExceptionRequest _ (StatusCodeException r _))
+ | want (responseStatus r) = Just e
+ | otherwise = Nothing
+matchStatusCodeException _ _ = Nothing
+#else
matchStatusCodeException :: (Status -> Bool) -> HttpException -> Maybe HttpException
matchStatusCodeException want e@(StatusCodeException s _ _)
| want s = Just e
| otherwise = Nothing
matchStatusCodeException _ _ = Nothing
+#endif
diff --git a/git-annex.cabal b/git-annex.cabal
index ec54a14..83d45a1 100644
--- a/git-annex.cabal
+++ b/git-annex.cabal
@@ -357,8 +357,7 @@ Executable git-annex
resourcet,
http-client,
http-types,
- -- Old version needed due to https://github.com/aristidb/aws/issues/206
- http-conduit (<2.2.0),
+ http-conduit,
time,
old-locale,
esqueleto,
--
2.7.4
\"\"\"]]
"""]]