packages feed

cabal-debian 4.35.3 → 4.35.5

raw patch · 28 files changed

+401/−244 lines, 28 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Debian.Debianize.BasicInfo: [_compilerChoice] :: Flags -> CompilerChoice
- Debian.Debianize.BasicInfo: compilerChoice :: Lens' Flags CompilerChoice
- Debian.Debianize.Optparse: [_compilerChoice] :: Flags -> CompilerChoice
- Debian.GHC: CompilerChoice :: CompilerVendor -> CompilerFlavor -> CompilerChoice
- Debian.GHC: Debian :: CompilerVendor
- Debian.GHC: HVR :: Version -> CompilerVendor
- Debian.GHC: [_hcFlavor] :: CompilerChoice -> CompilerFlavor
- Debian.GHC: [_hcVendor] :: CompilerChoice -> CompilerVendor
- Debian.GHC: compilerPATH :: CompilerVendor -> String -> String
- Debian.GHC: data CompilerChoice
- Debian.GHC: data CompilerVendor
- Debian.GHC: hcFlavor :: Lens' CompilerChoice CompilerFlavor
- Debian.GHC: hcVendor :: Lens' CompilerChoice CompilerVendor
- Debian.GHC: instance Data.Data.Data Debian.GHC.CompilerChoice
- Debian.GHC: instance Data.Data.Data Debian.GHC.CompilerVendor
- Debian.GHC: instance Data.Function.Memoize.Class.Memoizable Debian.GHC.CompilerChoice
- Debian.GHC: instance Data.Function.Memoize.Class.Memoizable Debian.GHC.CompilerVendor
- Debian.GHC: instance GHC.Classes.Eq Debian.GHC.CompilerChoice
- Debian.GHC: instance GHC.Classes.Eq Debian.GHC.CompilerVendor
- Debian.GHC: instance GHC.Classes.Ord Debian.GHC.CompilerChoice
- Debian.GHC: instance GHC.Classes.Ord Debian.GHC.CompilerVendor
- Debian.GHC: instance GHC.Show.Show Debian.GHC.CompilerChoice
- Debian.GHC: instance GHC.Show.Show Debian.GHC.CompilerVendor
- Debian.GHC: withCompilerPATH :: MonadIO m => CompilerVendor -> m a -> m a
+ Debian.Debianize.BasicInfo: [_compilerFlavor] :: Flags -> CompilerFlavor
+ Debian.Debianize.BasicInfo: compilerFlavor :: Lens' Flags CompilerFlavor
+ Debian.Debianize.Optparse: [_compilerFlavor] :: Flags -> CompilerFlavor
+ Debian.GHC: hvrCompilerPATH :: Version -> String -> String
+ Debian.GHC: isHVRCompilerPackage :: CompilerFlavor -> BinPkgName -> Maybe Version
+ System.Git: gitIsClean :: IO Bool
+ System.Git: gitResetHard :: IO ()
+ System.Git: gitResetSubdir :: FilePath -> IO ()
+ System.Git: gitUnclean :: IO (Maybe String)
+ System.Git: withCleanRepo :: IO a -> IO a
- Debian.Debianize.BasicInfo: Flags :: Int -> Bool -> Bool -> Bool -> Bool -> CompilerChoice -> Set (FlagName, Bool) -> EnvSet -> Flags
+ Debian.Debianize.BasicInfo: Flags :: Int -> Bool -> Bool -> Bool -> Bool -> CompilerFlavor -> Set (FlagName, Bool) -> EnvSet -> Flags
- Debian.Debianize.BuildDependencies: debianBuildDeps :: (Monad m, Functor m) => PackageDescription -> CabalT m Relations
+ Debian.Debianize.BuildDependencies: debianBuildDeps :: (MonadIO m, Functor m) => PackageDescription -> CabalT m Relations
- Debian.Debianize.BuildDependencies: debianBuildDepsIndep :: (Monad m, Functor m) => PackageDescription -> CabalT m Relations
+ Debian.Debianize.BuildDependencies: debianBuildDepsIndep :: (MonadIO m, Functor m) => PackageDescription -> CabalT m Relations
- Debian.Debianize.Bundled: builtIn :: CompilerChoice -> FilePath -> [PackageIdentifier]
+ Debian.Debianize.Bundled: builtIn :: CompilerFlavor -> FilePath -> [PackageIdentifier]
- Debian.Debianize.Bundled: hcVersion :: FilePath -> CompilerChoice -> Maybe Version
+ Debian.Debianize.Bundled: hcVersion :: FilePath -> CompilerFlavor -> Maybe Version
- Debian.Debianize.DebianName: debianName :: (Monad m, Functor m, PkgName name) => PackageType -> CompilerChoice -> CabalT m name
+ Debian.Debianize.DebianName: debianName :: (Monad m, Functor m, PkgName name) => PackageType -> CompilerFlavor -> CabalT m name
- Debian.Debianize.DebianName: mkPkgName :: PkgName name => CompilerChoice -> PackageName -> PackageType -> name
+ Debian.Debianize.DebianName: mkPkgName :: PkgName name => CompilerFlavor -> PackageName -> PackageType -> name
- Debian.Debianize.DebianName: mkPkgName' :: PkgName name => CompilerChoice -> PackageType -> DebBase -> name
+ Debian.Debianize.DebianName: mkPkgName' :: PkgName name => CompilerFlavor -> PackageType -> DebBase -> name
- Debian.Debianize.Optparse: Flags :: Int -> Bool -> Bool -> Bool -> Bool -> CompilerChoice -> Set (FlagName, Bool) -> EnvSet -> Flags
+ Debian.Debianize.Optparse: Flags :: Int -> Bool -> Bool -> Bool -> Bool -> CompilerFlavor -> Set (FlagName, Bool) -> EnvSet -> Flags
- Debian.GHC: compilerPackageName :: CompilerChoice -> PackageType -> BinPkgName
+ Debian.GHC: compilerPackageName :: CompilerFlavor -> PackageType -> Maybe BinPkgName
- Debian.GHC: newestAvailableCompilerId :: FilePath -> CompilerChoice -> Either String CompilerId
+ Debian.GHC: newestAvailableCompilerId :: FilePath -> CompilerFlavor -> Either String CompilerId
- Debian.GHC: withCompilerVersion :: FilePath -> CompilerChoice -> (Either String DebianVersion -> a) -> a
+ Debian.GHC: withCompilerVersion :: FilePath -> CompilerFlavor -> (DebianVersion -> a) -> Either String a

Files

Tests.hs view
@@ -1,11 +1,11 @@ {-# LANGUAGE CPP, OverloadedStrings, RankNTypes, ScopedTypeVariables, StandaloneDeriving #-} {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}-module Main-    ( tests-    , main-    ) where+module Main where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+import Data.Monoid (mconcat, mempty)+#endif import Debian.Debianize.Optparse(_flags, parseProgramArguments) import Control.Lens import Data.Algorithm.DiffContext (getContextDiff, prettyContextDiff)@@ -15,50 +15,46 @@ import Data.Map as Map (differenceWithKey, insert, intersectionWithKey) import qualified Data.Map as Map (elems, Map, toList) import Data.Maybe (fromMaybe)-import Data.Monoid ((<>), mconcat, mempty)+import Data.Monoid ((<>)) import Data.Set as Set (fromList, union, insert) import Data.Text as Text (intercalate, split, Text, unlines, unpack) import Data.Version (Version(Version)) import Debian.Changes (ChangeLog(..), ChangeLogEntry(..), parseEntry)-import Debian.Debianize.BasicInfo (compilerChoice, Flags, verbosity)+import Debian.Debianize.BasicInfo (compilerFlavor, Flags, verbosity) import qualified Debian.Debianize.Bundled as Bundled (tests) import qualified Debian.Debianize.BinaryDebDescription as B import Debian.Debianize.CabalInfo as A (CabalInfo, debInfo, epochMap, newCabalInfo) import Debian.Debianize.CopyrightDescription import Debian.Debianize.DebianName (mapCabal, splitCabal) import qualified Debian.Debianize.DebInfo as D+import Debian.Debianize.Details (debianDefaults) import Debian.Debianize.Files (debianizationFileMap) import Debian.Debianize.Finalize (debianize {-, finalizeDebianization-}) import Debian.Debianize.Goodies (doBackups, doExecutable, doServer, doWebsite, tightDependencyFixup) import Debian.Debianize.InputDebian (inputDebianization) import Debian.Debianize.Monad (CabalT, evalCabalT, execCabalM, execCabalT, liftCabal, execDebianT, DebianT, evalDebianT)+import Debian.Debianize.Output (performDebianization) import Debian.Debianize.Prelude (withCurrentDirectory) import qualified Debian.Debianize.SourceDebDescription as S import Debian.Debianize.VersionSplits (DebBase(DebBase))-import Debian.GHC (CompilerChoice(..), CompilerVendor(..))+import Debian.GHC (hvrCompilerPATH, withModifiedPATH) import Debian.Pretty (ppShow)-import Debian.Policy (databaseDirectory, PackageArchitectures(All), PackagePriority(Extra), parseMaintainer, Section(MainSection), SourceFormat(Native3), StandardsVersion(..), getDebhelperCompatLevel, getDebianStandardsVersion, License(..))+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 Distribution.Compiler (CompilerFlavor(GHC))+import Debian.Version (parseDebianVersion'{-, buildDebianVersion-})+import Distribution.Compiler (CompilerFlavor({-GHC,-} GHCJS)) import Distribution.Package (PackageName(PackageName)) import Prelude hiding (log) import System.Directory (doesDirectoryExist) import System.Exit (exitWith, ExitCode(..)) import System.FilePath ((</>))+import System.Git (gitResetSubdir) import System.Process (readProcessWithExitCode) import Test.HUnit import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr(..)) import Text.PrettyPrint.HughesPJClass (pPrint, text, Doc) -#if MIN_VERSION_base(4,8,0)-import Data.Version (makeVersion)-#else-makeVersion :: [Int] -> Version-makeVersion ns = Version ns []-#endif- -- | Backward compatibility. Should be fixed. newFlags :: IO Flags newFlags = _flags <$> parseProgramArguments@@ -80,9 +76,7 @@     where       ghc763 :: Either String CabalInfo -> CabalInfo       ghc763 (Left s) = error $ "testAtoms - failed to build CabalInfo: " ++ s-      ghc763 (Right atoms) =-          set (A.debInfo . D.flags . compilerChoice)-              (CompilerChoice {_hcVendor = HVR (makeVersion [7,6,3]), _hcFlavor = GHC}) atoms+      ghc763 (Right atoms) = {-set (A.debInfo . D.flags . compilerFlavor) GHC-} atoms  -- | Create a Debianization based on a changelog entry and a license -- value.  Uses the currently installed versions of debhelper and@@ -112,10 +106,14 @@                                                    test4 "test4 - test-data/clckwrks-dot-com",                                                    test5 "test5 - test-data/creativeprompts",                                                    test6 "test6 - test-data/artvaluereport2",-                                                   test7 "test7 - debian/Debianize.hs",+                                                   -- test7 "test7 - debian/Debianize.hs",                                                    test8 "test8 - test-data/artvaluereport-data",                                                    test9 "test9 - test-data/alex",-                                                   test10 "test10 - test-data/archive" {- ,+                                                   test10 "test10 - test-data/archive" {-,+                                                   -- This works, but it adds a dependency on ghcjs to the test suite+                                                   -- test11 "test11 - test-data/diff",+                                                   -- And this requires ghc-8.0.1 from the hvr compiler repo+                                                   -- test12 "test12 - test-data/diff",                                                    issue23 "issue23" -}])  issue23 :: String -> Test@@ -755,10 +753,35 @@ sortBinaryDebs :: DebianT IO () sortBinaryDebs = (D.control . S.binaryPackages) %= sortBy (compare `on` view B.package) +test11 :: String -> Test+test11 label =+    TestLabel label $+    TestCase $ do let input = "test-data/diff/input"+                      expected = "test-data/diff/expected.ghcjs"+                  gitResetSubdir input+                  withCurrentDirectory input (performDebianization (do debianDefaults+                                                                       (debInfo . D.flags . compilerFlavor) .= GHCJS+                                                                       (debInfo . D.testsStatus) .= D.TestsDisable+                                                                       (debInfo . D.sourceFormat) .= Native3))+                  assertEmptyDiff expected input++test12 :: String -> Test+test12 label =+    TestLabel label $+    TestCase $ withModifiedPATH (hvrCompilerPATH (Version [8,0,1] [])) $+               do let input = "test-data/diff/input"+                      expected = "test-data/diff/expected.hvr"+                  gitResetSubdir input+                  withCurrentDirectory input (performDebianization (do debianDefaults+                                                                       (debInfo . D.testsStatus) .= D.TestsDisable+                                                                       (debInfo . D.sourceFormat) .= Native3))+                  assertEmptyDiff expected input++ main :: IO () main = do- counts <- runTestTT tests- exitWith $ if errors counts + failures counts > 0+ cts <- withModifiedPATH (const "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games") (runTestTT tests)+ exitWith $ if errors cts + failures cts > 0             then ExitFailure 1             else ExitSuccess @@ -767,7 +790,7 @@ assertEmptyDiff :: String -- ^ The message prefix                 -> String -- ^ The actual diff                 -> Assertion-assertEmptyDiff preface "" = return ()+assertEmptyDiff _preface "" = return () assertEmptyDiff preface diff = assertFailure $  (if null preface then "" else preface ++ "\n") ++  "diff not empty:\n" ++
cabal-debian.cabal view
@@ -1,5 +1,5 @@ Name:           cabal-debian-Version:        4.35.3+Version:        4.35.5 Copyright:      Copyright (c) 2007-2014, David Fox, Jeremy Shaw License:        BSD3 License-File:   LICENSE@@ -218,6 +218,7 @@     Debian.Debianize.SourceDebDescription     Debian.Debianize.VersionSplits     Paths_cabal_debian+    System.Git   Other-Modules:     Debian.Orphans   if flag(pretty-112)@@ -245,6 +246,7 @@     Build-Depends: pretty < 1.1.2, prettyclass  Test-Suite cabal-debian-tests+  Buildable: False   Default-Language: Haskell2010   Type: exitcode-stdio-1.0   Hs-Source-Dirs: .
changelog view
@@ -1,9 +1,22 @@+haskell-cabal-debian (4.35.5) unstable; urgency=low++  * Fix up some ghcjs and hvr packaging issues.++ -- David Fox <dsf@foxthompson.net>  Sun, 27 Nov 2016 09:19:02 -0800++haskell-cabal-debian (4.35.4) unstable; urgency=low++  * Get rid of CompilerChoice and CompilerVendor types, just look for+    the ghc executable via the $PATH and use that info.++ -- David Fox <dsf@seereason.com>  Sat, 26 Nov 2016 11:39:48 -0800+ haskell-cabal-debian (4.35.3) unstable; urgency=low -  * Prefer haskell-devscripts-minimal to haskell-devscripts-  * Test suite seems ok+  * Prefer dependency on haskell-devscript-minimal over haskell-devscript+  * Do not assume deb containing ghc executable is named ghc, nor ghcjs. - -- David Fox <dsf@seereason.com>  Fri, 25 Nov 2016 11:45:37 -0800+ -- David Fox <dsf@foxthompson.net>  Sat, 26 Nov 2016 04:29:21 -0800  haskell-cabal-debian (4.35) unstable; urgency=low 
debian/control view
@@ -3,7 +3,7 @@ Priority: extra Section: haskell Build-Depends: debhelper (>= 9),- haskell-devscripts (>= 0.8),+ haskell-devscripts-minimal | haskell-devscripts (>= 0.8),  cdbs,  ghc,  ghc-prof,
debian/rules view
@@ -1,6 +1,7 @@ #!/usr/bin/make -f  DEB_ENABLE_TESTS = yes+DEB_SETUP_BIN_NAME = debian/hlibrary.setup DEB_CABAL_PACKAGE = cabal-debian DEB_DEFAULT_COMPILER = ghc 
src/Debian/Debianize.hs view
@@ -113,5 +113,5 @@ import Debian.Debianize.Prelude (buildDebVersionMap, debOfFile, dpkgFileMap, withCurrentDirectory, (.?=)) import Debian.Debianize.SourceDebDescription import Debian.Debianize.VersionSplits (DebBase(DebBase))-import Debian.GHC (CompilerChoice(..), CompilerVendor(..), hcVendor, hcFlavor)+import Debian.GHC () import Debian.Policy (accessLogBaseName, apacheAccessLog, apacheErrorLog, apacheLogDirectory, appLogBaseName, Area(..), databaseDirectory, debianPackageVersion, errorLogBaseName, fromCabalLicense, getCurrentDebianUser, getDebhelperCompatLevel, getDebianStandardsVersion, haskellMaintainer, License(..), PackageArchitectures(..), PackagePriority(..), MultiArch(..), parseMaintainer, parsePackageArchitectures, parseStandardsVersion, parseUploaders, readLicense, readPriority, readSection, readMultiArch, readSourceFormat, Section(..), serverAccessLog, serverAppLog, serverLogDirectory, SourceFormat(..), StandardsVersion(..), toCabalLicense)
src/Debian/Debianize/BasicInfo.hs view
@@ -11,7 +11,7 @@     , upgrade     , roundtrip     , validate-    , compilerChoice+    , compilerFlavor     , cabalFlagAssignments     , buildEnv       -- * State Monad@@ -25,7 +25,6 @@ import Data.Generics (Data, Typeable) import Data.Set as Set (fromList, Set, union) import Debian.Debianize.Prelude (read')-import Debian.GHC (CompilerChoice, hcFlavor) import Debian.Orphans () import Distribution.Compiler (CompilerFlavor(..)) import Distribution.PackageDescription as Cabal (FlagName(FlagName))@@ -54,7 +53,7 @@     -- configure is run.  Specifically, the version number in the top     -- changelog entry must match, and the sets of package names in     -- the control file must match.-    , _compilerChoice :: CompilerChoice+    , _compilerFlavor :: CompilerFlavor     -- ^ Which compiler should we generate library packages for?  In theory a single     -- deb could handle multiple compiler flavors, but the support tools are not ready     -- for this as of right now (28 Jan 2015.)@@ -97,13 +96,13 @@              "Carefully upgrade an existing debianization",       Option "" ["roundtrip"] (NoArg (roundtrip .= True))              "Rountrip a debianization to normalize it",-      Option "" ["ghc"] (NoArg ((compilerChoice . hcFlavor) .= GHC)) "Generate packages for GHC - same as --with-compiler GHC",+      Option "" ["ghc"] (NoArg (compilerFlavor .= GHC)) "Generate packages for GHC - same as --with-compiler GHC", #if MIN_VERSION_Cabal(1,22,0)-      Option "" ["ghcjs"] (NoArg ((compilerChoice . hcFlavor) .= GHCJS)) "Generate packages for GHCJS - same as --with-compiler GHCJS",+      Option "" ["ghcjs"] (NoArg (compilerFlavor .= GHCJS)) "Generate packages for GHCJS - same as --with-compiler GHCJS", #endif-      Option "" ["hugs"] (NoArg ((compilerChoice . hcFlavor) .= Hugs)) "Generate packages for Hugs - same as --with-compiler GHC",+      Option "" ["hugs"] (NoArg (compilerFlavor .= Hugs)) "Generate packages for Hugs - same as --with-compiler GHC",       Option "" ["with-compiler"] (ReqArg (\ s -> maybe (error $ "Invalid compiler id: " ++ show s)-                                                        (\ hc -> (compilerChoice . hcFlavor) .= hc)+                                                        (\ hc -> compilerFlavor .= hc)                                                         (readMaybe (map toUpper s) :: Maybe CompilerFlavor)) "COMPILER")              (unlines [ "Generate packages for this CompilerFlavor" ]),       Option "f" ["flags"] (ReqArg (\ fs -> cabalFlagAssignments %= (Set.union (Set.fromList (flagList fs)))) "FLAGS")
src/Debian/Debianize/BuildDependencies.hs view
@@ -6,9 +6,12 @@     ) where  +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Lens import Control.Monad.State (MonadState(get))+import Control.Monad.Trans (liftIO, MonadIO) import Data.Char (isSpace, toLower) import Data.Function (on) import Data.List as List (filter, groupBy, map, minimumBy, nub, sortBy)@@ -16,8 +19,8 @@ import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing, listToMaybe) import Data.Set as Set (empty, fold, fromList, map, member, Set, singleton, toList, union) import Data.Version (showVersion, Version)-import Debian.Debianize.BasicInfo (buildEnv, compilerChoice, EnvSet(dependOS), verbosity)-import Debian.Debianize.Bundled (builtIn, hcVersion)+import Debian.Debianize.BasicInfo (buildEnv, compilerFlavor, EnvSet(dependOS))+import Debian.Debianize.Bundled (builtIn) import qualified Debian.Debianize.DebInfo as D import Debian.Debianize.DebianName (mkPkgName, mkPkgName') import Debian.Debianize.Monad as Monad (CabalInfo, CabalT)@@ -25,7 +28,7 @@ import qualified Debian.Debianize.CabalInfo as A import qualified Debian.Debianize.SourceDebDescription as S import Debian.Debianize.VersionSplits (packageRangesFromVersionSplits)-import Debian.GHC (CompilerChoice(..), compilerPackageName)+import Debian.GHC (compilerPackageName) 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))@@ -104,10 +107,10 @@  -- The haskell-cdbs package contains the hlibrary.mk file with -- the rules for building haskell packages.-debianBuildDeps :: (Monad m, Functor m) => PackageDescription -> CabalT m D.Relations+debianBuildDeps :: (MonadIO m, Functor m) => PackageDescription -> CabalT m D.Relations debianBuildDeps pkgDesc =-    do hchoice <- use (A.debInfo . D.flags . compilerChoice)-       let hcs = singleton hchoice -- vestigial+    do hflavor <- use (A.debInfo . D.flags . compilerFlavor)+       let hcs = singleton hflavor -- vestigial        let hcTypePairsLibs =                fold union empty $                   Set.map (\ hc' -> Set.map (hc',) $ hcPackageTypesLibs hc') hcs@@ -134,59 +137,62 @@        prof <- not <$> use (A.debInfo . D.noProfilingLibrary)        official <- use (A.debInfo . D.official)        compat <- use (A.debInfo . D.compat)+       let ghcdev = compilerPackageName hflavor B.Development+       let ghcrel = if member GHC hcs then maybe [] ((: []) . anyrel') ghcdev else []+       let ghcprof = compilerPackageName hflavor B.Profiling+       let ghcrelprof = if prof then maybe [] ((: []) . anyrel') ghcprof else []        let xs = nub $ [maybe [] (\ n -> [D.Rel (D.BinPkgName "debhelper") (Just (D.GRE (parseDebianVersion' (show n)))) Nothing]) compat,                        [D.Rel (D.BinPkgName "haskell-devscripts-minimal") Nothing Nothing,                         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 (Set.map _hcFlavor hcs)-                       then [anyrel' (compilerPackageName hchoice B.Development)] ++ if prof then [anyrel' (compilerPackageName hchoice B.Profiling)] else []-                       else []) +++                      (ghcrel ++ ghcrelprof) +++{- #if MIN_VERSION_Cabal(1,22,0)-                      (if member GHCJS (Set.map _hcFlavor hcs) then [anyrel "ghcjs"] else []) +++                      (if member GHCJS (Set.map _hcFlavor hcs) then [anyrel (compilerPackageName hflavor B.Development)] else []) ++ #endif+-}                        bDeps ++                        cDeps        filterMissing xs     where-      hcPackageTypesLibs :: CompilerChoice -> Set B.PackageType-      hcPackageTypesLibs (CompilerChoice {_hcFlavor = GHC}) = fromList [B.Development, B.Profiling]+      hcPackageTypesLibs :: CompilerFlavor -> Set B.PackageType+      hcPackageTypesLibs GHC = fromList [B.Development, B.Profiling] #if MIN_VERSION_Cabal(1,22,0)-      hcPackageTypesLibs (CompilerChoice {_hcFlavor = GHCJS}) = fromList [B.Development]+      hcPackageTypesLibs GHCJS = fromList [B.Development] #endif       hcPackageTypesLibs hc = error $ "Unsupported compiler flavor: " ++ show hc        -- No point in installing profiling packages for the dependencies       -- of binaries and test suites-      hcPackageTypesBins :: CompilerChoice -> Set B.PackageType+      hcPackageTypesBins :: CompilerFlavor -> Set B.PackageType       hcPackageTypesBins _ = singleton B.Development -      hcPackageTypesTests :: CompilerChoice -> Set B.PackageType+      hcPackageTypesTests :: CompilerFlavor -> Set B.PackageType       hcPackageTypesTests _ = singleton B.Development --debianBuildDepsIndep :: (Monad m, Functor m) => PackageDescription -> CabalT m D.Relations+-- | Collect the dependencies required to build any packages that have+-- architecture "all".+debianBuildDepsIndep :: (MonadIO m, Functor m) => PackageDescription -> CabalT m D.Relations debianBuildDepsIndep pkgDesc =-    do hc <- use (A.debInfo . D.flags . compilerChoice)+    do hc <- use (A.debInfo . D.flags . compilerFlavor)        let hcs = singleton hc -- vestigial        doc <- not <$> use (A.debInfo . D.noDocumentationLibrary)        bDeps <- use (A.debInfo . D.control . S.buildDependsIndep)        libDeps <- allBuildDepends (maybe [] (return . libBuildInfo) (Cabal.library pkgDesc))        cDeps <- mapM docDependencies libDeps+       let ghcdoc = compilerPackageName hc B.Documentation+       let hcdocdep = if doc && member GHC hcs then maybe [] ((: []) . anyrel') ghcdoc else []        let xs = nub $ if doc && isJust (Cabal.library pkgDesc)-                      then (if member GHC (Set.map _hcFlavor hcs) then [anyrel' (compilerPackageName hc B.Documentation)] else []) ++-#if MIN_VERSION_Cabal(1,22,0)-                           (if member GHCJS (Set.map _hcFlavor hcs) then [anyrel "ghcjs"] else []) ++-#endif-                           bDeps ++ concat cDeps+                      then hcdocdep ++ bDeps ++ concat cDeps                       else []        filterMissing xs  -- | The documentation dependencies for a package include the -- documentation package for any libraries which are build -- dependencies, so we have use to all the cross references.-docDependencies :: (Monad m, Functor m) => Dependency_ -> CabalT m D.Relations+docDependencies :: (MonadIO m, Functor m) => Dependency_ -> CabalT m D.Relations docDependencies (BuildDepends (Dependency name ranges)) =-    do hc <- use (A.debInfo . D.flags . compilerChoice)+    do hc <- use (A.debInfo . D.flags . compilerFlavor)        let hcs = singleton hc -- vestigial        omitProfDeps <- use (A.debInfo . D.omitProfVersionDeps)        concat <$> mapM (\ hc' -> dependencies hc' B.Documentation name ranges omitProfDeps) (toList hcs)@@ -195,7 +201,7 @@ -- | The Debian build dependencies for a package include the profiling -- libraries and the documentation packages, used for creating cross -- references.  Also the packages associated with extra libraries.-buildDependencies :: (Monad m, Functor m) => Set (CompilerChoice, B.PackageType) -> Dependency_ -> CabalT m D.Relations+buildDependencies :: (MonadIO m, Functor m) => Set (CompilerFlavor, B.PackageType) -> Dependency_ -> CabalT m D.Relations buildDependencies hcTypePairs (BuildDepends (Dependency name ranges)) =     use (A.debInfo . D.omitProfVersionDeps) >>= \ omitProfDeps ->     concat <$> mapM (\ (hc, typ) -> dependencies hc typ name ranges omitProfDeps) (toList hcTypePairs)@@ -250,7 +256,7 @@ -- | Turn a cabal dependency into debian dependencies.  The result -- needs to correspond to a single debian package to be installed, -- so we will return just an OrRelation.-dependencies :: Monad m => CompilerChoice -> B.PackageType -> PackageName -> VersionRange -> Bool -> CabalT m Relations+dependencies :: MonadIO m => CompilerFlavor -> B.PackageType -> PackageName -> VersionRange -> Bool -> CabalT m Relations dependencies hc typ name cabalRange omitProfVersionDeps =     do nameMap <- use A.debianNameMap        -- Compute a list of alternative debian dependencies for@@ -317,37 +323,28 @@ -- compiler a substitute for that package.  If we were to -- specify the virtual package (e.g. libghc-base-dev) we would -- have to make sure not to specify a version number.-doBundled :: Monad m =>+doBundled :: MonadIO m =>              B.PackageType           -> PackageName-          -> CompilerChoice+          -> CompilerFlavor           -> [D.Relation]           -> CabalT m [D.Relation]-doBundled typ name hc rels =-    mapM doRel rels >>= return . concat+doBundled typ name hc rels = do+  let hcname = compilerPackageName hc typ+  mapM (doRel hcname) rels >>= return . concat     where       -- If a library is built into the compiler, this is the debian       -- package name the compiler will conflict with.-      comp = D.Rel (compilerPackageName hc typ) Nothing Nothing-      doRel :: Monad m => D.Relation -> CabalT m [D.Relation]-      doRel rel@(D.Rel dname req _) = do+      doRel :: Monad m => Maybe BinPkgName -> D.Relation -> CabalT m [D.Relation]+      doRel hcname rel@(D.Rel dname req _) = do+        let comp = maybe [] (\x -> [D.Rel x Nothing Nothing]) hcname         -- gver <- use ghcVersion         root <- use (A.debInfo . D.flags . buildEnv) >>= return . dependOS         -- Look at what version of the package is provided by the compiler.         atoms <- get         -- What version of this package (if any) does the compiler provide?-        let Just hcv = hcVersion root hc-            relInfo = builtIn hc root+        let relInfo = builtIn hc root             pver = listToMaybe $ fmap (debianVersion'' atoms) (filter ((== name) . pkgName) relInfo)-            v = view (A.debInfo . D.flags . verbosity) atoms-#if 0-        case (v > 0, filter ((== name) . pkgName) relInfo) of-          (True, [i]) ->-              trace ("  " ++ show hc ++ "-" ++ show (showVersion hcv) ++ " in " ++ root ++ " provides " ++ display (pkgName i) ++ "-" ++ display (pkgVersion i)) (return ())-          (True, _) ->-              trace ("  " ++ show hc ++ "-" ++ show (showVersion hcv) ++ " in " ++ root ++ " does not provide " ++ display name) (return ())-          _ -> return ()-#endif         -- The name this library would have if it was in the compiler conflicts list.         let naiveDebianName = mkPkgName hc name typ         -- The compiler should appear in the build dependency@@ -356,7 +353,7 @@         -- library (which, if pver is Nothing, will certainly         -- result in an error which needs to be corrected in         -- the packaging.)-        let compilerDependency = if isJust pver && (checkVersionReq req pver || (dname == naiveDebianName && conflictsWithHC naiveDebianName)) then [comp] else []+        let compilerDependency = if isJust pver && (checkVersionReq req pver || (dname == naiveDebianName && conflictsWithHC naiveDebianName)) then comp else []         -- The library package can satisfy the dependency if         -- the compiler doesn't provide a version, or if the         -- compiler doesn't conflict with the package's
src/Debian/Debianize/Bundled.hs view
@@ -20,7 +20,9 @@     , tests     ) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>), (<*>))+#endif import Control.DeepSeq (force, NFData) import Control.Exception (SomeException, try) import Control.Monad.Catch (MonadMask)@@ -31,13 +33,15 @@ import Data.Maybe (listToMaybe, mapMaybe) import Data.Set as Set (difference, fromList) import Data.Version (parseVersion, Version(..))-import Debian.GHC (CompilerChoice(..))+import Debian.GHC ({-instance Memoizable CompilerFlavor-}) import Debian.Relation (BinPkgName(..)) import Debian.Relation.ByteString () import Debian.Version (DebianVersion, parseDebianVersion', prettyDebianVersion) import Distribution.Package (PackageIdentifier(..), PackageName(..)) #if MIN_VERSION_Cabal(1,22,0) import Distribution.Simple.Compiler (CompilerFlavor(GHCJS))+#else+import Distribution.Compiler (CompilerFlavor) #endif import System.IO.Unsafe (unsafePerformIO) import System.Process (readProcess, showCommandForUser)@@ -63,7 +67,7 @@ -- This is done by looking for .conf files beneath a package.conf.d -- directory and parsing the name.  (Probably better to actually read -- the .conf file.)-builtIn :: CompilerChoice -> FilePath -> [PackageIdentifier]+builtIn :: CompilerFlavor -> FilePath -> [PackageIdentifier] builtIn hc root =   let Just hcname = (hcExecutablePath root hc >>= hcBinPkgName root) in   aptCacheProvides hcname root@@ -71,15 +75,15 @@ -- | Convert CompilerFlavor to an executable name in a way that works -- for at least the cases we are interested in.  This might need to be -- fudged or replaced as more cases become interesting.-hcExecutable :: CompilerChoice -> String-hcExecutable = map toLower . show . _hcFlavor+hcExecutable :: CompilerFlavor -> String+hcExecutable = map toLower . show  -- | Use which(1) to determine full path name to haskell compiler executable-hcExecutablePath :: FilePath -> CompilerChoice -> Maybe FilePath+hcExecutablePath :: FilePath -> CompilerFlavor -> Maybe FilePath hcExecutablePath = memoize2 $ \root hc ->   listToMaybe $ lines $ unsafePerformIO $ chroot root (readProcess "which" [hcExecutable hc] "") -hcVersion :: FilePath -> CompilerChoice -> Maybe Version+hcVersion :: FilePath -> CompilerFlavor -> Maybe Version hcVersion root hc =     let Just hcpath = hcExecutablePath root hc in     maybe Nothing parseVersion' $@@ -87,7 +91,7 @@      lines $      unsafePerformIO . chroot root $      readProcess hcpath-                 [case _hcFlavor hc of+                 [case hc of #if MIN_VERSION_Cabal(1,22,0)                     GHCJS -> "--numeric-ghc-version" #endif@@ -195,9 +199,11 @@                                  "haskeline", "hoopl", "hpc", "integer-gmp", "pretty", "process",                                  "template-haskell", "terminfo", "time", "transformers", "unix", "xhtml"])                          actual = Set.fromList (map (unPackageName . pkgName) (aptCacheProvides (BinPkgName ("ghc" ++ maybe "" ("-" ++) ver)) "/"))+                         missing (Just "8.0.1") = Set.fromList ["bin-package-db"]                          missing (Just "8.0.2") = Set.fromList ["bin-package-db"]                          missing _ = mempty                          extra (Just "7.8.4") = Set.fromList ["haskell2010","haskell98","old-locale","old-time"]+                         extra (Just "8.0.1") = Set.fromList ["ghc-boot","ghc-boot-th","ghci"]                          extra (Just "8.0.2") = Set.fromList ["ghc-boot","ghc-boot-th","ghci"]                          extra _ = mempty                      assertEqual "Bundled4"
src/Debian/Debianize/CabalInfo.hs view
@@ -16,6 +16,7 @@  #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+import Data.Monoid (Monoid(..)) #endif import Control.Lens import Control.Monad.Catch (MonadMask)@@ -23,7 +24,6 @@ import Control.Monad.Trans (MonadIO, liftIO) import Data.Generics (Data, Typeable) import Data.Map as Map (Map)-import Data.Monoid (Monoid(..)) import Data.Text as Text (null, pack, strip) import Debian.Debianize.BasicInfo (Flags) import Debian.Debianize.DebInfo as D (control, copyright, DebInfo, makeDebInfo)
src/Debian/Debianize/DebInfo.hs view
@@ -91,7 +91,9 @@ import Control.Monad.State (StateT) import Data.Generics (Data, Typeable) import Data.Map as Map (Map)+#if !MIN_VERSION_base(4,8,0) import Data.Monoid (Monoid(..))+#endif import Data.Set as Set (insert, Set) import Data.Text (Text) import Debian.Changes (ChangeLog)
src/Debian/Debianize/DebianName.hs view
@@ -1,5 +1,5 @@ -- | How to name the debian packages based on the cabal package name and version number.-{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, OverloadedStrings, RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeFamilies #-}+{-# LANGUAGE CPP, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings, RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeFamilies #-} {-# OPTIONS -Wall -Wwarn -fno-warn-name-shadowing -fno-warn-orphans #-} module Debian.Debianize.DebianName     ( debianName@@ -12,7 +12,9 @@     ) where  +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Lens import Data.Char (toLower) import Data.Map as Map (alter, lookup)@@ -22,7 +24,6 @@ import Debian.Debianize.BinaryDebDescription as Debian (PackageType(..)) import Debian.Debianize.DebInfo as D (overrideDebianNameBase, utilsPackageNameBase) import Debian.Debianize.VersionSplits (DebBase(DebBase, unDebBase), doSplits, insertSplit, makePackage, VersionSplits(oldestPackage, splits))-import Debian.GHC (CompilerChoice(..)) import Debian.Orphans () import Debian.Relation (PkgName(..), Relations) import qualified Debian.Relation as D (VersionReq(EEQ))@@ -40,10 +41,10 @@     deriving (Eq, Show)  -- | Build the Debian package name for a given package type.-debianName :: (Monad m, Functor m, PkgName name) => PackageType -> CompilerChoice -> CabalT m name-debianName typ hc@(CompilerChoice {_hcFlavor = cfl}) =+debianName :: (Monad m, Functor m, PkgName name) => PackageType -> CompilerFlavor -> CabalT m name+debianName typ hc =     do base <--           case (typ, cfl) of+           case (typ, hc) of              (Utilities, GHC) -> use (debInfo . utilsPackageNameBase) >>= maybe (((\ base -> "haskell-" ++ base ++ "-utils") . unDebBase) <$> debianNameBase) return              (Utilities, _) -> use (debInfo . utilsPackageNameBase) >>= maybe (((\ base -> base ++ "-utils") . unDebBase) <$> debianNameBase) return              _ -> unDebBase <$> debianNameBase@@ -70,24 +71,24 @@ -- debian package type.  Unfortunately, this does not enforce the -- correspondence between the PackageType value and the name type, so -- it can return nonsense like (SrcPkgName "libghc-debian-dev").-mkPkgName :: PkgName name => CompilerChoice -> PackageName -> PackageType -> name+mkPkgName :: PkgName name => CompilerFlavor -> PackageName -> PackageType -> name mkPkgName hc pkg typ = mkPkgName' hc typ (debianBaseName pkg) -mkPkgName' :: PkgName name => CompilerChoice -> PackageType -> DebBase -> name-mkPkgName' (CompilerChoice {_hcFlavor = cfl}) typ (DebBase base) =+mkPkgName' :: PkgName name => CompilerFlavor -> PackageType -> DebBase -> name+mkPkgName' hc typ (DebBase base) =     pkgNameFromString $              case typ of                 Documentation -> prefix ++ base ++ "-doc"                 Development -> prefix ++ base ++ "-dev"                 Profiling -> prefix ++ base ++ "-prof"-                Utilities -> base {- ++ case cfl of+                Utilities -> base {- ++ case hc of                                           GHC -> ""-                                          _ -> "-" ++ map toLower (show cfl) -}+                                          _ -> "-" ++ map toLower (show hc) -}                 Exec -> base                 Source -> base                 HaskellSource -> "haskell-" ++ base                 Cabal -> base-    where prefix = "lib" ++ map toLower (show cfl) ++ "-"+    where prefix = "lib" ++ map toLower (show hc) ++ "-"  debianBaseName :: PackageName -> DebBase debianBaseName (PackageName name) =
src/Debian/Debianize/Files.hs view
@@ -1,13 +1,16 @@ -- | Convert a Debianization into a list of files that can then be -- written out.-{-# LANGUAGE FlexibleContexts, FlexibleInstances, OverloadedStrings, ScopedTypeVariables, TupleSections #-}+{-# LANGUAGE CPP, FlexibleContexts, FlexibleInstances, OverloadedStrings, ScopedTypeVariables, TupleSections #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Debian.Debianize.Files     ( debianizationFileMap     ) where  +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+import Data.Monoid (mempty)+#endif import Control.Lens import Control.Monad.Trans (lift) import Control.Monad.Writer (execWriterT, tell, WriterT)@@ -15,7 +18,7 @@ import Data.List as List (dropWhile, dropWhileEnd, map) import Data.Map as Map (fromListWithKey, insertWith, map, Map, mapKeys, toList) import Data.Maybe (fromMaybe)-import Data.Monoid ((<>), mempty)+import Data.Monoid ((<>)) import Data.Set as Set (fold, member, toList) import Data.Text as Text (dropWhile, dropWhileEnd, intercalate, lines, null, pack, strip, Text, unlines, unpack) import Debian.Control (Control'(Control, unControl), Field'(Field), Paragraph'(Paragraph))
src/Debian/Debianize/Finalize.hs view
@@ -6,7 +6,10 @@     ) where  +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+import Data.Monoid (mempty)+#endif import Control.Lens hiding ((<.>)) import Control.Monad (unless, when) import Control.Monad as List (mapM_)@@ -19,12 +22,12 @@ import Data.List as List (filter, intercalate, map, nub, null, unlines, maximumBy) import Data.Map as Map (delete, elems, insertWith, lookup, Map, toList) import Data.Maybe (fromMaybe, isJust, fromJust)-import Data.Monoid ((<>), mempty)+import Data.Monoid ((<>)) import Data.Set as Set (difference, filter, fold, fromList, insert, map, null, Set, singleton, toList, union, unions) import Data.Set.Extra as Set (mapM_) import Data.Text as Text (intercalate, pack, Text, unlines, unpack) import Debian.Changes (ChangeLog(..), ChangeLogEntry(..))-import Debian.Debianize.BasicInfo (cabalFlagAssignments, compilerChoice, verbosity)+import Debian.Debianize.BasicInfo (cabalFlagAssignments, compilerFlavor, verbosity) import qualified Debian.Debianize.BinaryDebDescription as B import Debian.Debianize.BuildDependencies (debianBuildDeps, debianBuildDepsIndep) import qualified Debian.Debianize.CabalInfo as A@@ -37,7 +40,7 @@ import Debian.Debianize.Prelude ((.?=)) import qualified Debian.Debianize.SourceDebDescription as S import Debian.Debianize.VersionSplits (DebBase(DebBase))-import Debian.GHC (CompilerChoice, hcFlavor)+import Debian.GHC (compilerPackageName) import Debian.Orphans () import Debian.Policy (getCurrentDebianUser, getDebhelperCompatLevel, haskellMaintainer, maintainerOfLastResort, PackageArchitectures(Any, All), PackagePriority(Extra), parseMaintainer, parseStandardsVersion, Section(..), SourceFormat(Native3)) import Debian.Pretty (PP(..), ppShow)@@ -91,10 +94,10 @@ -- 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 -> Bool -> CabalT m ()+finalizeDebianization'  :: (MonadIO 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 . compilerChoice)+       hc <- use (A.debInfo . D.flags . compilerFlavor)        pkgDesc <- use A.packageDescription         testsStatus <- use (A.debInfo . D.testsStatus)@@ -103,12 +106,11 @@          (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 ()-+       (A.debInfo . D.rulesSettings) %=+          (++ ["DEB_SETUP_BIN_NAME = " <> if setupExists then "debian/hlibrary.setup" else "cabal"])+         finalizeSourceName B.HaskellSource-       checkOfficialSettings (view hcFlavor hc)+       checkOfficialSettings hc        addExtraLibDependencies hc        (A.debInfo . D.watch) .?= Just (watchAtom (pkgName $ Cabal.package $ pkgDesc))        (A.debInfo . D.control . S.section) .?= Just (MainSection "haskell")@@ -212,10 +214,18 @@ finalizeSourceName :: (Monad m, Functor m) => B.PackageType -> CabalT m () finalizeSourceName typ =     do DebBase debName <- debianNameBase-       (A.debInfo . D.sourcePackageName) .?= Just (SrcPkgName (case typ of-                                                   B.HaskellSource -> "haskell-" ++ debName-                                                   B.Source -> debName-                                                   _ -> error $ "finalizeSourceName: " ++ show typ))+       hc <- use (A.debInfo . D.flags . compilerFlavor)+       (A.debInfo . D.sourcePackageName) .?=+          Just (SrcPkgName (case (hc, typ) of+                              -- Haskell source deb names conventionally have the prefix+                              -- "haskell-" added.  Here we add prefix "ghcjs-" to+                              -- haskell packages build with the ghcjs compiler.+                              (GHC, B.HaskellSource) -> "haskell-" ++ debName+#if MIN_VERSION_Cabal(1,22,0)+                              (GHCJS, B.HaskellSource) -> "ghcjs-" ++ debName+#endif+                              (_, B.Source) -> debName+                              _ -> error $ "finalizeSourceName: " ++ show typ))  -- | Try to compute a string for the the debian "Maintainer:" and -- "Uploaders:" fields using, in this order@@ -330,7 +340,7 @@ -- | Convert the extraLibs field of the cabal build info into debian -- binary package names and make them dependendencies of the debian -- devel package (if there is one.)-addExtraLibDependencies :: (Monad m, Functor m) => CompilerChoice -> CabalT m ()+addExtraLibDependencies :: (Monad m, Functor m) => CompilerFlavor -> CabalT m () addExtraLibDependencies hc =     do pkgDesc <- use A.packageDescription        devName <- debianName B.Development hc@@ -370,7 +380,7 @@               , S.VCSGit  "https://anonscm.debian.org/cgit/pkg-haskell/DHG_packages.git"               ]) -putBuildDeps :: (Monad m, Functor m) => (Relations -> Relations) -> PackageDescription -> CabalT m ()+putBuildDeps :: (MonadIO m, Functor m) => (Relations -> Relations) -> PackageDescription -> CabalT m () putBuildDeps finalizeRelations pkgDesc =     do deps <- debianBuildDeps pkgDesc >>= return . finalizeRelations        depsIndep <- debianBuildDepsIndep pkgDesc >>= return . finalizeRelations@@ -413,16 +423,16 @@       B.provides %= (anyrel "${haskell:Provides}" :)  -- | Add the library paragraphs for a particular compiler flavor.-librarySpecs :: (Monad m, Functor m) => PackageDescription -> CompilerChoice -> CabalT m ()+librarySpecs :: (Monad m, Functor m) => PackageDescription -> CompilerFlavor -> CabalT m () librarySpecs pkgDesc hc =     do let dev = isJust (Cabal.library pkgDesc)        doc <- get >>= return . not . view (A.debInfo . D.noDocumentationLibrary)        prof <- get >>= return . not . view (A.debInfo . D.noProfilingLibrary)        when dev (librarySpec Any B.Development hc)-       when (dev && prof && view hcFlavor hc == GHC) (librarySpec Any B.Profiling hc)+       when (dev && prof && hc == GHC) (librarySpec Any B.Profiling hc)        when (dev && doc) (docSpecsParagraph hc) -docSpecsParagraph :: (Monad m, Functor m) => CompilerChoice -> CabalT m ()+docSpecsParagraph :: (Monad m, Functor m) => CompilerFlavor -> CabalT m () docSpecsParagraph hc =     do b <- debianName B.Documentation hc        binaryPackageRelations b B.Documentation@@ -432,7 +442,7 @@        (A.debInfo . D.binaryDebDescription b . B.binarySection) .?= Just (MainSection "doc")        (A.debInfo . D.binaryDebDescription b . B.description) .?= Just desc -librarySpec :: (Monad m, Functor m) => PackageArchitectures -> B.PackageType -> CompilerChoice -> CabalT m ()+librarySpec :: (Monad m, Functor m) => PackageArchitectures -> B.PackageType -> CompilerFlavor -> CabalT m () librarySpec arch typ hc =     do b <- debianName typ hc        binaryPackageRelations b typ@@ -456,7 +466,7 @@ -- files, assign them to the packages returned by the -- utilsPackageNames lens, and make sure those packages are in the -- source deb description.-makeUtilsPackage :: forall m. (Monad m, Functor m) => PackageDescription -> CompilerChoice -> CabalT m ()+makeUtilsPackage :: forall m. (Monad m, Functor m) => PackageDescription -> CompilerFlavor -> CabalT m () makeUtilsPackage pkgDesc hc =     do -- Files the cabal package expects to be installed        -- Files that are already assigned to any binary deb@@ -519,7 +529,7 @@  expandAtoms :: Monad m => CabalT m () expandAtoms =-    do hc <- use (A.debInfo . D.flags . compilerChoice . hcFlavor)+    do hc <- use (A.debInfo . D.flags . compilerFlavor)        case hc of          GHC -> (A.debInfo . D.flags . cabalFlagAssignments) %= (Set.union (Set.fromList (flagList "--ghc"))) #if MIN_VERSION_Cabal(1,22,0)@@ -557,7 +567,7 @@       -- Turn A.InstallCabalExec into A.Install       expandInstallCabalExecs :: Monad m => FilePath -> CabalT m ()       expandInstallCabalExecs builddir = do-        hc <- use (A.debInfo . D.flags . compilerChoice . hcFlavor)+        hc <- use (A.debInfo . D.flags . compilerFlavor)         use (A.debInfo . D.atomSet) >>= Set.mapM_ (doAtom hc)           where             doAtom :: Monad m => CompilerFlavor -> D.Atom -> CabalT m ()@@ -577,7 +587,7 @@       -- Turn A.InstallCabalExecTo into a make rule       expandInstallCabalExecTo :: Monad m => FilePath -> CabalT m ()       expandInstallCabalExecTo builddir = do-        hc <- use (A.debInfo . D.flags . compilerChoice . hcFlavor)+        hc <- use (A.debInfo . D.flags . compilerFlavor)         use (A.debInfo . D.atomSet) >>= Set.mapM_ (doAtom hc)           where             doAtom :: Monad m => CompilerFlavor -> D.Atom -> CabalT m ()@@ -651,13 +661,14 @@              List.mapM_ (\ (b, f) -> modify (execAtoms b f)) (Map.toList mp)  -- | Add the normal default values to the rules files.-finalizeRules :: (Monad m, Functor m) => CabalT m ()+finalizeRules :: (MonadIO m, Functor m) => CabalT m () finalizeRules =     do DebBase b <- debianNameBase-       compiler <- use (A.debInfo . D.flags . compilerChoice . hcFlavor)+       hc <- use (A.debInfo . D.flags . compilerFlavor)+       let BinPkgName hcdeb = maybe (error "No compiler package") id (compilerPackageName hc B.Development)        (A.debInfo . D.rulesHead) .?= Just "#!/usr/bin/make -f"        (A.debInfo . D.rulesSettings) %= (++ ["DEB_CABAL_PACKAGE = " <> pack b])-       (A.debInfo . D.rulesSettings) %= (++ (["DEB_DEFAULT_COMPILER = " <> pack (List.map toLower (show compiler))]))+       (A.debInfo . D.rulesSettings) %= (++ ["DEB_DEFAULT_COMPILER = " <> pack hcdeb])        flags <- (flagString . Set.toList) <$> use (A.debInfo . D.flags . cabalFlagAssignments)        unless (List.null flags) ((A.debInfo . D.rulesSettings) %= (++ ["DEB_SETUP_GHC6_CONFIGURE_ARGS = " <> pack flags]))        (A.debInfo . D.rulesIncludes) %= (++ ["include /usr/share/cdbs/1/rules/debhelper.mk",
src/Debian/Debianize/Goodies.hs view
@@ -1,6 +1,6 @@ -- | Things that seem like they could be clients of this library, but -- are instead included as part of the library.-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP, OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-unused-do-bind #-} module Debian.Debianize.Goodies     ( tightDependencyFixup@@ -23,7 +23,10 @@ import Data.List as List (dropWhileEnd, intercalate, intersperse, map) import Data.Map as Map (insert, insertWith) import Data.Maybe (fromMaybe)-import Data.Monoid ((<>), mappend)+import Data.Monoid ((<>))+#if !MIN_VERSION_base(4,8,0)+import Data.Monoid (mappend)+#endif import Data.Set as Set (insert, singleton, union) import Data.Text as Text (pack, Text, unlines) import qualified Debian.Debianize.DebInfo as D
src/Debian/Debianize/InputCabal.hs view
@@ -12,18 +12,18 @@ import Control.Applicative ((<$>)) #endif import Data.Set as Set (toList)-import Debian.Debianize.BasicInfo (Flags, buildEnv, dependOS, verbosity, compilerChoice, cabalFlagAssignments)+import Debian.Debianize.BasicInfo (Flags, buildEnv, dependOS, verbosity, compilerFlavor, cabalFlagAssignments) import Debian.Debianize.Prelude (intToVerbosity')-import Debian.GHC (hcFlavor) #if MIN_VERSION_Cabal(1,22,0) import Debian.GHC (getCompilerInfo) #else import Debian.GHC (newestAvailableCompilerId) #endif import Debian.Orphans ()-import Distribution.Compiler (CompilerId) #if MIN_VERSION_Cabal(1,22,0) import Distribution.Compiler (CompilerInfo)+#else+import Distribution.Compiler (CompilerId) #endif import Distribution.Package (Package(packageId)) import Distribution.PackageDescription as Cabal (PackageDescription)@@ -73,9 +73,9 @@ getCompInfo :: MonadIO m => Flags -> WithProcAndSys m (Either String CompilerInfo) getCompInfo flags = #if MIN_VERSION_Cabal(1,22,0)-              getCompilerInfo root (view (compilerChoice . hcFlavor) flags)+              getCompilerInfo root (view compilerFlavor flags) #else-              return $ newestAvailableCompilerId root (view compilerChoice flags)+              return $ newestAvailableCompilerId root (view compilerFlavor flags) #endif     where       root = dependOS $ view buildEnv flags
src/Debian/Debianize/InputDebian.hs view
@@ -18,7 +18,10 @@ import Data.Char (isSpace) import Data.Map as Map (insert, insertWith) import Data.Maybe (fromMaybe)-import Data.Monoid ((<>), mappend)+import Data.Monoid ((<>))+#if !MIN_VERSION_base(4,8,0)+import Data.Monoid (mappend)+#endif import Data.Set as Set (fromList, insert, singleton) import Data.Text (break, lines, null, pack, strip, Text, unpack, words) import Data.Text.IO (readFile)
src/Debian/Debianize/Optparse.hs view
@@ -15,7 +15,11 @@   parseProgramArguments,   parseProgramArguments',   handleBehaviorAdjustment) where-import Control.Applicative ((<$>), (<*>), many, pure, (<|>))++#if !MIN_VERSION_base(4,8,0)+import Control.Applicative ((<$>), (<*>), pure)+#endif+import Control.Applicative (many, (<|>)) import Control.Lens import Control.Monad.State.Class (MonadState) import Control.Monad.Trans@@ -23,18 +27,15 @@ import Data.Bifunctor (first) import Data.Char(toUpper) import Data.Foldable (forM_)-import Data.List (nub) import Data.Maybe.Extended (fromMaybe) import Data.Maybe.Extended (nothingIf) import Data.Monoid ((<>))-import Data.Version (Version, parseVersion)-import Debian.Debianize.BasicInfo-import Debian.Debianize.Bundled (parseVersion')+import Debian.Debianize.BasicInfo (EnvSet(EnvSet), cleanOS, dependOS, buildOS, Flags(..)) import Debian.Debianize.DebInfo (TestsStatus(..)) import Debian.Debianize.Monad import Debian.Debianize.Prelude (maybeRead) import Debian.Debianize.VersionSplits-import Debian.GHC (CompilerChoice(..), CompilerVendor(..))+import Debian.GHC () import Debian.Policy import Debian.Relation import Debian.Version (DebianVersion, parseDebianVersion')@@ -44,9 +45,7 @@ import GHC.Generics import System.Environment (getArgs) import System.FilePath(splitFileName, (</>))-import System.Posix.Env (getEnv) import System.Process (showCommandForUser)-import Text.ParserCombinators.ReadP (readP_to_S) import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr(..)) import Text.PrettyPrint.ANSI.Leijen (linebreak, (<+>), string, indent) import qualified  Debian.Debianize.DebInfo as D@@ -524,7 +523,7 @@                <*> upgradeP                <*> roundtripP                <*> pure False     -- validate-               <*> (CompilerChoice <$> hvrghcP <*> ghcjsP)         -- CompilerChoice+               <*> hcFlavorP         -- CompilerFlavor                <*> (flagSet <$> cabalFlagsP)    -- cabalFlagAssignments                <*> buildEnvDirP     where@@ -567,18 +566,11 @@     "Roundtrip a debianization to normalize it."     ] -versionR :: O.ReadM Version-versionR = (maybe (error "Invalid compiler version") id . parseVersion') <$> O.str--hvrghcP :: O.Parser CompilerVendor-hvrghcP = O.option (HVR <$> versionR) m where-  m = O.help "Use HVR's debian repository"-      <> O.long "hvr-version"-      <> O.value Debian-      <> O.metavar "VERSION"+-- versionR :: O.ReadM Version+-- versionR = (maybe (error "Invalid compiler version") id . parseVersion') <$> O.str -ghcjsP :: O.Parser CompilerFlavor-ghcjsP = O.flag GHC+hcFlavorP :: O.Parser CompilerFlavor+hcFlavorP = O.flag GHC #if MIN_VERSION_Cabal(1,22,0)                     GHCJS #else@@ -674,9 +666,9 @@ parseProgramArguments = getArgs >>= parseProgramArguments' . leaveOne "--disable-haddock"     where       leaveOne :: String -> [String] -> [String]-      leaveOne s xs = go s False xs+      leaveOne s xs = go False xs           where-            go _ _ [] = []-            go s False (x : xs) | x == s = x : go s True xs-            go s True (x : xs) | x == s = go s True xs-            go s flag (x : xs) = x : go s flag xs+            go _ [] = []+            go False (x : xs') | x == s = x : go True xs'+            go True (x : xs') | x == s = go True xs'+            go flag (x : xs') = x : go flag xs'
src/Debian/Debianize/Output.hs view
@@ -44,7 +44,7 @@ import System.IO (hPutStrLn, stderr) import System.Process (readProcessWithExitCode, showCommandForUser) import Text.PrettyPrint.HughesPJClass (text)-import System.Posix.Env (setEnv)+-- import System.Posix.Env (setEnv)  -- | Run the script in @debian/Debianize.hs@ with the given command -- line arguments.  Returns @True@ if the script exists and succeeds.
src/Debian/GHC.hs view
@@ -9,28 +9,29 @@     -- , ghcNewestAvailableVersion'     -- , ghcNewestAvailableVersion     -- , compilerIdFromDebianVersion-    , CompilerVendor (Debian, HVR)     , hvrCabalVersion     , hvrHappyVersion     , hvrAlexVersion-    , compilerPATH-    , withCompilerPATH+    , hvrCompilerPATH+    , isHVRCompilerPackage     , withModifiedPATH-    , CompilerChoice(..), hcVendor, hcFlavor+    -- , CompilerChoice(..), hcVendor, hcFlavor     , compilerPackageName #if MIN_VERSION_Cabal(1,22,0)     , getCompilerInfo #endif     ) where +#if !MIN_VERSION_base(4,8,0)+import Control.Applicative ((<$>))+#endif import Control.DeepSeq (force) import Control.Exception (SomeException, throw, try)-import Control.Lens (makeLenses)+import Control.Lens (_2, over) import Control.Monad.Trans (MonadIO, liftIO)-import Data.Char (isSpace, {-toLower,-} toUpper)-import Data.Function.Memoize (deriveMemoizable, memoize2)-import Data.Generics (Data, Typeable)-import Data.List (intercalate)+import Data.Char (isSpace, toLower, toUpper)+import Data.Function.Memoize (deriveMemoizable, memoize, memoize2)+import Data.List (intercalate, isPrefixOf) import Data.Version (showVersion, Version(..), parseVersion) import Debian.Debianize.BinaryDebDescription (PackageType(..)) import Debian.Relation (BinPkgName(BinPkgName))@@ -51,43 +52,50 @@ import System.Unix.Mount (WithProcAndSys) import Text.ParserCombinators.ReadP (readP_to_S) import Text.Read (readMaybe)+import Text.Regex.TDFA ((=~))  $(deriveMemoizable ''CompilerFlavor) $(deriveMemoizable ''Version) $(deriveMemoizable ''BinPkgName)-deriving instance Data CompilerVendor-deriving instance Typeable CompilerVendor --- | Up until now this system only worked with Debian's or Ubuntu's--- ghc source package, which has binary package names ghc, ghc-prof,--- ghc-doc, etc.  This type is intended to add support for Herbert--- Valerio Riedel's (hvr's) repository of several different versions--- of ghc and supporting tools happy, alex and cabal.  These have--- different binary package names, and the packages put the--- executables in different locations than the Debian (and Ubuntu)--- packages.  This option is activated by the --hvr-version option to--- cabal-debian.-data CompilerChoice =-    CompilerChoice { _hcVendor :: CompilerVendor-                   , _hcFlavor :: CompilerFlavor-                   } deriving (Eq, Ord, Show, Data, Typeable)-data CompilerVendor = Debian | HVR Version deriving (Eq, Ord, Show)+-- | Up until now cabal-debian only worked with Debian's or Ubuntu's+-- ghc debs, which have binary package names ghc, ghc-prof, ghc-doc,+-- etc.  This type is intended to add support for Herbert Valerio+-- Riedel's (hvr's) repository of several different versions of ghc+-- and supporting tools happy, alex and cabal.  These have different+-- binary package names, and the packages put the executables in+-- different locations than the Debian (and Ubuntu) packages.  This+-- option is activated when a directory such as /opt/ghc/8.0.1/bin is+-- present in $PATH and a ghc executable is found there.+--+-- This function decides whether a deb name is that of one of+-- debian/ubuntu's ghc packages or one of hvr's.  If it is an hvr+-- package it returns the version number embedded in its name.+isHVRCompilerPackage :: CompilerFlavor -> BinPkgName -> Maybe Version+isHVRCompilerPackage hc (BinPkgName name) =+    case isPrefixOf prefix name of+      True -> toVersion (takeWhile (/= '-') (drop (length prefix) name))+      False -> Nothing+      where+        prefix = map toLower (show hc) ++ "-" -withCompilerVersion :: FilePath -> CompilerChoice -> (Either String DebianVersion -> a) -> a-withCompilerVersion root hc f = f (newestAvailableCompiler root hc)+toVersion :: String -> Maybe Version+toVersion s = case filter (all isSpace . snd) (readP_to_S parseVersion s) of+                [(v, _)] -> Just v+                _ -> Nothing -withCompilerPATH :: MonadIO m => CompilerVendor -> m a -> m a-withCompilerPATH vendor action = withModifiedPATH (compilerPATH vendor) action+withCompilerVersion :: FilePath -> CompilerFlavor -> (DebianVersion -> a) -> Either String a+withCompilerVersion root hc f = either Left (\v -> Right (f v)) (newestAvailableCompiler root hc) -compilerPATH :: CompilerVendor -> String -> String-compilerPATH vendor path0 = do-  case vendor of-    Debian -> path0-    HVR v -> (intercalate ":" ["/opt/ghc/" ++ showVersion v ++ "/bin",-                               "/opt/cabal/" ++ showVersion (hvrCabalVersion v) ++ "/bin",-                               "/opt/happy/" ++ showVersion (hvrHappyVersion v) ++ "/bin",-                               "/opt/alex/" ++ showVersion (hvrAlexVersion v) ++ "/bin",-                               path0])+-- | Return the a string containing the PATH environment variable value+-- suitable for using some version of ghc from hvr's compiler repo.+hvrCompilerPATH :: Version -> String -> String+hvrCompilerPATH v path0 =+    intercalate ":" ["/opt/ghc/" ++ showVersion v ++ "/bin",+                     "/opt/cabal/" ++ showVersion (hvrCabalVersion v) ++ "/bin",+                     "/opt/happy/" ++ showVersion (hvrHappyVersion v) ++ "/bin",+                     "/opt/alex/" ++ showVersion (hvrAlexVersion v) ++ "/bin",+                     path0]  -- | What version of Cabal goes with this version of GHC? hvrCabalVersion :: Version -> Version@@ -143,11 +151,11 @@           chroot "/" = id           chroot _ = useEnv root (return . force) -newestAvailableCompiler :: FilePath -> CompilerChoice -> Either String DebianVersion-newestAvailableCompiler root hc = newestAvailable root (compilerPackageName hc Development)+newestAvailableCompiler :: FilePath -> CompilerFlavor -> Either String DebianVersion+newestAvailableCompiler root hc = maybe (Left "No compiler package") (newestAvailable root) (compilerPackageName hc Development) -newestAvailableCompilerId :: FilePath -> CompilerChoice -> Either String CompilerId-newestAvailableCompilerId root hc@(CompilerChoice _ flavor) = fmap (compilerIdFromDebianVersion flavor) (newestAvailableCompiler root hc)+newestAvailableCompilerId :: FilePath -> CompilerFlavor -> Either String CompilerId+newestAvailableCompilerId root hc = either Left (Right . compilerIdFromDebianVersion hc) (newestAvailableCompiler root hc)  {- -- | The IO portion of ghcVersion.  For there to be no version of ghc@@ -214,24 +222,62 @@       s -> Just (BinPkgName s) -} -compilerPackageName :: CompilerChoice -> PackageType -> BinPkgName-compilerPackageName (CompilerChoice Debian GHC) Documentation = BinPkgName "ghc-doc"-compilerPackageName (CompilerChoice Debian GHC) Profiling = BinPkgName "ghc-prof"-compilerPackageName (CompilerChoice Debian GHC) Development = BinPkgName "ghc"-compilerPackageName (CompilerChoice Debian GHC) _ = BinPkgName "ghc" -- whatevs-compilerPackageName (CompilerChoice (HVR v) GHC) Documentation = BinPkgName ("ghc-" ++ showVersion v ++ "-htmldocs")-compilerPackageName (CompilerChoice (HVR v) GHC) Profiling = BinPkgName ("ghc-" ++ showVersion v ++ "-prof")-compilerPackageName (CompilerChoice (HVR v) GHC) Development = BinPkgName ("ghc-" ++ showVersion v)-compilerPackageName (CompilerChoice (HVR v) GHC) _ = BinPkgName ("ghc-" ++ showVersion v)+-- | Compute the compiler package names by finding out what package+-- contains the corresponding executable.+compilerPackageName :: CompilerFlavor -> PackageType -> Maybe BinPkgName+compilerPackageName hc typ =+    maybe Nothing (Just . finish) (compilerPackage hc)+    where+      finish (BinPkgName hcname) =+          let isDebian = map toLower (show hc) == hcname in+          -- hcname is the package that contains the compiler+          -- executable.  This will be ghc or ghcjs for Debian+          -- packages, anything else is an hvr package.+          case (hc, typ, isDebian) of+            -- Debian puts the .haddock files in ghc-doc+            (GHC, Documentation, True) -> BinPkgName (hcname ++ "-doc")+            -- In HVR repo the .haddock files required to buid html+            -- are in the main compiler package+            (GHC, Documentation, False) -> BinPkgName hcname+            (GHC, Profiling, _) -> BinPkgName (hcname ++ "-prof")+            _ -> BinPkgName hcname++compilerPackage :: CompilerFlavor -> Maybe BinPkgName+compilerPackage GHC = filePackage "ghc" #if MIN_VERSION_Cabal(1,22,0)-compilerPackageName (CompilerChoice _ GHCJS) Documentation = BinPkgName "ghcjs"-compilerPackageName (CompilerChoice _ GHCJS) Profiling = error "Profiling not supported for GHCJS"-compilerPackageName (CompilerChoice _ GHCJS) Development = BinPkgName "ghcjs"-compilerPackageName (CompilerChoice _ GHCJS) _ = BinPkgName "ghcjs" -- whatevs+compilerPackage GHCJS = filePackage "ghcjs" #endif-compilerPackageName hc _ = error $ "Unsupported compiler flavor: " ++ show hc+compilerPackage x = error $ "compilerPackage - unsupported CompilerFlavor: " ++ show x +{-+compilerExecutable :: CompilerFlavor -> String+compilerExecutable GHC = "ghc" #if MIN_VERSION_Cabal(1,22,0)+compilerExecutable GHCJS = "ghcjs"+#endif+compilerExecutable x = error $ "compilerExecutable - unexpected flavor: " ++ show x+-}++filePackage :: FilePath -> Maybe BinPkgName+filePackage = memoize f+    where+      f :: FilePath -> Maybe BinPkgName+      f p = unsafePerformIO (which p >>= maybe (return Nothing) (\x -> package <$> readProcess "dpkg-query" ["-S", x] ""))+      package :: String -> Maybe BinPkgName+      package s =+          case s =~ "^(.*): .*$" :: (String, String, String, [String]) of+            (_, _, _, [name]) -> Just (BinPkgName name)+            _ -> Nothing++which :: String -> IO (Maybe FilePath)+which bin = do+  (toPath . over _2 lines) <$> readProcessWithExitCode "which" [bin] ""+    where+      toPath :: (ExitCode, [String], String) -> Maybe String+      toPath (ExitSuccess, [path], _) = Just path+      toPath _ = Nothing++#if MIN_VERSION_Cabal(1,22,0) -- | IO based alternative to newestAvailableCompilerId - install the -- compiler into the chroot if necessary and ask it for its version -- number.  This has the benefit of working for ghcjs, which doesn't@@ -251,33 +297,29 @@     Right (_, out, _) -> do       let compilerId = maybe (error $ "Parse error in version string: " ++ show out) (CompilerId flavor) (toVersion out)       compilerCompat <- case flavor of+#if MIN_VERSION_Cabal(1,22,0)                           GHCJS -> do                             (r' :: Either IOError (ExitCode, String, String)) <- try $ readProcessWithExitCode (hcCommand flavor) ["--numeric-ghc-version"] ""                             case r' of                               Right (ExitSuccess, out', _) ->                                   maybe (error $ "getCompilerInfo - parse error in version string: " ++ show out') (return . Just . (: []) . CompilerId GHC) (toVersion out')                               _ -> error "getCompilerInfo - failure computing compilerCompat"+#endif                           _ -> return Nothing       return $ Right $ (unknownCompilerInfo compilerId NoAbiTag) {compilerInfoCompat = compilerCompat} -toVersion :: String -> Maybe Version-toVersion s = case filter (all isSpace . snd) (readP_to_S parseVersion s) of-                [(v, _)] -> Just v-                _ -> Nothing- processErrorMessage :: String -> String -> [String] -> (ExitCode, String, String) -> String processErrorMessage msg cmd args (ExitFailure n, out, err) =     msg ++ " - " ++ showCommandForUser cmd args ++ " -> " ++ show n ++ "\n stdout: " ++ indent out ++ "\n stderr: " ++ indent err     where       indent :: String -> String       indent = intercalate "\n         " . lines+processErrorMessage _msg _cmd _args (ExitSuccess, _out, _err) = ""  hcCommand :: CompilerFlavor -> String hcCommand GHC = "ghc"+#if MIN_VERSION_Cabal(1,22,0) hcCommand GHCJS = "ghcjs"+#endif hcCommand flavor = error $ "hcCommand - unexpected CompilerFlavor: " ++ show flavor #endif--$(makeLenses ''CompilerChoice)-$(deriveMemoizable ''CompilerVendor)-$(deriveMemoizable ''CompilerChoice)
src/Distribution/Version/Invert.hs view
@@ -8,7 +8,7 @@ #if MIN_VERSION_Cabal(1,24,0) import Distribution.Version (invertVersionRange, invertVersionIntervals) #else-import Distribution.Version (Version(Version, versionBranch, versionTags), VersionRange, fromVersionIntervals, asVersionIntervals, mkVersionIntervals,+import Distribution.Version (Version(Version), VersionRange, fromVersionIntervals, asVersionIntervals, mkVersionIntervals,                              LowerBound(LowerBound), UpperBound(UpperBound, NoUpperBound), Bound(InclusiveBound, ExclusiveBound))  -- | This function belongs in Cabal, see http://hackage.haskell.org/trac/hackage/ticket/935.@@ -19,7 +19,7 @@ invertVersionIntervals xs =     case xs of       [] -> [(lb0, NoUpperBound)]-      ((LowerBound (Version {versionBranch = [0], versionTags = []}) InclusiveBound, ub) : more) ->+      ((LowerBound (Version [0] []) InclusiveBound, ub) : more) ->           invertVersionIntervals' ub more       ((lb, ub) : more) ->           (lb0, invertLowerBound lb) : invertVersionIntervals' ub more@@ -42,5 +42,5 @@       invertBound InclusiveBound = ExclusiveBound        lb0 :: LowerBound-      lb0 = LowerBound (Version {versionBranch = [0], versionTags = []}) InclusiveBound+      lb0 = LowerBound (Version [0] []) InclusiveBound #endif
+ src/System/Git.hs view
@@ -0,0 +1,59 @@+-- | Git related functions that belong in some other package.++{-# LANGUAGE CPP, ScopedTypeVariables #-}++module System.Git+    ( gitResetHard+    , gitResetSubdir+    , gitUnclean+    , gitIsClean+    , withCleanRepo+    ) where++#if !MIN_VERSION_base(4,8,0)+import Control.Applicative (pure, (<$>))+#endif +import Control.Exception (catch, SomeException, throw)+import System.Directory (getCurrentDirectory)+import System.Exit (ExitCode(ExitSuccess, ExitFailure))+import System.IO (hPutStrLn, stderr)+import System.Process (readProcessWithExitCode, readProcess)++-- | Do a hard reset of all the files of the repository containing the+-- working directory.+gitResetHard :: IO ()+gitResetHard = do+  (code, _out, _err) <- readProcessWithExitCode "git" ["reset", "--hard"] ""+  case code of+    ExitSuccess -> pure ()+    ExitFailure _n -> error "gitResetHard"++-- | Do a hard reset of all the files of a subdirectory within a git+-- repository.  (Does this every throw an exception?)+gitResetSubdir :: FilePath -> IO ()+gitResetSubdir dir = do+  (readProcess "git" ["checkout", "--", dir] "" >>+   readProcess "git" ["clean", "-f", dir] "" >> pure ())+    `catch` \(e :: SomeException) -> hPutStrLn stderr ("gitResetSubdir " ++ show dir ++ " failed: " ++ show e) >> throw e++-- | Determine whether the repository containing the working directory+-- is in a modified state, if so return the messages.+gitUnclean :: IO (Maybe String)+gitUnclean = do+  here <- getCurrentDirectory+  hPutStrLn stderr ("here: " ++ show here)+  (code, out, _err) <- readProcessWithExitCode "git" ["status", "--porcelain"] ""+  case code of+    ExitFailure _ -> error "gitCheckClean failure"+    ExitSuccess | all unmodified (lines out) -> pure Nothing+    ExitSuccess -> pure $ Just out+    where+      unmodified (a : b : _) = elem a "?! " && elem b "?! "+      unmodified _ = False++gitIsClean :: IO Bool+gitIsClean = maybe True (const False) <$> gitUnclean++withCleanRepo :: IO a -> IO a+withCleanRepo action = do+  gitUnclean >>= maybe action (\s -> error $ "withCleanRepo: please commit or revert changes:\n" ++ s)
test-data/alex/output/debian/control view
@@ -3,7 +3,7 @@ Section: haskell Maintainer: Simon Marlow <marlowsd@gmail.com> Build-Depends: debhelper (>= 9),-               haskell-devscripts (>= 0.8),+               haskell-devscripts-minimal | haskell-devscripts (>= 0.8),                cdbs,                ghc,                ghc-prof,
test-data/archive/output/debian/control view
@@ -3,7 +3,7 @@ Maintainer: David Fox <dsf@seereason.com> Section: haskell Build-Depends: debhelper (>= 9)-               , haskell-devscripts (>= 0.8)+               , haskell-devscripts-minimal | haskell-devscripts (>= 0.8)                , cdbs                , ghc 	       , ghc-prof
test-data/artvaluereport-data/output/debian/control view
@@ -3,7 +3,7 @@ Section: haskell Maintainer: David Fox <dsf@seereason.com> Build-Depends: debhelper (>= 9)-               , haskell-devscripts (>= 0.8)+               , haskell-devscripts-minimal | haskell-devscripts (>= 0.8)                , cdbs                , ghc                , ghc-prof
test-data/artvaluereport2/output/debian/control view
@@ -3,7 +3,7 @@ Section: haskell Maintainer: Clifford Beshers <beshers@seereason.com> Build-Depends: debhelper (>= 9)-               , haskell-devscripts (>= 0.8)+               , haskell-devscripts-minimal | haskell-devscripts (>= 0.8)                , cdbs                , ghc                , ghc-prof
test-data/clckwrks-dot-com/output/debian/control view
@@ -3,10 +3,10 @@ Priority: extra Section: haskell Build-Depends: debhelper (>= 9)-               , haskell-devscripts (>= 0.8)+               , haskell-devscripts-minimal | haskell-devscripts (>= 0.8)                , cdbs-               , ghc-7.6.3-               , ghc-7.6.3-prof+               , ghc+               , ghc-prof                , libghc-clckwrks-dev (>= 0.13)                , libghc-clckwrks-dev (<< 0.15)                , libghc-clckwrks-plugin-bugs-dev (>= 0.3)
test-data/creativeprompts/output/debian/control view
@@ -3,10 +3,10 @@ Priority: extra Section: haskell Build-Depends: debhelper (>= 9)-	       , haskell-devscripts (>= 0.8)+	       , haskell-devscripts-minimal | haskell-devscripts (>= 0.8) 	       , cdbs-               , ghc-7.6.3-               , ghc-7.6.3-prof+               , ghc+               , ghc-prof                , libghc-extra-dev                , libghc-hjscript-dev                , libghc-http-dev