diff --git a/Tests.hs b/Tests.hs
--- a/Tests.hs
+++ b/Tests.hs
@@ -38,7 +38,7 @@
 import Debian.Policy (databaseDirectory, PackageArchitectures(All), PackagePriority(Extra), parseMaintainer, Section(MainSection), SourceFormat(Native3), StandardsVersion(..), getDebhelperCompatLevel, getDebianStandardsVersion, License(..))
 import Debian.Relation (BinPkgName(..), Relation(..), SrcPkgName(..), VersionReq(..))
 import Debian.Release (ReleaseName(ReleaseName, relName))
-import Debian.Version (parseDebianVersion, buildDebianVersion)
+import Debian.Version (parseDebianVersion', buildDebianVersion)
 import Distribution.Compiler (CompilerFlavor(GHC))
 import Distribution.Package (PackageName(PackageName))
 import Prelude hiding (log)
@@ -296,7 +296,7 @@
                 (debInfo . D.control . S.uploaders) .= [NameAddr {nameAddr_name = Just "Marco Silva", nameAddr_addr = "marcot@debian.org"},NameAddr {nameAddr_name = Just "Joachim Breitner", nameAddr_addr = "nomeata@debian.org"}]
                 (debInfo . D.control . S.priority) .= Just Extra
                 (debInfo . D.control . S.section) .= Just (MainSection "haskell")
-                (debInfo . D.control . S.buildDepends) %= (++ [[Rel (BinPkgName {unBinPkgName = "debhelper"}) (Just (GRE (Debian.Version.parseDebianVersion ("7" :: String)))) Nothing]])
+                (debInfo . D.control . S.buildDepends) %= (++ [[Rel (BinPkgName {unBinPkgName = "debhelper"}) (Just (GRE (Debian.Version.parseDebianVersion' ("7" :: String)))) Nothing]])
                 (debInfo . D.control . S.buildDependsIndep) %=  (++ [[Rel (BinPkgName {unBinPkgName = "perl"}) Nothing Nothing]])
                 (debInfo . D.control . S.standardsVersion) .= Just (StandardsVersion 3 9 4 Nothing)
                 (debInfo . D.control . S.vcsFields) %= Set.union (Set.fromList [ S.VCSBrowser "http://darcs.debian.org/cgi-bin/darcsweb.cgi?r=pkg-haskell/haskell-devscripts"
@@ -318,19 +318,19 @@
                      [ [Rel (BinPkgName {unBinPkgName = "dctrl-tools"}) Nothing Nothing]
                      , [Rel (BinPkgName {unBinPkgName = "debhelper"}) Nothing Nothing]
                      , [Rel (BinPkgName {unBinPkgName = "dh-buildinfo"}) Nothing Nothing]
-                     , [Rel (BinPkgName {unBinPkgName = "ghc"}) (Just (GRE (Debian.Version.parseDebianVersion ("7.6" :: String)))) Nothing]
+                     , [Rel (BinPkgName {unBinPkgName = "ghc"}) (Just (GRE (Debian.Version.parseDebianVersion'("7.6" :: String)))) Nothing]
                      , [Rel (BinPkgName {unBinPkgName = "cdbs"}) Nothing Nothing]
                      , [Rel (BinPkgName {unBinPkgName = "${misc:Depends}"}) Nothing Nothing]
                      , [Rel (BinPkgName {unBinPkgName = "html-xml-utils"}) Nothing Nothing]
-                     , [Rel (BinPkgName {unBinPkgName = "hscolour"}) (Just (GRE (Debian.Version.parseDebianVersion ("1.8" :: String)))) Nothing]
-                     , [Rel (BinPkgName {unBinPkgName = "ghc-haddock"}) (Just (GRE (Debian.Version.parseDebianVersion ("7.4" :: String)))) Nothing] ]
+                     , [Rel (BinPkgName {unBinPkgName = "hscolour"}) (Just (GRE (Debian.Version.parseDebianVersion'("1.8" :: String)))) Nothing]
+                     , [Rel (BinPkgName {unBinPkgName = "ghc-haddock"}) (Just (GRE (Debian.Version.parseDebianVersion'("7.4" :: String)))) Nothing] ]
 {-
                 control %= (\ y -> y { S.source = 
                                      , S.maintainer = Just (NameAddr {nameAddr_name = Just "Debian Haskell Group", nameAddr_addr = "pkg-haskell-maintainers@lists.alioth.debian.org"})
                                      , S.uploaders = [NameAddr {nameAddr_name = Just "Marco Silva", nameAddr_addr = "marcot@debian.org"},NameAddr {nameAddr_name = Just "Joachim Breitner", nameAddr_addr = "nomeata@debian.org"}]
                                      , S.priority = Just Extra
                                      , S.section = Just (MainSection "haskell")
-                                     , S.buildDepends = (S.buildDepends y) ++ [[Rel (BinPkgName {unBinPkgName = "debhelper"}) (Just (GRE (Debian.Version.parseDebianVersion ("7" :: String)))) Nothing]]
+                                     , S.buildDepends = (S.buildDepends y) ++ [[Rel (BinPkgName {unBinPkgName = "debhelper"}) (Just (GRE (Debian.Version.parseDebianVersion'("7" :: String)))) Nothing]]
                                      , S.buildDependsIndep = (S.buildDependsIndep y) ++ [[Rel (BinPkgName {unBinPkgName = "perl"}) Nothing Nothing]]
                                      , S.standardsVersion = Just (StandardsVersion 3 9 4 Nothing)
                                      , S.vcsFields = Set.union (S.vcsFields y) (Set.fromList [ S.VCSBrowser "http://darcs.debian.org/cgi-bin/darcsweb.cgi?r=pkg-haskell/haskell-devscripts"
@@ -358,12 +358,12 @@
                                                                                               [ [Rel (BinPkgName {unBinPkgName = "dctrl-tools"}) Nothing Nothing]
                                                                                               , [Rel (BinPkgName {unBinPkgName = "debhelper"}) Nothing Nothing]
                                                                                               , [Rel (BinPkgName {unBinPkgName = "dh-buildinfo"}) Nothing Nothing]
-                                                                                              , [Rel (BinPkgName {unBinPkgName = "ghc"}) (Just (GRE (Debian.Version.parseDebianVersion ("7.6" :: String)))) Nothing]
+                                                                                              , [Rel (BinPkgName {unBinPkgName = "ghc"}) (Just (GRE (Debian.Version.parseDebianVersion'("7.6" :: String)))) Nothing]
                                                                                               , [Rel (BinPkgName {unBinPkgName = "cdbs"}) Nothing Nothing]
                                                                                               , [Rel (BinPkgName {unBinPkgName = "${misc:Depends}"}) Nothing Nothing]
                                                                                               , [Rel (BinPkgName {unBinPkgName = "html-xml-utils"}) Nothing Nothing]
-                                                                                              , [Rel (BinPkgName {unBinPkgName = "hscolour"}) (Just (GRE (Debian.Version.parseDebianVersion ("1.8" :: String)))) Nothing]
-                                                                                              , [Rel (BinPkgName {unBinPkgName = "ghc-haddock"}) (Just (GRE (Debian.Version.parseDebianVersion ("7.4" :: String)))) Nothing] ]
+                                                                                              , [Rel (BinPkgName {unBinPkgName = "hscolour"}) (Just (GRE (Debian.Version.parseDebianVersion'("1.8" :: String)))) Nothing]
+                                                                                              , [Rel (BinPkgName {unBinPkgName = "ghc-haddock"}) (Just (GRE (Debian.Version.parseDebianVersion'("7.4" :: String)))) Nothing] ]
                                                                                             , B.recommends = []
                                                                                             , B.suggests = []
                                                                                             , B.preDepends = []
@@ -376,14 +376,14 @@
                                                                                             )
             atoms
       log = ChangeLog [Entry { logPackage = "haskell-devscripts"
-                             , logVersion = Debian.Version.parseDebianVersion ("0.8.13" :: String)
+                             , logVersion = Debian.Version.parseDebianVersion'("0.8.13" :: String)
                              , logDists = [ReleaseName {relName = "experimental"}]
                              , logUrgency = "low"
                              , logComments = "  [ Joachim Breitner ]\n  * Improve parsing of \"Setup register\" output, patch by David Fox\n  * Enable creation of hoogle files, thanks to Kiwamu Okabe for the\n    suggestion. \n\n  [ Kiwamu Okabe ]\n  * Need --html option to fix bug that --hoogle option don't output html file.\n  * Support to create /usr/lib/ghc-doc/hoogle/*.txt for hoogle package.\n\n  [ Joachim Breitner ]\n  * Symlink hoogle\8217s txt files to /usr/lib/ghc-doc/hoogle/\n  * Bump ghc dependency to 7.6 \n  * Bump standards version\n"
                              , logWho = "Joachim Breitner <nomeata@debian.org>"
                              , logDate = "Mon, 08 Oct 2012 21:14:50 +0200" },
                        Entry { logPackage = "haskell-devscripts"
-                             , logVersion = Debian.Version.parseDebianVersion ("0.8.12" :: String)
+                             , logVersion = Debian.Version.parseDebianVersion'("0.8.12" :: String)
                              , logDists = [ReleaseName {relName = "unstable"}]
                              , logUrgency = "low"
                              , logComments = "  * Depend on ghc >= 7.4, adjusting to its haddock --interface-version\n    behaviour.\n"
@@ -654,7 +654,7 @@
                    , "AlexWrapper-strict-bytestring"]
              (debInfo . D.control . S.homepage) .= Just "http://www.haskell.org/alex/"
              (debInfo . D.sourceFormat) .= Native3
-             (debInfo . D.debVersion) .= Just (parseDebianVersion ("3.0.2-1~hackage1" :: String))
+             (debInfo . D.debVersion) .= Just (parseDebianVersion'("3.0.2-1~hackage1" :: String))
              doExecutable (BinPkgName "alex")
                           (D.InstallFile {D.execName = "alex", D.destName = "alex", D.sourceDir = Nothing, D.destDir = Nothing})
              -- Bootstrap self-dependency
diff --git a/cabal-debian.cabal b/cabal-debian.cabal
--- a/cabal-debian.cabal
+++ b/cabal-debian.cabal
@@ -1,5 +1,5 @@
 Name:           cabal-debian
-Version:        4.31.4
+Version:        4.31.6
 Copyright:      Copyright (c) 2007-2014, David Fox, Jeremy Shaw
 License:        BSD3
 License-File:   LICENSE
@@ -148,12 +148,11 @@
 
 Flag tests
   Description: enable the unit test executable (disabled by default because it has a lot of wacky dependencies.)
-  Default: False
-  Manual: True
+  Default: True
 
 flag local-debian
   Description: Link directly to the source of the debian library
-  Default: False
+  Default: True
   Manual: True
 
 flag pretty-112
@@ -286,7 +285,7 @@
     Other-Modules:
       Debian.Version.Internal
   else
-    Build-depends: debian >= 3.87
+    Build-depends: debian >= 3.89
 
 Executable cabal-debian
   Hs-Source-Dirs: .
@@ -298,17 +297,19 @@
   else
     Build-Depends: pretty < 1.1.2, prettyclass
   if !flag(local-debian)
-    Build-Depends: debian >= 3.87
+    Build-Depends: debian >= 3.89
 
 Test-Suite cabal-debian-tests
+  if !flag(tests)
+    Buildable: False
   Type: exitcode-stdio-1.0
   Hs-Source-Dirs: .
   Main-is: Tests.hs
   ghc-options: -threaded -Wall -O2
-  Build-Depends: base >= 4.7.0.0, cabal-debian, Cabal >= 1.18, containers, Diff >= 0.3.1, directory, filepath, hsemail, HUnit, lens, process, text
+  Build-Depends: base >= 4.8.1.0, cabal-debian, Cabal >= 1.18, containers, Diff >= 0.3.1, directory, filepath, hsemail, HUnit, lens, process, text
   if flag(pretty-112)
     Build-Depends: pretty >= 1.1.2
   else
     Build-Depends: pretty < 1.1.2, prettyclass
   if !flag(local-debian)
-    Build-Depends: debian >= 3.87
+    Build-Depends: debian >= 3.89
diff --git a/debian-haskell/Debian/Apt/Dependencies.hs b/debian-haskell/Debian/Apt/Dependencies.hs
--- a/debian-haskell/Debian/Apt/Dependencies.hs
+++ b/debian-haskell/Debian/Apt/Dependencies.hs
@@ -16,13 +16,14 @@
 import Control.Arrow (second)
 import qualified Data.ByteString.Char8 as C
 import Data.List as List (find, union)
-import Data.Tree(Tree(rootLabel, Node))
-import Debian.Apt.Package(PackageNameMap, packageNameMap, lookupPackageByRel)
-import Debian.Control.ByteString(ControlFunctions(stripWS, lookupP, parseControlFromFile),
-                                 Field'(Field, Comment), Control'(Control), Paragraph, Control)
+import Data.Tree (Tree(rootLabel, Node))
+import Debian.Apt.Package (PackageNameMap, packageNameMap, lookupPackageByRel)
+import Debian.Control.ByteString (ControlFunctions(stripWS, lookupP, parseControlFromFile),
+                                  Field'(Field, Comment), Control'(Control), Paragraph, Control)
 import Debian.Relation (BinPkgName(..))
-import Debian.Relation.ByteString(ParseRelations(..), Relation(..), OrRelation, AndRelation, Relations, checkVersionReq)
-import Debian.Version(DebianVersion, parseDebianVersion, prettyDebianVersion)
+import Debian.Relation.ByteString (ParseRelations(..), Relation(..), OrRelation, AndRelation, Relations, checkVersionReq)
+import Debian.Version (DebianVersion, parseDebianVersion, prettyDebianVersion)
+import Debian.Version.ByteString ()
 import Text.PrettyPrint (render)
 
 -- * Basic CSP Types and Functions
@@ -113,7 +114,10 @@
       (Just (Field (_, name))) ->
           case lookupP "Version" p of
             Nothing -> error $ "Paragraph missing Version field"
-            (Just (Field (_, version))) -> (BinPkgName (C.unpack (stripWS name)), parseDebianVersion (C.unpack version))
+            (Just (Field (_, str))) ->
+                case parseDebianVersion str of
+                  Right ver -> (BinPkgName (C.unpack (stripWS name)), ver)
+                  Left e -> error $ "packageVersionParagraph: " ++ show e
             (Just (Comment _)) -> error "packageVersionParagraph"
       (Just (Comment _)) -> error "packageVersionParagraph"
 
diff --git a/debian-haskell/Debian/Changes.hs b/debian-haskell/Debian/Changes.hs
--- a/debian-haskell/Debian/Changes.hs
+++ b/debian-haskell/Debian/Changes.hs
@@ -209,7 +209,7 @@
       x | mrSubList x == [] -> Left ["Parse error in " ++ show text]
       MR {mrAfter = after, mrSubList = [_, name, ver, dists, urgency, _, details, _, _, who, _, date, _]} ->
           Right (Entry name
-                         (parseDebianVersion ver)
+                         (parseDebianVersion' ver)
                          (map parseReleaseName . words $ dists)
                          urgency
                          ("  " ++ unpack (strip (pack details)) ++ "\n")
@@ -251,7 +251,7 @@
       MR {mrSubList = []} -> Nothing
       MR {mrSubList = [_, name, ver, dists, urgency, _, details]} ->
           Just $ Entry name
-                       (parseDebianVersion ver)
+                       (parseDebianVersion' ver)
                        (map parseReleaseName . words $ dists)
                        urgency
                        details
diff --git a/debian-haskell/Debian/Control/Text.hs b/debian-haskell/Debian/Control/Text.hs
--- a/debian-haskell/Debian/Control/Text.hs
+++ b/debian-haskell/Debian/Control/Text.hs
@@ -29,7 +29,7 @@
 import qualified Data.ByteString.Char8 as B
 import Data.Char (toLower, chr)
 import Data.List (find)
-import qualified Data.Text as T (Text, pack, unpack, map, strip, reverse)
+import qualified Data.Text as T (Text, pack, unpack, map, dropAround, reverse)
 import Data.Text.Encoding (decodeUtf8With, encodeUtf8)
 --import Data.Text.IO as T (readFile)
 import qualified Debian.Control.ByteString as B
@@ -92,7 +92,8 @@
         where hasFieldName :: String -> Field' T.Text -> Bool
               hasFieldName name (Field (fieldName',_)) = T.pack name == T.map toLower fieldName'
               hasFieldName _ _ = False
-    stripWS = T.strip
+    stripWS = T.dropAround (`elem` (" \t" :: String))
+      -- T.strip would also strip newlines
     protectFieldText = protectFieldText'
     asString = T.unpack
 
diff --git a/debian-haskell/Debian/GenBuildDeps.hs b/debian-haskell/Debian/GenBuildDeps.hs
--- a/debian-haskell/Debian/GenBuildDeps.hs
+++ b/debian-haskell/Debian/GenBuildDeps.hs
@@ -27,18 +27,20 @@
 import           Control.Applicative ((<$>))
 #endif
 import           Control.Exception (throw)
-import           Control.Monad (filterM)
+import           Control.Monad (filterM, foldM)
+import           Control.Monad.State (evalState, get, modify, State)
 import           Data.Graph (Graph, Edge, Vertex, buildG, topSort, reachable, transposeG, edges, scc)
-import           Data.List
-import qualified Data.Map as Map
+import           Data.List as List (elemIndex, find, map, nub, partition, tails)
+import           Data.Map as Map (empty, findWithDefault, fromList, insert, Map, lookup)
 import           Data.Maybe
-import qualified Data.Set as Set
+import           Data.Set as Set (fromList, intersection, null, Set)
 import           Data.Tree as Tree (Tree(Node, rootLabel, subForest))
 import           Debian.Control (parseControlFromFile)
 import           Debian.Control.Policy (HasDebianControl, DebianControl, ControlFileError(..), validateDebianControl, debianSourcePackageName, debianBinaryPackageNames, debianBuildDeps, debianBuildDepsIndep)
 import           Debian.Loc (__LOC__)
 import           Debian.Relation
 import           Debian.Relation.Text ()
+-- import           Debug.Trace (trace)
 import           System.Directory (getDirectoryContents, doesFileExist)
 
 -- | This type describes the build dependencies of a source package.
@@ -46,6 +48,8 @@
       sourceName :: SrcPkgName          -- ^ source package name
     , relations :: Relations            -- ^ dependency relations
     , binaryNames :: [BinPkgName]       -- ^ binary dependency names (is this a function of relations?)
+    , depSet :: Set.Set BinPkgName          -- ^ Set containing all binary package names mentioned in relations
+    , binSet :: Set.Set BinPkgName          -- ^ Set containing binaryNames
     } deriving Show
 
 instance Eq DepInfo where
@@ -58,10 +62,14 @@
 -- <http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles>
 buildDependencies :: HasDebianControl control => control -> DepInfo
 buildDependencies control = do
+  let rels = concat [fromMaybe [] (debianBuildDeps control),
+                     fromMaybe [] (debianBuildDepsIndep control)]
+      bins = debianBinaryPackageNames control
   DepInfo { sourceName = debianSourcePackageName control
-          , relations = concat [fromMaybe [] (debianBuildDeps control),
-                                fromMaybe [] (debianBuildDepsIndep control)]
-          , binaryNames = debianBinaryPackageNames control }
+          , relations = rels
+          , binaryNames = bins
+          , depSet = Set.fromList (List.map (\(Rel x _ _) -> x) (concat rels))
+          , binSet = Set.fromList bins }
 
 -- | source package name
 sourceName' :: HasDebianControl control => control -> SrcPkgName
@@ -94,7 +102,7 @@
 -- |Remove any dependencies that are designated \"relaxed\" by relaxInfo.
 relaxDeps :: RelaxInfo -> [DepInfo] -> [DepInfo]
 relaxDeps relaxInfo deps =
-    map relaxDep deps
+    List.map relaxDep deps
     where
       relaxDep :: DepInfo -> DepInfo
       relaxDep info = info {relations = filteredDependencies}
@@ -103,7 +111,7 @@
             -- this results in an empty list in an or-dep the entire dependency can
             -- be discarded.
             filteredDependencies :: Relations
-            filteredDependencies = filter (/= []) (map (filter keepDep) (relations info))
+            filteredDependencies = filter (/= []) (List.map (filter keepDep) (relations info))
             keepDep :: Relation -> Bool
             keepDep (Rel name _ _) = not (relaxInfo (sourceName info) name)
 
@@ -130,25 +138,26 @@
 buildable :: forall a. (a -> DepInfo) -> [a] -> BuildableInfo a
 buildable relax packages =
     -- Find all packages which can't reach any other packages in the
-    -- graph of the "has build dependency" relation.
+    -- graph of the "has build dependency" relation on the
+    -- yet-to-be-built packages
     case partition (\ x -> reachable hasDep x == [x]) verts of
       -- None of the packages are buildable, return information
       -- about how to break this build dependency cycle.
-      ([], _) -> CycleInfo {depPairs = map ofEdge $ head $ (allCycles hasDep)}
+      ([], _) -> CycleInfo {depPairs = List.map ofEdge $ head $ (allCycles hasDep)}
       -- We have some buildable packages, return them along with
       -- the list of packages each one directly blocks
       (allReady, blocked) ->
-          BuildableInfo { readyTargets = map (makeReady blocked allReady) allReady
-                        , allBlocked = map ofVertex blocked }
+          BuildableInfo { readyTargets = List.map (makeReady blocked allReady) allReady
+                        , allBlocked = List.map ofVertex blocked }
     where
       makeReady :: [Vertex] -> [Vertex] -> Vertex -> ReadyTarget a
       makeReady blocked ready thisReady =
           let otherReady = filter (/= thisReady) ready
               (directlyBlocked, otherBlocked) = partition (\ x -> elem x (reachable isDep thisReady)) blocked in
           ReadyTarget { ready = ofVertex thisReady
-                      , waiting = map ofVertex directlyBlocked
-                      , other = map ofVertex (otherReady ++ otherBlocked) }
-      --allDeps x = (ofVertex x, map ofVertex (filter (/= x) (reachable hasDep x)))
+                      , waiting = List.map ofVertex directlyBlocked
+                      , other = List.map ofVertex (otherReady ++ otherBlocked) }
+      --allDeps x = (ofVertex x, List.map ofVertex (filter (/= x) (reachable hasDep x)))
       isDep :: Graph
       isDep = transposeG hasDep
       hasDep :: Graph
@@ -156,16 +165,37 @@
 
       hasDepEdges :: [(Int, Int)]
       hasDepEdges =
+#if 0
           nub (foldr f [] (tails vertPairs))
           where f :: [(Int, DepInfo)] -> [(Int, Int)] -> [(Int, Int)]
                 f [] es = es
-                f (x : xs) es = catMaybes (map (toEdge x) xs) ++ es
+                f (x : xs) es = catMaybes (List.map (toEdge x) xs) ++ es
                 toEdge :: (Int, DepInfo) -> (Int, DepInfo) -> Maybe Edge
                 toEdge (xv, xa) (yv, ya) =
                     case compareSource xa ya of
                       EQ -> Nothing
                       LT -> Just (yv, xv)
                       GT -> Just (xv, yv)
+#else
+          nub (evalState (foldM f [] (tails vertPairs)) Map.empty)
+          where f :: [(Int, Int)] -> [(Int, DepInfo)] -> State (Map.Map (Int, Int) Ordering) [(Int, Int)]
+                f es [] = return es
+                f es (x : xs) = mapM (toEdge x) xs >>= \es' -> return (catMaybes es' ++ es)
+                toEdge :: (Int, DepInfo) -> (Int, DepInfo) -> State (Map.Map (Int, Int) Ordering) (Maybe Edge)
+                toEdge (xv, xa) (yv, ya) = do
+                  mp <- get
+                  r <- case Map.lookup (xv, yv) mp of
+                         Just r' -> return r'
+                         Nothing -> do
+                           let r' = compareSource xa ya
+                           -- trace ("compareSource " ++ show (unSrcPkgName $ sourceName xa) ++ " " ++ show (unSrcPkgName $ sourceName ya) ++ " -> " ++ show r') (return ())
+                           modify (Map.insert (xv, yv) r')
+                           return r'
+                  case r of
+                    EQ -> return Nothing
+                    LT -> return $ Just (yv, xv)
+                    GT -> return $ Just (xv, yv)
+#endif
       ofEdge :: Edge -> (a, a)
       ofEdge (a, b) = (ofVertex a, ofVertex b)
       ofVertex :: Int -> a
@@ -242,13 +272,19 @@
 -- a pretty simplistic approach to 'or' build depends. However, I
 -- think this should work pretty nicely in practice.
 compareSource :: DepInfo -> DepInfo -> Ordering
-compareSource (DepInfo {relations = depends1, binaryNames = bins1}) (DepInfo {relations = depends2, binaryNames = bins2})
-    | any (\rel -> isJust (find (checkPackageNameReq rel) bins2)) (concat depends1) = GT
-    | any (\rel -> isJust (find (checkPackageNameReq rel) bins1)) (concat depends2) = LT
+compareSource p1 p2
+#if 0
+    | any (\rel -> isJust (find (checkPackageNameReq rel) (binaryNames p2))) (concat (relations p1)) = GT
+    | any (\rel -> isJust (find (checkPackageNameReq rel) (binaryNames p1))) (concat (relations p2)) = LT
     | otherwise = EQ
     where
       checkPackageNameReq :: Relation -> BinPkgName -> Bool
       checkPackageNameReq (Rel rPkgName _ _) bPkgName = rPkgName == bPkgName
+#else
+    | not (Set.null (Set.intersection (depSet p1) (binSet p2))) = GT
+    | not (Set.null (Set.intersection (depSet p2) (binSet p1))) = LT
+    | otherwise = EQ
+#endif
 
 compareSource' :: HasDebianControl control => control -> control -> Ordering
 compareSource' control1 control2
diff --git a/debian-haskell/Debian/Relation/String.hs b/debian-haskell/Debian/Relation/String.hs
--- a/debian-haskell/Debian/Relation/String.hs
+++ b/debian-haskell/Debian/Relation/String.hs
@@ -84,7 +84,7 @@
        ver <- many1 (noneOf [' ',')','\t','\n'])
        skipMany whiteChar
        char ')'
-       return $ Just (op (parseDebianVersion ver))
+       return $ Just (op (parseDebianVersion' ver))
     <|>
     do return $ Nothing
 
diff --git a/debian-haskell/Debian/Report.hs b/debian-haskell/Debian/Report.hs
--- a/debian-haskell/Debian/Report.hs
+++ b/debian-haskell/Debian/Report.hs
@@ -40,7 +40,7 @@
 
 -- |extract the version number from a control paragraph
 extractVersion :: Paragraph -> Maybe DebianVersion
-extractVersion paragraph = fmap (parseDebianVersion . unpack)  $ fieldValue "Version" paragraph
+extractVersion paragraph = fmap (parseDebianVersion' . unpack)  $ fieldValue "Version" paragraph
 
 -- * Trump Report
 
diff --git a/debian-haskell/Debian/Version.hs b/debian-haskell/Debian/Version.hs
--- a/debian-haskell/Debian/Version.hs
+++ b/debian-haskell/Debian/Version.hs
@@ -4,6 +4,7 @@
     (DebianVersion -- |Exported abstract because the internal representation is likely to change
     , prettyDebianVersion
     , parseDebianVersion
+    , parseDebianVersion'
     , epoch
     , version
     , revision
diff --git a/debian-haskell/Debian/Version/ByteString.hs b/debian-haskell/Debian/Version/ByteString.hs
--- a/debian-haskell/Debian/Version/ByteString.hs
+++ b/debian-haskell/Debian/Version/ByteString.hs
@@ -14,5 +14,5 @@
     parseDebianVersion byteStr =
         let str = C.unpack byteStr in
         case parse parseDV str str of
-          Left e -> error (show e)
-          Right dv -> DebianVersion str dv
+          Left e -> Left e
+          Right dv -> Right (DebianVersion str dv)
diff --git a/debian-haskell/Debian/Version/Common.hs b/debian-haskell/Debian/Version/Common.hs
--- a/debian-haskell/Debian/Version/Common.hs
+++ b/debian-haskell/Debian/Version/Common.hs
@@ -6,6 +6,7 @@
     ( DebianVersion -- |Exported abstract because the internal representation is likely to change
     , prettyDebianVersion
     , ParseDebianVersion(..)
+    , parseDebianVersion'
     , evr               -- DebianVersion -> (Maybe Int, String, Maybe String)
     , epoch
     , version
@@ -94,11 +95,14 @@
 -- * Parser
 
 class ParseDebianVersion a where
-    parseDebianVersion :: a-> DebianVersion
+    parseDebianVersion :: a-> Either ParseError DebianVersion
 -- |Convert a string to a debian version number. May throw an
 -- exception if the string is unparsable -- but I am not sure if that
 -- can currently happen. Are there any invalid version strings?
 -- Perhaps ones with underscore, or something?
+
+parseDebianVersion' :: ParseDebianVersion string => string -> DebianVersion
+parseDebianVersion' str = either (\e -> error (show e)) id (parseDebianVersion str)
 
 {-
 showNN :: NonNumeric -> String
diff --git a/debian-haskell/Debian/Version/Internal.hs b/debian-haskell/Debian/Version/Internal.hs
--- a/debian-haskell/Debian/Version/Internal.hs
+++ b/debian-haskell/Debian/Version/Internal.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts #-}
 module Debian.Version.Internal
     ( DebianVersion(..)
     , Numeric(..)
diff --git a/debian-haskell/Debian/Version/String.hs b/debian-haskell/Debian/Version/String.hs
--- a/debian-haskell/Debian/Version/String.hs
+++ b/debian-haskell/Debian/Version/String.hs
@@ -13,13 +13,13 @@
 instance ParseDebianVersion String where
     parseDebianVersion str =
         case parse parseDV str str of
-          Left e -> error (show e)
-          Right dv -> DebianVersion str dv
-
+          Left e -> Left e
+          Right dv -> Right (DebianVersion str dv)
+ 
 instance Read DebianVersion where
     readsPrec _ s =
         case stripPrefix "Debian.Version.parseDebianVersion " s of
           Just s' -> case reads s' :: [(String, String)] of
                        []-> []
-                       (v, s'') : _ -> [(parseDebianVersion v, s'')]
+                       (v, s'') : _ -> [(parseDebianVersion' v, s'')]
           Nothing -> []
diff --git a/debian-haskell/Debian/Version/Text.hs b/debian-haskell/Debian/Version/Text.hs
--- a/debian-haskell/Debian/Version/Text.hs
+++ b/debian-haskell/Debian/Version/Text.hs
@@ -14,5 +14,5 @@
     parseDebianVersion text =
         let str = T.unpack text in
         case parse parseDV str str of
-          Left e -> error (show e)
-          Right dv -> DebianVersion str dv
+          Left e -> Left e
+          Right dv -> Right (DebianVersion str dv)
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+haskell-cabal-debian (4.31.6) unstable; urgency=low
+
+  * Signature change in Debian.Version.parseDebianVersion
+
+ -- David Fox <dsf@seereason.com>  Tue, 22 Sep 2015 06:56:28 -0700
+
+haskell-cabal-debian (4.31.5) unstable; urgency=low
+
+  * If there is no Setup.hs or Setup.lhs file we cannot build
+    debian/hlibrary.setup, therefore we should set DEB_SETUP_BIN_NAME to
+    "cabal".
+
+ -- David Fox <dsf@seereason.com>  Thu, 17 Sep 2015 08:21:46 -0700
+
 haskell-cabal-debian (4.31.4) unstable; urgency=low
 
   * The test suite was failing during the debian package build because
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -23,8 +23,8 @@
  libghc-bifunctors-prof,
  libghc-data-default-dev,
  libghc-data-default-prof,
- libghc-debian-dev (>= 3.87),
- libghc-debian-prof (>= 3.87),
+ libghc-debian-dev (>= 3.89),
+ libghc-debian-prof (>= 3.89),
  libghc-exceptions-dev,
  libghc-exceptions-prof,
  libghc-hsemail-dev,
diff --git a/src/Debian/Debianize/BuildDependencies.hs b/src/Debian/Debianize/BuildDependencies.hs
--- a/src/Debian/Debianize/BuildDependencies.hs
+++ b/src/Debian/Debianize/BuildDependencies.hs
@@ -29,7 +29,7 @@
 import Debian.Orphans ()
 import Debian.Relation (BinPkgName(..), checkVersionReq, Relation(..), Relations)
 import qualified Debian.Relation as D (BinPkgName(BinPkgName), Relation(..), Relations, VersionReq(EEQ, GRE, LTE, SGR, SLT))
-import Debian.Version (DebianVersion, parseDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion')
 import Distribution.Compiler (CompilerFlavor(..))
 import Distribution.Package (Dependency(..), PackageName(PackageName))
 import Distribution.PackageDescription (PackageDescription)
@@ -133,8 +133,8 @@
        prof <- not <$> use (A.debInfo . D.noProfilingLibrary)
        official <- use (A.debInfo . D.official)
        compat <- use (A.debInfo . D.compat)
-       let xs = nub $ [maybe [] (\ n -> [D.Rel (D.BinPkgName "debhelper") (Just (D.GRE (parseDebianVersion (show n)))) Nothing]) compat,
-                       [D.Rel (D.BinPkgName "haskell-devscripts") (Just $ D.GRE $ parseDebianVersion $ if official then "0.9" else "0.8" :: String) Nothing],
+       let xs = nub $ [maybe [] (\ n -> [D.Rel (D.BinPkgName "debhelper") (Just (D.GRE (parseDebianVersion' (show n)))) Nothing]) compat,
+                       [D.Rel (D.BinPkgName "haskell-devscripts") (Just $ D.GRE $ parseDebianVersion' $ if official then "0.9" else "0.8" :: String) Nothing],
                        anyrel "cdbs"] ++
                       (if member GHC hcs
                        then [anyrel' (compilerPackageName GHC B.Development)] ++ if prof then [anyrel' (compilerPackageName GHC B.Profiling)] else []
@@ -385,10 +385,10 @@
 debianVersion' :: Monad m => PackageName -> Version -> CabalT m DebianVersion
 debianVersion' name v =
     do atoms <- get
-       return $ parseDebianVersion (maybe "" (\ n -> show n ++ ":") (Map.lookup name (view A.epochMap atoms)) ++ showVersion v)
+       return $ parseDebianVersion' (maybe "" (\ n -> show n ++ ":") (Map.lookup name (view A.epochMap atoms)) ++ showVersion v)
 
 debianVersion'' :: CabalInfo -> PackageName -> Version -> DebianVersion
-debianVersion'' atoms name v = parseDebianVersion (maybe "" (\ n -> show n ++ ":") (Map.lookup name (view A.epochMap atoms)) ++ showVersion v)
+debianVersion'' atoms name v = parseDebianVersion' (maybe "" (\ n -> show n ++ ":") (Map.lookup name (view A.epochMap atoms)) ++ showVersion v)
 
 data Rels a = And {unAnd :: [Rels a]} | Or {unOr :: [Rels a]} | Rel' {unRel :: a} deriving Show
 
diff --git a/src/Debian/Debianize/Bundled.hs b/src/Debian/Debianize/Bundled.hs
--- a/src/Debian/Debianize/Bundled.hs
+++ b/src/Debian/Debianize/Bundled.hs
@@ -30,7 +30,7 @@
 import Debian.GHC ()
 import Debian.Relation (BinPkgName(..))
 import Debian.Relation.ByteString ()
-import Debian.Version (DebianVersion, parseDebianVersion, prettyDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion', prettyDebianVersion)
 import Distribution.Package (PackageIdentifier(..), PackageName(..))
 import Distribution.Simple.Compiler (CompilerFlavor(..))
 import System.IO.Unsafe (unsafePerformIO)
@@ -95,7 +95,7 @@
     hcs'
     where
       doHCVersion :: [String] -> (DebianVersion, [BinPkgName])
-      doHCVersion (versionString : "-" : deps) = (parseDebianVersion versionString, map BinPkgName deps)
+      doHCVersion (versionString : "-" : deps) = (parseDebianVersion' versionString, map BinPkgName deps)
       doHCVersion x = error $ "Unexpected output from apt-cache: " ++ show x
 
 aptCacheDepends :: FilePath -> String -> String -> Either SomeException String
@@ -115,7 +115,7 @@
 
 aptVersions :: FilePath -> String -> [DebianVersion]
 aptVersions root hcname =
-    either (\ _ -> []) (map parseDebianVersion . filter (/= "") . map (takeWhile (/= ' ')) . takeWhile (not . isPrefixOf "Reverse Depends:") . drop 1 . dropWhile (not . isPrefixOf "Versions:") . lines) (aptCacheShowPkg root hcname)
+    either (\ _ -> []) (map parseDebianVersion' . filter (/= "") . map (takeWhile (/= ' ')) . takeWhile (not . isPrefixOf "Reverse Depends:") . drop 1 . dropWhile (not . isPrefixOf "Versions:") . lines) (aptCacheShowPkg root hcname)
 
 takeBetween :: (a -> Bool) -> (a -> Bool) -> [a] -> [a]
 takeBetween startPred endPred = takeWhile (not . endPred) . dropWhile startPred . dropWhile (not . startPred)
diff --git a/src/Debian/Debianize/DebianName.hs b/src/Debian/Debianize/DebianName.hs
--- a/src/Debian/Debianize/DebianName.hs
+++ b/src/Debian/Debianize/DebianName.hs
@@ -25,7 +25,7 @@
 import Debian.Orphans ()
 import Debian.Relation (PkgName(..), Relations)
 import qualified Debian.Relation as D (VersionReq(EEQ))
-import Debian.Version (parseDebianVersion)
+import Debian.Version (parseDebianVersion')
 import Distribution.Compiler (CompilerFlavor(..))
 import Distribution.Package (Dependency(..), PackageIdentifier(..), PackageName(PackageName))
 import qualified Distribution.PackageDescription as Cabal (PackageDescription(package))
@@ -59,7 +59,7 @@
        let pkgId = Cabal.package pkgDesc
        nameMap <- use A.debianNameMap
        let pname@(PackageName _) = pkgName pkgId
-           version = (Just (D.EEQ (parseDebianVersion (showVersion (pkgVersion pkgId)))))
+           version = (Just (D.EEQ (parseDebianVersion' (showVersion (pkgVersion pkgId)))))
        case (nameBase, Map.lookup (pkgName pkgId) nameMap) of
          (Just base, _) -> return base
          (Nothing, Nothing) -> return $ debianBaseName pname
diff --git a/src/Debian/Debianize/Finalize.hs b/src/Debian/Debianize/Finalize.hs
--- a/src/Debian/Debianize/Finalize.hs
+++ b/src/Debian/Debianize/Finalize.hs
@@ -44,7 +44,7 @@
 import qualified Debian.Relation as D (BinPkgName(BinPkgName), Relation(..))
 import Debian.Release (parseReleaseName)
 import Debian.Time (getCurrentLocalRFC822Time)
-import qualified Debian.Version as V (buildDebianVersion, DebianVersion, parseDebianVersion, epoch, version, revision)
+import qualified Debian.Version as V (buildDebianVersion, DebianVersion, parseDebianVersion', epoch, version, revision)
 import Distribution.Compiler (CompilerFlavor(GHC))
 #if MIN_VERSION_Cabal(1,22,0)
 import Distribution.Compiler (CompilerFlavor(GHCJS))
@@ -53,6 +53,7 @@
 import Distribution.PackageDescription as Cabal (allBuildInfo, author, BuildInfo(buildable, extraLibs), Executable(buildInfo, exeName), FlagName(FlagName), maintainer, PackageDescription(testSuites))
 import qualified Distribution.PackageDescription as Cabal (PackageDescription(dataFiles, executables, library, package))
 import Prelude hiding (init, log, map, unlines, unlines, writeFile)
+import System.Directory (doesFileExist)
 import System.FilePath ((<.>), (</>), makeRelative, splitFileName, takeDirectory, takeFileName)
 import System.IO (hPutStrLn, stderr)
 import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr(..))
@@ -75,7 +76,8 @@
     do date <- liftIO getCurrentLocalRFC822Time
        currentUser <- liftIO getCurrentDebianUser
        debhelperCompat <- liftIO getDebhelperCompatLevel
-       finalizeDebianization' date currentUser debhelperCompat
+       setupExists <- or <$> mapM (liftIO . doesFileExist) ["Setup.hs", "Setup.lhs"]
+       finalizeDebianization' date currentUser debhelperCompat setupExists
        vb <- use (A.debInfo . D.flags . verbosity)
        when (vb >= 3) (get >>= \ x -> liftIO (putStrLn ("\nFinalized Cabal Info: " ++ show x ++ "\n")))
        either (\e -> liftIO $ hPutStrLn stderr ("WARNING: " ++ e)) (\_ -> return ()) =<< use (A.debInfo . D.control . S.maintainer)
@@ -88,8 +90,8 @@
 -- this function is not idempotent.  (Exported for use in unit tests.)
 -- FIXME: we should be able to run this without a PackageDescription, change
 --        paramter type to Maybe PackageDescription and propagate down thru code
-finalizeDebianization'  :: (Monad m, Functor m) => String -> Maybe NameAddr -> Maybe Int -> CabalT m ()
-finalizeDebianization' date currentUser debhelperCompat =
+finalizeDebianization'  :: (Monad m, Functor m) => String -> Maybe NameAddr -> Maybe Int -> Bool -> CabalT m ()
+finalizeDebianization' date currentUser debhelperCompat setupExists =
     do -- In reality, hcs must be a singleton or many things won't work.  But some day...
        hc <- use (A.debInfo . D.flags . compilerFlavor)
        pkgDesc <- use A.packageDescription
@@ -100,6 +102,9 @@
          (True, D.TestsRun) -> (A.debInfo . D.rulesSettings) %= (++ ["DEB_ENABLE_TESTS = yes"])
          (True, D.TestsBuild) -> (A.debInfo . D.rulesSettings) %= (++ ["DEB_ENABLE_TESTS = yes", "DEB_BUILD_OPTIONS += nocheck"])
          _ -> return ()
+       case setupExists of
+         False -> (A.debInfo . D.rulesSettings) %= (++ ["DEB_SETUP_BIN_NAME = cabal"])
+         _ -> return ()
 
        finalizeSourceName B.HaskellSource
        checkOfficialSettings hc
@@ -157,7 +162,7 @@
 debianVersion :: (Monad m, Functor m) => CabalT m V.DebianVersion
 debianVersion =
     do cabalName <- (pkgName . Cabal.package) <$> use A.packageDescription
-       (cabalVersion :: V.DebianVersion) <- (V.parseDebianVersion . ppShow . pkgVersion . Cabal.package) <$> use A.packageDescription
+       (cabalVersion :: V.DebianVersion) <- (V.parseDebianVersion' . ppShow . pkgVersion . Cabal.package) <$> use A.packageDescription
        cabalEpoch <- debianEpoch cabalName
        fmt <- use (A.debInfo . D.sourceFormat)
        cabalRevision <-
@@ -182,12 +187,12 @@
          _ | isJust versionArg -> return $ fromJust versionArg
          _ | isJust debVersion ->
                case (V.epoch (fromJust debVersion),
-                     V.parseDebianVersion (V.version (fromJust debVersion)),
+                     V.parseDebianVersion' (V.version (fromJust debVersion)),
                      V.revision (fromJust debVersion)) of
                  (debEpoch, debianVersion', (debianRevision :: Maybe String)) ->
                      let finalEpoch = max debEpoch cabalEpoch
                          finalVersion = max debianVersion' cabalVersion
-                         (finalRevision :: Maybe String) = maximumBy (compare `on` fmap V.parseDebianVersion) [debianRevision, cabalRevision] in
+                         (finalRevision :: Maybe String) = maximumBy (compare `on` fmap V.parseDebianVersion') [debianRevision, cabalRevision] in
                      return $ V.buildDebianVersion finalEpoch (ppShow finalVersion) finalRevision
          _ -> return $ V.buildDebianVersion cabalEpoch (ppShow cabalVersion) cabalRevision
 
diff --git a/src/Debian/Debianize/Optparse.hs b/src/Debian/Debianize/Optparse.hs
--- a/src/Debian/Debianize/Optparse.hs
+++ b/src/Debian/Debianize/Optparse.hs
@@ -31,7 +31,7 @@
 import Debian.Debianize.VersionSplits
 import Debian.Policy
 import Debian.Relation
-import Debian.Version.Common (DebianVersion, parseDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion')
 import Distribution.Compiler (CompilerFlavor(..))
 import Distribution.Package (PackageName(..))
 import Distribution.PackageDescription (FlagName(FlagName))
@@ -302,7 +302,7 @@
     ]
 
 debianVersionP :: O.Parser (Maybe DebianVersion)
-debianVersionP = O.option (Just . parseDebianVersion <$> O.str) m where
+debianVersionP = O.option (Just . parseDebianVersion' <$> O.str) m where
   m = O.help helpMsg
       <> O.long "deb-version"
       <> O.metavar "DEBIANVERSION"
diff --git a/src/Debian/Debianize/Prelude.hs b/src/Debian/Debianize/Prelude.hs
--- a/src/Debian/Debianize/Prelude.hs
+++ b/src/Debian/Debianize/Prelude.hs
@@ -61,8 +61,7 @@
 import Debian.Pretty (PP(PP))
 import qualified Debian.Relation as D (BinPkgName(BinPkgName), Relations)
 import Debian.Relation.Common ()
-import Debian.Version (DebianVersion, prettyDebianVersion)
-import Debian.Version.String (parseDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion', prettyDebianVersion)
 import Distribution.Package (PackageIdentifier(..), PackageName(..))
 import Distribution.Verbosity (intToVerbosity, Verbosity)
 import GHC.IO.Exception (ExitCode(ExitFailure, ExitSuccess), IOErrorType(InappropriateType, NoSuchThing), IOException(IOError, ioe_description, ioe_type))
@@ -86,7 +85,7 @@
     return . either (const []) unControl . parseControl "/var/lib/dpkg/status" >>=
     mapM (\ p -> case (lookupP "Package" p, lookupP "Version" p) of
                    (Just (Field (_, name)), Just (Field (_, version))) ->
-                       return (Just (D.BinPkgName (stripWS name), Just (parseDebianVersion (stripWS version))))
+                       return (Just (D.BinPkgName (stripWS name), Just (parseDebianVersion' (stripWS version))))
                    _ -> return Nothing) >>=
     return . Map.fromList . catMaybes
 
diff --git a/src/Debian/Debianize/VersionSplits.hs b/src/Debian/Debianize/VersionSplits.hs
--- a/src/Debian/Debianize/VersionSplits.hs
+++ b/src/Debian/Debianize/VersionSplits.hs
@@ -22,7 +22,7 @@
 import Debian.Debianize.Interspersed (foldTriples, Interspersed(leftmost, pairs, foldInverted))
 import Debian.Orphans ()
 import qualified Debian.Relation as D (VersionReq(..))
-import Debian.Version (DebianVersion, parseDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion')
 import Distribution.Package (PackageIdentifier(..), PackageName(..))
 import Distribution.Version (anyVersion, earlierVersion, intersectVersionRanges, orLaterVersion, VersionRange)
 import Prelude hiding (init, log, unlines)
@@ -88,12 +88,12 @@
 debianFromCabal :: VersionSplits -> PackageIdentifier -> DebBase
 debianFromCabal s p =
     doSplits s (Just (D.EEQ debVer))
-    where debVer = parseDebianVersion (showVersion (pkgVersion p))
+    where debVer = parseDebianVersion' (showVersion (pkgVersion p))
 
 cabalFromDebian' :: Map PackageName VersionSplits -> DebBase -> Version -> PackageIdentifier
 cabalFromDebian' mp base ver =
     PackageIdentifier (cabalFromDebian mp base dver) ver
-    where dver = parseDebianVersion (showVersion ver)
+    where dver = parseDebianVersion' (showVersion ver)
 
 -- | Brute force implementation - I'm assuming this is not a huge map.
 cabalFromDebian :: Map PackageName VersionSplits -> DebBase -> DebianVersion -> PackageName
@@ -118,7 +118,7 @@
 doSplits :: VersionSplits -> Maybe D.VersionReq -> DebBase
 doSplits s version =
     foldTriples' (\ ltName v geName _ ->
-                           let split = parseDebianVersion (showVersion v) in
+                           let split = parseDebianVersion' (showVersion v) in
                                 case version of
                                   Nothing -> geName
                                   Just (D.SLT v') | v' <= split -> ltName
diff --git a/src/Debian/GHC.hs b/src/Debian/GHC.hs
--- a/src/Debian/GHC.hs
+++ b/src/Debian/GHC.hs
@@ -25,7 +25,7 @@
 import Data.Version (showVersion, Version(Version), parseVersion)
 import Debian.Debianize.BinaryDebDescription (PackageType(..))
 import Debian.Relation (BinPkgName(BinPkgName))
-import Debian.Version (DebianVersion, parseDebianVersion)
+import Debian.Version (DebianVersion, parseDebianVersion')
 import Distribution.Compiler (CompilerFlavor(..), CompilerId(CompilerId))
 #if MIN_VERSION_Cabal(1,22,0)
 import Distribution.Compiler (CompilerInfo(..), unknownCompilerInfo, AbiTag(NoAbiTag))
@@ -64,7 +64,7 @@
                 return . dropWhile (/= "Versions: ") . lines) :: IO (Either SomeException [String])
   case versions of
     Left e -> error $ "newestAvailable failed in " ++ show root ++ ": " ++ show e
-    Right (_ : versionLine : _) -> return . Just . parseDebianVersion . takeWhile (/= ' ') $ versionLine
+    Right (_ : versionLine : _) -> return . Just . parseDebianVersion' . takeWhile (/= ' ') $ versionLine
     _ -> return Nothing
     where
       chroot "/" = id
@@ -120,7 +120,7 @@
     CompilerId hc (greatestLowerBound debVersion (map (\ d -> Version (ds ++ [d]) ts) [0..]))
     where
       greatestLowerBound :: DebianVersion -> [Version] -> Version
-      greatestLowerBound b xs = last $ takeWhile (\ v -> parseDebianVersion (showVersion v) < b) xs
+      greatestLowerBound b xs = last $ takeWhile (\ v -> parseDebianVersion' (showVersion v) < b) xs
 
 -- | General function to build a command line option that reads most
 -- of the possible values for CompilerFlavor.
diff --git a/src/Debian/Policy.hs b/src/Debian/Policy.hs
--- a/src/Debian/Policy.hs
+++ b/src/Debian/Policy.hs
@@ -55,7 +55,7 @@
 import Debian.Debianize.Prelude (read')
 import Debian.Pretty (PP(..))
 import Debian.Relation (BinPkgName)
-import Debian.Version (DebianVersion, parseDebianVersion, version)
+import Debian.Version (DebianVersion, parseDebianVersion', version)
 import qualified Distribution.License as Cabal (License(..))
 import Distribution.Package (PackageIdentifier(pkgName))
 import Distribution.PackageDescription (PackageDescription(package))
@@ -109,11 +109,11 @@
 debianPackageVersion :: String -> IO (Maybe DebianVersion)
 debianPackageVersion name =
     readProcess "dpkg-query" ["--show", "--showformat=${version}", name] "" >>=
-    return . parseDebianVersion'
+    return . parseDebianVersion''
     where
       -- This should maybe be the real parseDebianVersion
-      parseDebianVersion' "" = Nothing
-      parseDebianVersion' s = Just (parseDebianVersion s)
+      parseDebianVersion'' "" = Nothing
+      parseDebianVersion'' s = Just (parseDebianVersion' s)
 
 -- | The version number of the installed debhelper package is the
 -- highest acceptable value for compat in a debian/control file.  If
diff --git a/test-data/alex/output/debian/rules b/test-data/alex/output/debian/rules
--- a/test-data/alex/output/debian/rules
+++ b/test-data/alex/output/debian/rules
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = alex
 DEB_DEFAULT_COMPILER = ghc
 
diff --git a/test-data/archive/output/debian/rules b/test-data/archive/output/debian/rules
--- a/test-data/archive/output/debian/rules
+++ b/test-data/archive/output/debian/rules
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = seereason-darcs-backups
 DEB_DEFAULT_COMPILER = ghc
 
diff --git a/test-data/artvaluereport-data/output/debian/rules b/test-data/artvaluereport-data/output/debian/rules
--- a/test-data/artvaluereport-data/output/debian/rules
+++ b/test-data/artvaluereport-data/output/debian/rules
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = artvaluereport-data
 DEB_DEFAULT_COMPILER = ghc
 
diff --git a/test-data/artvaluereport2/input/debian/Debianize.hs b/test-data/artvaluereport2/input/debian/Debianize.hs
--- a/test-data/artvaluereport2/input/debian/Debianize.hs
+++ b/test-data/artvaluereport2/input/debian/Debianize.hs
@@ -13,7 +13,7 @@
 import Debian.Pretty (ppShow)
 import Debian.Policy (databaseDirectory, PackageArchitectures(All), StandardsVersion(StandardsVersion))
 import Debian.Relation (BinPkgName(BinPkgName), Relation(Rel), SrcPkgName(..), VersionReq(SLT))
-import Debian.Version (parseDebianVersion)
+import Debian.Version (parseDebianVersion')
 
 -- This looks somewhat like a "real" Debianize.hs file except that (1) it
 -- expects to be run from the cabal-debian source directory and (2) it returns
@@ -51,7 +51,7 @@
              addServerData
              addServerDeps
              (debInfo . binaryDebDescription (BinPkgName "appraisalscope") . description) .= Just "Offline manipulation of appraisal database"
-             (debInfo . control . buildDependsIndep) %= (++ [[Rel (BinPkgName "libjs-jquery-ui") (Just (SLT (parseDebianVersion ("1.10" :: String)))) Nothing]])
+             (debInfo . control . buildDependsIndep) %= (++ [[Rel (BinPkgName "libjs-jquery-ui") (Just (SLT (parseDebianVersion' ("1.10" :: String)))) Nothing]])
              (debInfo . control . buildDependsIndep) %= (++ [[Rel (BinPkgName "libjs-jquery") Nothing Nothing]])
              (debInfo . control . buildDependsIndep) %= (++ [[Rel (BinPkgName "libjs-jcrop") Nothing Nothing]])
              (debInfo . binaryDebDescription (BinPkgName "artvaluereport2-staging") . architecture) .= Just All
diff --git a/test-data/artvaluereport2/output/debian/rules b/test-data/artvaluereport2/output/debian/rules
--- a/test-data/artvaluereport2/output/debian/rules
+++ b/test-data/artvaluereport2/output/debian/rules
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = artvaluereport
 DEB_DEFAULT_COMPILER = ghc
 
diff --git a/test-data/clckwrks-dot-com/output/debian/rules b/test-data/clckwrks-dot-com/output/debian/rules
--- a/test-data/clckwrks-dot-com/output/debian/rules
+++ b/test-data/clckwrks-dot-com/output/debian/rules
@@ -1,6 +1,7 @@
 #!/usr/bin/make -f
 
 DEB_SETUP_GHC_CONFIGURE_ARGS = -fbackups
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = clckwrks-dot-com
 DEB_DEFAULT_COMPILER = ghc
 
diff --git a/test-data/creativeprompts/output/debian/control b/test-data/creativeprompts/output/debian/control
--- a/test-data/creativeprompts/output/debian/control
+++ b/test-data/creativeprompts/output/debian/control
@@ -38,8 +38,8 @@
                , libghc-json-dev
                , libghc-mtl-dev
                , libghc-network-dev
-	       , libghc-old-locale-dev
-	       , libghc-old-time-dev
+               , libghc-old-locale-dev
+               , libghc-old-time-dev
                , libghc-parsec3-dev (>= 3) | libghc-parsec2-dev (<< 3)
                , libghc-random-dev
                , libghc-safecopy-dev (>= 0.6.0)
diff --git a/test-data/creativeprompts/output/debian/rules b/test-data/creativeprompts/output/debian/rules
--- a/test-data/creativeprompts/output/debian/rules
+++ b/test-data/creativeprompts/output/debian/rules
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+DEB_SETUP_BIN_NAME = cabal
 DEB_CABAL_PACKAGE = creativeprompts
 DEB_DEFAULT_COMPILER = ghc
 
