From 104b3a9c6ae759577bd0861b39505bbfe4ea9033 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 22 Jun 2020 11:30:33 -0400 Subject: [PATCH] Build with the http-client-restricted library when available Otherwise use the vendored copy as before. The library is in Debian testing but not stable. Once it reaches stable, the vendored copy can be removed. Did not add it to debian/control because IIRC that's used to build git-annex on stable too, possibly. However, the Debian maintainer will probably want to make the package depend on libghc-http-client-restricted-dev This commit was sponsored by Ilya Shlyakhter on Patreon. --- Annex/Url.hs | 6 ++++++ CHANGELOG | 4 ++-- Utility/HttpManagerRestricted.hs | 3 +++ Utility/Url.hs | 5 +++++ git-annex.cabal | 11 ++++++++++- stack-lts-12.14.yaml | 1 + stack.yaml | 1 + 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Annex/Url.hs b/Annex/Url.hs index 77d48b044b..fd0fc9f39b 100644 --- a/Annex/Url.hs +++ b/Annex/Url.hs @@ -6,6 +6,8 @@ - Licensed under the GNU AGPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Annex.Url ( withUrlOptions, withUrlOptionsPromptingCreds, @@ -34,7 +36,11 @@ import Annex.Common import qualified Annex import qualified Utility.Url as U import Utility.IPAddress +#ifdef WITH_HTTP_CLIENT_RESTRICTED +import Network.HTTP.Client.Restricted +#else import Utility.HttpManagerRestricted +#endif import Utility.Metered import Git.Credential import qualified BuildInfo diff --git a/CHANGELOG b/CHANGELOG index df0c6cb687..28fc49cee6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,8 +3,8 @@ git-annex (8.20200618) UNRELEASED; urgency=medium * Fix a deadlock that could occur after git-annex got an unlocked file, causing the command to hang indefinitely. Known to happen on vfat filesystems, possibly others. - * Build with the git-lfs library when available, otherwise use the - vendored copy as before. + * Build with the http-client-restricted and git-lfs libraries when + available, otherwise use the vendored copy as before. -- Joey Hess Thu, 18 Jun 2020 12:21:14 -0400 diff --git a/Utility/HttpManagerRestricted.hs b/Utility/HttpManagerRestricted.hs index 0b325240b4..b0b4e51451 100644 --- a/Utility/HttpManagerRestricted.hs +++ b/Utility/HttpManagerRestricted.hs @@ -9,6 +9,9 @@ {-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable, LambdaCase, PatternGuards #-} +-- This is a vendored copy of Network.HTTP.Client.Restricted from the +-- http-client-restricted package, and will be removed once that package +-- is available in all build environments. module Utility.HttpManagerRestricted ( Restriction, checkAddressRestriction, diff --git a/Utility/Url.hs b/Utility/Url.hs index 763474fdf1..0bcc6efbff 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -9,6 +9,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} module Utility.Url ( newManager, @@ -44,7 +45,11 @@ module Utility.Url ( import Common import Utility.Metered +#ifdef WITH_HTTP_CLIENT_RESTRICTED +import Network.HTTP.Client.Restricted +#else import Utility.HttpManagerRestricted +#endif import Utility.IPAddress import Network.URI diff --git a/git-annex.cabal b/git-annex.cabal index 35dd3ef3c5..c11f8e96b0 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -293,6 +293,10 @@ Flag GitLfs Description: Build with git-lfs library (rather than vendored copy) Default: True +Flag HttpClientRestricted + Description: Build with http-client-restricted library (rather than vendored copy) + Default: True + source-repository head type: git location: git://git-annex.branchable.com/ @@ -416,6 +420,12 @@ Executable git-annex CPP-Options: -DWITH_GIT_LFS else Other-Modules: Utility.GitLFS + + if flag(HttpClientRestricted) + Build-Depends: http-client-restricted (>= 0.0.2) + CPP-Options: -DWITH_HTTP_CLIENT_RESTRICTED + else + Other-Modules: Utility.HttpManagerRestricted if flag(S3) Build-Depends: aws (>= 0.20) @@ -1074,7 +1084,6 @@ Executable git-annex Utility.Gpg Utility.Hash Utility.HtmlDetect - Utility.HttpManagerRestricted Utility.HumanNumber Utility.HumanTime Utility.InodeCache diff --git a/stack-lts-12.14.yaml b/stack-lts-12.14.yaml index 918a042c6c..51d1bf01a4 100644 --- a/stack-lts-12.14.yaml +++ b/stack-lts-12.14.yaml @@ -13,6 +13,7 @@ flags: benchmark: false networkbsd: false gitlfs: true + httpclientrestricted: true packages: - '.' extra-deps: diff --git a/stack.yaml b/stack.yaml index d2ee985a14..32014aa6f7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -13,6 +13,7 @@ flags: benchmark: false networkbsd: false gitlfs: true + httpclientrestricted: true packages: - '.' extra-deps: