[Pkg-haskell-commits] [tools] 03/07: Make SQL a CPP directive

Joachim Breitner nomeata at moszumanska.debian.org
Mon Sep 8 07:29:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

nomeata pushed a commit to branch master
in repository tools.

commit 0222d643a1261c03d39103f0f8b07435fa5773bc
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Aug 28 11:59:22 2014 -0700

    Make SQL a CPP directive
---
 binNMUs.hs | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/binNMUs.hs b/binNMUs.hs
index 2d3c33b..d8e0903 100644
--- a/binNMUs.hs
+++ b/binNMUs.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 import Text.Printf
 import Data.List
 import Data.List.Split
@@ -19,9 +21,11 @@ import Control.Arrow
 import qualified Data.ByteString.Char8 as B
 import Data.Time
 import Control.Lens
---import Control.Parallel.Strategies
+
+#ifdef SQL
 import Database.PostgreSQL.Simple hiding (Binary)
 import Database.PostgreSQL.Simple.Types (Query(Query)) 
+#endif
 
 import AcquireFile
 
@@ -241,10 +245,11 @@ fetchWannaBuild c | sql c     = fetchWannaBuildSQL c
 
 fetchWannaBuildSQL :: Conf -> Arch -> IO WBMap
 fetchWannaBuildSQL conf arch = do
-    unless q $ hPutStr stderr $ printf "Querying wanna-build database for  arch %s ..." arch
+#ifdef SQL
+    unless q $ hPutStr stderr $ printf "Querying wanna-build database for arch %s ..." arch
     unless q $ hFlush stderr
-    -- conn <- connectPostgreSQL (B.pack "service=projectb")
-    conn <- connect (ConnectInfo "localhost" 5436 "guest" "" "wanna-build")
+    conn <- connectPostgreSQL (B.pack "service=wanna-build")
+    --- conn <- connect (ConnectInfo "localhost" 5436 "guest" "" "wanna-build")
     rows <- query conn fetchWB [arch]
     close conn
     unless q $ hPutStrLn stderr " done"
@@ -268,6 +273,9 @@ fetchWB = Query $ B.pack $ "\
     \    architecture = ?  \
     \    AND distribution = 'sid' \
     \"
+#else
+    error "SQL disabled"
+#endif
 
 
 fetchWannaBuildHTTP :: Conf -> Arch -> IO WBMap
@@ -395,10 +403,11 @@ type Row = (String, String, String, String, String, B.ByteString, B.ByteString)
 
 acquirePackagesSQL :: Conf -> String -> Arch -> IO [Binary]
 acquirePackagesSQL conf suite arch = do
+#ifdef SQL
     unless q $ hPutStr stderr $ printf "Querying projectb database for suite %s arch %s ..." suite arch
     unless q $ hFlush stderr
-    -- conn <- connectPostgreSQL (B.pack "service=projectb")
-    conn <- connect (ConnectInfo "localhost" 5434 "guest" "" "projectb")
+    conn <- connectPostgreSQL (B.pack "service=projectb")
+    -- conn <- connect (ConnectInfo "localhost" 5434 "guest" "" "projectb")
     rows <- query conn fetchBins [suite, arch, r, r]
     close conn
     let bins = mapMaybe (rowToBinary conf) rows
@@ -433,6 +442,10 @@ fetchBins = Query $ B.pack $ "\
     \    AND (dm.value ~ ? OR pm.value ~ ? )    \
     \"
 
+#else
+    error "no SQL"
+#endif
+
 -- Option parsing
 data Conf = Conf
     { arches :: [Arch]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/tools.git



More information about the Pkg-haskell-commits mailing list