Roll the dns build flag into the assistant build flag.

This commit is contained in:
Joey Hess 2016-01-26 08:48:14 -04:00
parent 65f44423d1
commit dcfb038cd2
Failed to extract signature
4 changed files with 3 additions and 52 deletions

View file

@ -73,9 +73,6 @@ buildFlags = filter (not . null)
#else #else
#warning Building without ConcurrentOutput #warning Building without ConcurrentOutput
#endif #endif
#ifdef WITH_DNS
, "DNS"
#endif
#ifdef WITH_TDFA #ifdef WITH_TDFA
, "TDFA" , "TDFA"
#endif #endif

View file

@ -1,6 +1,4 @@
{- SRV record lookup {- SRV record lookup
-
- Uses either the the standalone Haskell DNS package, or the host command.
- -
- Copyright 2012 Joey Hess <id@joeyh.name> - Copyright 2012 Joey Hess <id@joeyh.name>
- -
@ -13,26 +11,15 @@ module Utility.SRV (
mkSRVTcp, mkSRVTcp,
mkSRV, mkSRV,
lookupSRV, lookupSRV,
lookupSRVHost,
HostPort, HostPort,
) where ) where
import Utility.Process
import Utility.Exception
import Utility.PartialPrelude
import Network
import Data.Function import Data.Function
import Data.List import Data.List
import Data.Maybe import Network
import Control.Applicative
import Prelude
#ifdef WITH_DNS
import qualified Network.DNS.Lookup as DNS import qualified Network.DNS.Lookup as DNS
import Network.DNS.Resolver import Network.DNS.Resolver
import qualified Data.ByteString.UTF8 as B8 import qualified Data.ByteString.UTF8 as B8
#endif
newtype SRV = SRV String newtype SRV = SRV String
deriving (Show, Eq) deriving (Show, Eq)
@ -52,7 +39,6 @@ mkSRVTcp = mkSRV "tcp"
- -
- On error, returns an empty list. -} - On error, returns an empty list. -}
lookupSRV :: SRV -> IO [HostPort] lookupSRV :: SRV -> IO [HostPort]
#ifdef WITH_DNS
lookupSRV (SRV srv) = do lookupSRV (SRV srv) = do
seed <- makeResolvSeed defaultResolvConf seed <- makeResolvSeed defaultResolvConf
r <- withResolver seed $ flip DNS.lookupSRV $ B8.fromString srv r <- withResolver seed $ flip DNS.lookupSRV $ B8.fromString srv
@ -68,33 +54,6 @@ lookupSRV (SRV srv) = do
( (priority, weight) ( (priority, weight)
, (B8.toString hostname, PortNumber $ fromIntegral port) , (B8.toString hostname, PortNumber $ fromIntegral port)
) )
#else
lookupSRV = lookupSRVHost
#endif
lookupSRVHost :: SRV -> IO [HostPort]
lookupSRVHost (SRV srv) = catchDefaultIO [] $
parseSrvHost <$> readProcessEnv "host" ["-t", "SRV", "--", srv]
-- clear environment, to avoid LANG affecting output
(Just [])
parseSrvHost :: String -> [HostPort]
parseSrvHost = orderHosts . catMaybes . map parse . lines
where
parse l = case words l of
[_, _, _, _, spriority, sweight, sport, hostname] -> do
let v =
( readish sport :: Maybe Int
, readish spriority :: Maybe Int
, readish sweight :: Maybe Int
)
case v of
(Just port, Just priority, Just weight) -> Just
( (priority, weight)
, (hostname, PortNumber $ fromIntegral port)
)
_ -> Nothing
_ -> Nothing
orderHosts :: [(PriorityWeight, HostPort)] -> [HostPort] orderHosts :: [(PriorityWeight, HostPort)] -> [HostPort]
orderHosts = map snd . sortBy (compare `on` fst) orderHosts = map snd . sortBy (compare `on` fst)

1
debian/changelog vendored
View file

@ -24,6 +24,7 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
the core dependencies. the core dependencies.
* Removed the feed build flag, which only adds feed to the core * Removed the feed build flag, which only adds feed to the core
dependencies. dependencies.
* Roll the dns build flag into the assistant build flag.
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400 -- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400

View file

@ -46,9 +46,6 @@ Flag Webapp
Flag Pairing Flag Pairing
Description: Enable pairing Description: Enable pairing
Flag DNS
Description: Enable the haskell DNS library for DNS lookup
Flag Production Flag Production
Description: Enable production build (slower build; faster binary) Description: Enable production build (slower build; faster binary)
@ -165,6 +162,7 @@ Executable git-annex
CPP-Options: -DWITH_WEBDAV CPP-Options: -DWITH_WEBDAV
if flag(Assistant) && ! os(solaris) if flag(Assistant) && ! os(solaris)
Build-Depends: dns
CPP-Options: -DWITH_ASSISTANT CPP-Options: -DWITH_ASSISTANT
if flag(Assistant) if flag(Assistant)
@ -223,10 +221,6 @@ Executable git-annex
if (! os(windows)) if (! os(windows))
Build-Depends: network-protocol-xmpp, gnutls (>= 0.1.4), xml-types Build-Depends: network-protocol-xmpp, gnutls (>= 0.1.4), xml-types
CPP-Options: -DWITH_XMPP CPP-Options: -DWITH_XMPP
if flag(DNS)
Build-Depends: dns
CPP-Options: -DWITH_DNS
if flag(TorrentParser) if flag(TorrentParser)
Build-Depends: torrent (>= 10000.0.0) Build-Depends: torrent (>= 10000.0.0)