cabal-debian 4.1.1 → 4.3.1
raw patch · 15 files changed
+263/−160 lines, 15 filesdep +Unixutilsdep +deepseqdep −bytestringdep −networkdep −old-localesetup-changed
Dependencies added: Unixutils, deepseq
Dependencies removed: bytestring, network, old-locale, process-listlike, regex-compat, time
Files
- Setup.hs +1/−1
- cabal-debian.cabal +26/−20
- changelog +23/−1
- src/CabalDebian.hs +5/−2
- src/Debian/Debianize/BuildDependencies.hs +34/−15
- src/Debian/Debianize/Bundled.hs +72/−31
- src/Debian/Debianize/Finalize.hs +7/−7
- src/Debian/Debianize/Input.hs +44/−31
- src/Debian/Debianize/Options.hs +7/−11
- src/Debian/Debianize/Output.hs +5/−4
- src/Debian/Debianize/SubstVars.hs +21/−12
- src/Debian/Debianize/Tests.hs +2/−1
- src/Debian/Debianize/Types.hs +2/−2
- src/Debian/Debianize/Types/Atoms.hs +10/−21
- src/Debian/Orphans.hs +4/−1
Setup.hs view
@@ -4,7 +4,7 @@ import Distribution.Simple import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(buildDir)) import Distribution.Simple.Program-import System.Cmd+import System.Process import System.Directory import System.Exit
cabal-debian.cabal view
@@ -1,5 +1,5 @@ Name: cabal-debian-Version: 4.1.1+Version: 4.3.1 License: BSD3 License-File: debian/copyright Author: David Fox <dsf@seereason.com>@@ -140,10 +140,10 @@ Default: False Manual: True -flag local-debian- Description: Link directly to the source of the debian library- Default: False- Manual: True+-- flag local-debian+-- Description: Link directly to the source of the debian library+-- Default: False+-- Manual: True Source-Repository head type: darcs@@ -158,6 +158,7 @@ containers, data-lens, data-lens-template,+ deepseq, Diff, directory, filepath,@@ -172,6 +173,7 @@ syb, text, unix,+ Unixutils, utf8-string Exposed-Modules: Data.Algorithm.Diff.Context@@ -201,11 +203,11 @@ Debian.Debianize.VersionSplits Other-Modules: Debian.Orphans- if flag(local-debian)- Hs-Source-Dirs: ., haskell-debian- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time- else- Build-depends: debian >= 3.81+-- if flag(local-debian)+-- Hs-Source-Dirs: ., ../../haskell-debian+-- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time+-- else+ Build-depends: debian >= 3.81 Executable cabal-debian Hs-Source-Dirs: src@@ -218,6 +220,7 @@ data-lens, data-lens-template, debian,+ deepseq, Diff, directory, filepath,@@ -231,12 +234,13 @@ syb, text, unix,+ Unixutils, utf8-string- if flag(local-debian)- Hs-Source-Dirs: ., haskell-debian- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time- else- Build-Depends: debian >= 3.81+-- if flag(local-debian)+-- Hs-Source-Dirs: ., ../../haskell-debian+-- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time+-- else+ Build-Depends: debian >= 3.81 Executable cabal-debian-tests Hs-Source-Dirs: src@@ -249,6 +253,7 @@ data-lens, data-lens-template, debian,+ deepseq, Diff, directory, filepath,@@ -263,9 +268,10 @@ syb, text, unix,+ Unixutils, utf8-string- if flag(local-debian)- Hs-Source-Dirs: ., haskell-debian- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time- else- Build-depends: debian >= 3.81+-- if flag(local-debian)+-- Hs-Source-Dirs: ., ../../haskell-debian+-- Build-Depends: regex-compat, bytestring, process-listlike, network, old-locale, time+-- else+ Build-depends: debian >= 3.81
changelog view
@@ -1,4 +1,26 @@-haskell-cabal-debian (4.1) unstable; urgency=low+haskell-cabal-debian (4.3.1) unstable; urgency=low++ * Safer default value for buildEnv - "/" instead of "". This is+ where we look for the GHC version number.++ -- David Fox <dsf@seereason.com> Thu, 27 Mar 2014 06:12:28 -0700++haskell-cabal-debian (4.3) unstable; urgency=low++ * Make the default value for buildEnv "/", this makes it normally look+ at the version number of the ghc compiler installed in the root+ environment.++ -- David Fox <dsf@seereason.com> Mon, 24 Mar 2014 06:01:49 -0700++haskell-cabal-debian (4.2) unstable; urgency=low++ * Get the GHC compiler version from the build environment, which+ now needs to be explicitly set.++ -- David Fox <dsf@seereason.com> Fri, 07 Mar 2014 10:58:37 -0800++haskell-cabal-debian (4.1.1) unstable; urgency=low * Remove build dependency on ansi-wl-pprint. * Split module Debian.Debianize.BuildDependencies out of
src/CabalDebian.hs view
@@ -6,7 +6,7 @@ -- be accessed using the command line interface. import Control.Monad.State (get, lift)-import Data.Lens.Lazy (getL)+import Data.Lens.Lazy (getL, access) import Data.List as List (unlines) import Debian.Debianize.Details (debianDefaultAtoms) import Debian.Debianize.Finalize (debianization)@@ -15,7 +15,7 @@ import Debian.Debianize.Output (doDebianizeAction) import Debian.Debianize.SubstVars (substvars) import Debian.Debianize.Types (Top(Top))-import Debian.Debianize.Types.Atoms (DebAction(Debianize, SubstVar, Usage), debAction, newAtoms)+import Debian.Debianize.Types.Atoms (DebAction(Debianize, SubstVar, Usage), debAction, newAtoms, buildEnv) import Prelude hiding (unlines, writeFile, init) import System.Console.GetOpt (usageInfo) import System.Environment (getProgName)@@ -32,8 +32,11 @@ -- This picks up the options required to decide what action we are -- taking. Much of this will be repeated in the call to debianize. evalDebT (init >> compileEnvironmentArgs >> compileCommandlineArgs >>+ testBuildEnv >> get >>= return . getL debAction >>= finish) newAtoms where+ testBuildEnv = access buildEnv >>= \ root -> if root == "" then error ("Invalid build environment: " ++ show root) else return ()+ finish (SubstVar debType) = substvars top debType finish Debianize = debianization top (return ()) (return ()) >> doDebianizeAction top finish Usage = do
src/Debian/Debianize/BuildDependencies.hs view
@@ -6,6 +6,7 @@ ) where import Control.Monad.State (MonadState(get))+import Control.Monad.Trans (MonadIO, liftIO) import Data.Char (isSpace) import Data.Function (on) import Data.Lens.Lazy (access, getL)@@ -14,11 +15,12 @@ import Data.Maybe (catMaybes, fromMaybe) import Data.Set as Set (singleton) import qualified Data.Set as Set (member)-import Data.Version (showVersion, Version)+import Data.Version (showVersion, Version(Version)) import Debian.Debianize.Bundled (ghcBuiltIn) import Debian.Debianize.DebianName (mkPkgName, mkPkgName')+import Debian.Debianize.Input (ghcVersion') import Debian.Debianize.Monad as Monad (Atoms, DebT)-import qualified Debian.Debianize.Types as T (buildDepends, buildDependsIndep, compiler, debianNameMap, epochMap, execMap, extraLibMap, missingDependencies, noDocumentationLibrary, noProfilingLibrary)+import qualified Debian.Debianize.Types as T (buildDepends, buildDependsIndep, debianNameMap, epochMap, execMap, extraLibMap, missingDependencies, noDocumentationLibrary, noProfilingLibrary, buildEnv) import qualified Debian.Debianize.Types.BinaryDebDescription as B (PackageType(Development, Documentation, Profiling)) import Debian.Debianize.VersionSplits (packageRangesFromVersionSplits) import Debian.Orphans ()@@ -29,6 +31,7 @@ import Distribution.PackageDescription (PackageDescription) import Distribution.PackageDescription as Cabal (allBuildInfo, BuildInfo(..), BuildInfo(buildTools, extraLibs, pkgconfigDepends), Executable(..)) import qualified Distribution.PackageDescription as Cabal (PackageDescription(buildDepends, executables, package))+import Distribution.Simple.Compiler import Distribution.Version (anyVersion, asVersionIntervals, earlierVersion, foldVersionRange', fromVersionIntervals, intersectVersionRanges, isNoVersion, laterVersion, orEarlierVersion, orLaterVersion, toVersionIntervals, unionVersionRanges, VersionRange, withinVersion) import Distribution.Version.Invert (invertVersionRange) import Prelude hiding (init, log, map, unlines, unlines, writeFile)@@ -74,7 +77,7 @@ -- The haskell-cdbs package contains the hlibrary.mk file with -- the rules for building haskell packages.-debianBuildDeps :: Monad m => PackageDescription -> DebT m D.Relations+debianBuildDeps :: MonadIO m => PackageDescription -> DebT m D.Relations debianBuildDeps pkgDesc = do deb <- get cDeps <- cabalDeps@@ -97,7 +100,7 @@ (concatMap extraLibs . allBuildInfo $ pkgDesc) mapM buildDependencies (List.filter (not . selfDependency (Cabal.package pkgDesc)) deps) >>= return . concat -debianBuildDepsIndep :: Monad m => PackageDescription -> DebT m D.Relations+debianBuildDepsIndep :: MonadIO m => PackageDescription -> DebT m D.Relations debianBuildDepsIndep pkgDesc = do doc <- get >>= return . (/= singleton True) . getL T.noDocumentationLibrary bDeps <- get >>= return . getL T.buildDependsIndep@@ -127,14 +130,14 @@ -- | The documentation dependencies for a package include the -- documentation package for any libraries which are build -- dependencies, so we have access to all the cross references.-docDependencies :: Monad m => Dependency_ -> DebT m D.Relations+docDependencies :: MonadIO m => Dependency_ -> DebT m D.Relations docDependencies (BuildDepends (Dependency name ranges)) = dependencies B.Documentation name ranges docDependencies _ = return [] -- | 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 => Dependency_ -> DebT m D.Relations+buildDependencies :: MonadIO m => Dependency_ -> DebT m D.Relations buildDependencies (BuildDepends (Dependency name ranges)) = do dev <- dependencies B.Development name ranges prof <- dependencies B.Profiling name ranges@@ -187,7 +190,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 => B.PackageType -> PackageName -> VersionRange -> DebT m Relations+dependencies :: MonadIO m => B.PackageType -> PackageName -> VersionRange -> DebT m Relations dependencies typ name cabalRange = do atoms <- get -- Compute a list of alternative debian dependencies for@@ -199,10 +202,10 @@ Nothing -> [(mkPkgName name typ, cabalRange')] -- If there are splits create a list of (debian package name, VersionRange) pairs Just splits' -> List.map (\ (n, r) -> (mkPkgName' n typ, r)) (packageRangesFromVersionSplits splits')- mapM convert alts >>= mapM (doBundled typ name) . convert' . canonical . Or . catMaybes+ mapM (convert name) alts >>= mapM (doBundled typ name) . convert' . canonical . Or . catMaybes where- convert :: Monad m => (BinPkgName, VersionRange) -> DebT m (Maybe (Rels Relation))- convert (dname, range) =+ convert :: Monad m => PackageName -> (BinPkgName, VersionRange) -> DebT m (Maybe (Rels Relation))+ convert name (dname, range) = case isNoVersion range''' of True -> return Nothing False ->@@ -252,12 +255,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 => B.PackageType -> PackageName -> [D.Relation] -> DebT m [D.Relation]+doBundled :: MonadIO m =>+ B.PackageType+ -> PackageName+ -> [D.Relation]+ -> DebT m [D.Relation] doBundled typ name rels =- do comp <- access T.compiler >>= return . fromMaybe (error "no Compiler value")- case ghcBuiltIn comp name of- True -> return $ rels ++ [D.Rel (compilerPackageName typ) Nothing Nothing]- False -> return rels+ do root <- access T.buildEnv+ gver <- liftIO $ ghcVersion' root+ pver <- ghcBuiltIn root name+ -- Prefer the compiler to the library, if the compiler provides libghc-foo-dev+ -- generate "ghc | libghc-foo-dev" rather than "libghc-foo-dev | ghc". It would be+ -- better to see if the version built into the compiler is newer than the uploaded+ -- version. For now, libraries built into the new 7.8 compiler must trump uploaded+ -- packages because they were all built with 7.6.3.+ let preferCompiler = case gver of+ Just (CompilerId GHC (Version (7 : 8 : _) _)) -> True+ _ -> False+ case pver of+ -- If preferCompiler is set generate "ghc | libghc-foo-dev" instead of "libghc-foo-dev | ghc"+ Just v | preferCompiler -> return $ [D.Rel (compilerPackageName typ) Nothing Nothing] ++ rels+ Just _ -> return $ rels ++ [D.Rel (compilerPackageName typ) Nothing Nothing]+ Nothing -> return rels where compilerPackageName B.Documentation = D.BinPkgName "ghc-doc" compilerPackageName B.Profiling = D.BinPkgName "ghc-prof"
src/Debian/Debianize/Bundled.hs view
@@ -6,14 +6,16 @@ ( ghcBuiltIn ) where -import qualified Data.Map as Map-import Data.Set (fromList, member)+import Control.Monad.Trans (MonadIO)+import Data.Function (on)+import Data.List (sortBy) import Data.Version (Version(..))+import Debian.Debianize.Input (ghcVersion') import Debian.Relation.ByteString() import Distribution.Simple.Compiler (CompilerId(..), CompilerFlavor(..), {-PackageDB(GlobalPackageDB), compilerFlavor-}) import Distribution.Package (PackageIdentifier(..), PackageName(..) {-, Dependency(..)-}) -type Bundled = (CompilerFlavor, Version, [PackageIdentifier])+type Bundled = (Version, [PackageIdentifier]) -- |Return a list of built in packages for the compiler in an environment. -- ghcBuiltIns :: FilePath -> IO [PackageIdentifier]@@ -28,39 +30,78 @@ ghcBuiltIns :: CompilerId -> Bundled ghcBuiltIns (CompilerId GHC compilerVersion) =- case Map.lookup compilerVersion- (Map.fromList (map (\ (cmp, ver, lst) -> (ver, (cmp, ver, lst)))- [ (GHC, Version [7,6,3] [], ghc763BuiltIns)- , (GHC, Version [7,6,2] [], ghc762BuiltIns)- , (GHC, Version [7,6,1] [], ghc761BuiltIns)- , (GHC, Version [7,6,1,20121207] [], ghc761BuiltIns)- , (GHC, Version [7,4,1] [], ghc741BuiltIns)- , (GHC, Version [7,4,0,20111219] [], ghc740BuiltIns)- , (GHC, Version [7,4,0,20120108] [], ghc740BuiltIns)- , (GHC, Version [7,2,2] [], ghc721BuiltIns)- , (GHC, Version [7,2,1] [], ghc721BuiltIns)- , (GHC, Version [7,0,4] [], ghc701BuiltIns)- , (GHC, Version [7,0,3] [], ghc701BuiltIns)- , (GHC, Version [7,0,1] [], ghc701BuiltIns)- , (GHC, Version [6,8,3] [], ghc683BuiltIns)- , (GHC, Version [6,8,2] [], ghc682BuiltIns)- , (GHC, Version [6,8,1] [], ghc681BuiltIns)- , (GHC, Version [6,6,1] [], ghc661BuiltIns)- , (GHC, Version [6,6] [], ghc66BuiltIns) ])) of- Nothing -> error $ "cabal-debian: No bundled package list for ghc " ++ show compilerVersion- Just x -> x+ case dropWhile (\ pr -> (fst pr < compilerVersion)) pairs of+ [] -> error $ "cabal-debian: No bundled package list for ghc " ++ show compilerVersion+ x : _ -> x ghcBuiltIns _ = error "ghcBuiltIns: Only GHC is supported" -ghcBuiltIn :: CompilerId -> PackageName -> Bool-ghcBuiltIn compiler package =- Data.Set.member- package- (Data.Set.fromList- (let {- (Just (_, _, xs)) = unsafePerformIO (ghc6BuiltIns compiler) -}- (_, _, xs) = ghcBuiltIns compiler in map pkgName xs))+pairs :: [Bundled]+pairs = sortBy+ (compare `on` fst)+ ([ (Version [7,8,20140228] [], ghc781BuiltIns)+ , (Version [7,8,20140130] [], ghc781BuiltIns)+ , (Version [7,8,1] [], ghc781BuiltIns) + , (Version [7,6,3] [], ghc763BuiltIns)+ , (Version [7,6,2] [], ghc762BuiltIns)+ , (Version [7,6,1] [], ghc761BuiltIns)+ , (Version [7,6,1,20121207] [], ghc761BuiltIns)++ , (Version [7,4,1] [], ghc741BuiltIns)+ , (Version [7,4,0,20111219] [], ghc740BuiltIns)+ , (Version [7,4,0,20120108] [], ghc740BuiltIns)+ , (Version [7,2,2] [], ghc721BuiltIns)+ , (Version [7,2,1] [], ghc721BuiltIns)+ , (Version [7,0,4] [], ghc701BuiltIns)+ , (Version [7,0,3] [], ghc701BuiltIns)+ , (Version [7,0,1] [], ghc701BuiltIns)+ , (Version [6,8,3] [], ghc683BuiltIns)+ , (Version [6,8,2] [], ghc682BuiltIns)+ , (Version [6,8,1] [], ghc681BuiltIns)+ , (Version [6,6,1] [], ghc661BuiltIns)+ , (Version [6,6] [], ghc66BuiltIns) ])++ghcBuiltIn :: MonadIO m => FilePath -> PackageName -> m (Maybe Version)+ghcBuiltIn root package = do+ compiler <- ghcVersion' root >>= maybe (error $ "No GHC available in environment at " ++ show root) return+ let (_, xs) = ghcBuiltIns compiler+ packageIds = filter (\ p -> pkgName p == package) xs+ case packageIds of+ [] -> return Nothing+ [p] -> return $ Just (pkgVersion p)+ ps -> error $ "Multiple versions of " ++ show package ++ " built into " ++ show compiler ++ ": " ++ show ps+ v :: String -> [Int] -> PackageIdentifier v n x = PackageIdentifier (PackageName n) (Version x [])++ghc781BuiltIns :: [PackageIdentifier]+ghc781BuiltIns = [+ v "array" [0,5,0,0],+ v "base" [4,7,0,0],+ v "binary" [0,7,1,0],+ v "bin-package-db" [0,0,0,0],+ v "bytestring" [0,10,4,0],+ v "Cabal" [1,18,1,3],+ v "containers" [0,5,4,0],+ v "deepseq" [1,3,0,2],+ v "directory" [1,2,0,2],+ v "filepath" [1,3,0,2],+ v "ghc" [7,8,20140130],+ v "ghc-prim" [0,3,1,0],+ v "haskell2010" [1,1,1,1],+ v "haskell98" [2,0,0,3],+ v "hoopl" [3,10,0,0],+ v "hpc" [0,6,0,1],+ v "integer-gmp" [0,5,1,0],+ v "old-locale" [1,0,0,6],+ v "old-time" [1,1,0,2],+ v "pretty" [1,1,1,1],+ v "process" [1,2,0,0],+ v "template-haskell" [2,9,0,0],+ v "time" [1,4,1],+ v "transformers" [0,3,0,0],+ v "unix" [2,7,0,0]+ ] ghc763BuiltIns :: [PackageIdentifier] ghc763BuiltIns = [
src/Debian/Debianize/Finalize.hs view
@@ -31,13 +31,13 @@ import Debian.Debianize.Options (compileCommandlineArgs, compileEnvironmentArgs) import Debian.Debianize.Prelude ((%=), (+++=), (+=), foldEmpty, fromEmpty, fromSingleton, (~=), (~?=)) import Debian.Debianize.Types (Top)-import qualified Debian.Debianize.Types as T (apacheSite, backups, binaryArchitectures, binaryPackages, binarySection, breaks, buildDepends, buildDependsIndep, buildDir, builtUsing, changelog, comments, compat, conflicts, debianDescription, debVersion, depends, epochMap, executable, extraDevDeps, extraLibMap, file, install, installCabalExec, installCabalExecTo, installData, installDir, installTo, intermediateFiles, license, link, maintainer, noDocumentationLibrary, noProfilingLibrary, packageDescription, packageType, preDepends, provides, recommends, replaces, revision, rulesFragments, serverInfo, source, sourcePackageName, sourcePriority, sourceSection, suggests, utilsPackageNames, verbosity, watch, website)+import qualified Debian.Debianize.Types as T (apacheSite, backups, binaryArchitectures, binaryPackages, binarySection, breaks, buildDepends, buildDependsIndep, buildDir, builtUsing, changelog, comments, compat, conflicts, debianDescription, debVersion, depends, epochMap, executable, extraDevDeps, extraLibMap, file, install, installCabalExec, installCabalExecTo, installData, installDir, installTo, intermediateFiles, license, link, maintainer, noDocumentationLibrary, noProfilingLibrary, packageDescription, packageType, preDepends, provides, recommends, replaces, revision, rulesFragments, serverInfo, source, sourcePackageName, sourcePriority, sourceSection, suggests, utilsPackageNames, verbosity, watch, website, buildEnv) import qualified Debian.Debianize.Types.Atoms as A (InstallFile(execName, sourceDir), showAtoms) import qualified Debian.Debianize.Types.BinaryDebDescription as B (BinaryDebDescription, package, PackageType(Development, Documentation, Exec, Profiling, Source', Utilities)) import Debian.Orphans () import Debian.Policy (getDebhelperCompatLevel, haskellMaintainer, PackageArchitectures(Any, All), PackagePriority(Optional), Section(..)) import Debian.Pretty (pretty)-import Debian.Relation (BinPkgName, BinPkgName(BinPkgName), Relation, Relation(Rel), Relations)+import Debian.Relation (BinPkgName, BinPkgName(BinPkgName), Relation(Rel), Relations) import qualified Debian.Relation as D (BinPkgName(BinPkgName), Relation(..)) import Debian.Release (parseReleaseName) import Debian.Time (getCurrentLocalRFC822Time)@@ -56,12 +56,12 @@ -- computed from the cabal package description.) debianization :: Top -> DebT IO () -> DebT IO () -> DebT IO () debianization top init customize =- do inputCabalization top+ do compileEnvironmentArgs+ compileCommandlineArgs+ inputCabalization top inputChangeLog top inputMaintainer init- compileEnvironmentArgs- compileCommandlineArgs customize finalizeDebianization' @@ -81,7 +81,7 @@ -- 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 Int -> DebT m ()+finalizeDebianization :: (MonadIO m, Functor m) => String -> Maybe Int -> DebT m () finalizeDebianization date debhelperCompat = do addExtraLibDependencies Just pkgDesc <- access T.packageDescription@@ -219,7 +219,7 @@ devDep :: Map String Relations -> String -> Relations devDep libMap cab = maybe [[Rel (BinPkgName ("lib" ++ cab ++ "-dev")) Nothing Nothing]] id (Map.lookup cab libMap) -putBuildDeps :: Monad m => PackageDescription -> DebT m ()+putBuildDeps :: MonadIO m => PackageDescription -> DebT m () putBuildDeps pkgDesc = do deps <- debianBuildDeps pkgDesc depsIndep <- debianBuildDepsIndep pkgDesc
src/Debian/Debianize/Input.hs view
@@ -5,8 +5,8 @@ ( inputDebianization , inputDebianizationFile , inputChangeLog- , inputCompiler- , inputCompiler'+ , ghcVersion+ , ghcVersion' , inputCabalization , inputCabalization' , inputMaintainer@@ -16,6 +16,7 @@ import Debug.Trace (trace) import Control.Category ((.))+import Control.DeepSeq (NFData, force) import Control.Exception (bracket) import Control.Monad (when, foldM, filterM) import Control.Monad.State (get, put)@@ -26,7 +27,7 @@ import Data.Set as Set (Set, toList, fromList, insert, singleton) import Data.Text (Text, unpack, pack, lines, words, break, strip, null) import Data.Text.IO (readFile)-import Data.Version (Version)+import Data.Version (showVersion, Version(Version)) import Debian.Changes (ChangeLog(..), ChangeLogEntry(logWho), parseChangeLog) import Debian.Control (Control'(unControl), Paragraph'(..), stripWS, parseControlFromFile, Field, Field'(..), ControlFunctions) import qualified Debian.Debianize.Types as T (maintainer)@@ -35,34 +36,35 @@ import qualified Debian.Debianize.Types.BinaryDebDescription as B import qualified Debian.Debianize.Types.SourceDebDescription as S import Debian.Debianize.Types.Atoms- (newAtoms, control, warning, sourceFormat, watch, rulesHead, compat, packageDescription, compiler,+ (newAtoms, control, warning, sourceFormat, watch, rulesHead, compat, packageDescription, license, licenseFile, copyright, changelog, installInit, postInst, postRm, preInst, preRm,- logrotateStanza, link, install, installDir, intermediateFiles, compilerVersion, cabalFlagAssignments, verbosity)+ logrotateStanza, link, install, installDir, intermediateFiles, cabalFlagAssignments, verbosity) import Debian.Debianize.Monad (Atoms, DebT, execDebT) import Debian.Debianize.Prelude (getDirectoryContents', withCurrentDirectory, readFileMaybe, read', intToVerbosity', (~=), (~?=), (+=), (++=), (+++=))-import Debian.Debianize.Types (Top(unTop))+import Debian.Debianize.Types (Top(unTop), buildEnv) import Debian.Orphans () import Debian.Policy (Section(..), parseStandardsVersion, readPriority, readSection, parsePackageArchitectures, parseMaintainer, parseUploaders, readSourceFormat, getDebianMaintainer) import Debian.Relation (Relations, BinPkgName(..), SrcPkgName(..), parseRelations)+import Debian.Version (DebianVersion, parseDebianVersion)+import Distribution.Compiler (CompilerId(CompilerId), CompilerFlavor(GHC)) import Distribution.Package (Package(packageId), PackageIdentifier(..), PackageName(PackageName), Dependency) import qualified Distribution.PackageDescription as Cabal (PackageDescription(licenseFile, maintainer, package, license, copyright {-, synopsis, description-})) import Distribution.PackageDescription as Cabal (PackageDescription, FlagName) import Distribution.PackageDescription.Configuration (finalizePackageDescription) import Distribution.PackageDescription.Parse (readPackageDescription)-import Distribution.Simple.Compiler (CompilerId(..), CompilerFlavor(..), Compiler(..))-import Distribution.Simple.Configure (configCompiler)-import Distribution.Simple.Program (defaultProgramConfiguration) import Distribution.Simple.Utils (defaultPackageDesc, die, setupMessage) import Distribution.System (Platform(..), buildOS, buildArch) import Distribution.Verbosity (Verbosity) import Prelude hiding (readFile, lines, words, break, null, log, sum, (.))-import System.Cmd (system)-import System.Directory (doesFileExist)+import qualified Prelude (lines)+import System.Directory (doesFileExist, doesDirectoryExist) import System.Exit (ExitCode(..)) import System.FilePath ((</>), takeExtension, dropExtension) import System.Posix.Files (setFileCreationMask)+import System.Process (readProcess, system) import System.IO.Error (catchIOError, tryIOError)+import System.Unix.Chroot (useEnv) -- import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr) inputDebianization :: Top -> DebT IO ()@@ -268,10 +270,10 @@ inputCabalization :: MonadIO m => Top -> DebT m () inputCabalization top = do vb <- access verbosity >>= return . intToVerbosity'- comp <- inputCompiler top- compiler ~= Just comp flags <- access cabalFlagAssignments- ePkgDesc <- liftIO $ inputCabalization' top vb comp flags+ root <- access buildEnv+ mcid <- liftIO (ghcVersion' root)+ ePkgDesc <- liftIO $ inputCabalization' top vb flags (fromMaybe (error $ "inputCabalization - invalid buildEnv: " ++ show root) mcid) either (\ deps -> error $ "Missing dependencies in cabal package at " ++ show (unTop top) ++ ": " ++ show deps) (\ pkgDesc -> do packageDescription ~= Just pkgDesc@@ -288,12 +290,12 @@ s -> Just (pack s))) ePkgDesc -inputCabalization' :: Top -> Verbosity -> CompilerId -> Set (FlagName, Bool) -> IO (Either [Dependency] PackageDescription)-inputCabalization' top vb compId flags =+inputCabalization' :: Top -> Verbosity -> Set (FlagName, Bool) -> CompilerId -> IO (Either [Dependency] PackageDescription)+inputCabalization' top vb flags cid = withCurrentDirectory (unTop top) $ do descPath <- defaultPackageDesc vb genPkgDesc <- readPackageDescription vb descPath- case finalizePackageDescription (toList flags) (const True) (Platform buildArch buildOS) compId [] genPkgDesc of+ case finalizePackageDescription (toList flags) (const True) (Platform buildArch buildOS) cid [] genPkgDesc of Left deps -> return (Left deps) Right (pkgDesc, _) -> do bracket (setFileCreationMask 0o022) setFileCreationMask $ \ _ -> autoreconf vb pkgDesc@@ -312,21 +314,32 @@ ExitSuccess -> return () ExitFailure n -> die ("autoreconf failed with status " ++ show n) -inputCompiler :: MonadIO m => Top -> DebT m CompilerId-inputCompiler top =- do vb <- access verbosity >>= return . intToVerbosity'- mCompilerVersion <- access compilerVersion- liftIO $ inputCompiler' top vb mCompilerVersion+-- | Use apt-cache to find the version number of the newest in a build environment.+ghcVersion :: MonadIO m => FilePath -> m (Maybe DebianVersion)+ghcVersion root = do+ exists <- liftIO $ doesDirectoryExist root+ when (not exists) (error $ "ghcVersion: no such environment: " ++ show root)+ versions <- liftIO $ chroot root $ readProcess "apt-cache" ["showpkg", "ghc"] "" >>=+ return . dropWhile (/= "Versions: ") . Prelude.lines+ case versions of+ (_ : versionLine : _) -> return . Just . parseDebianVersion . takeWhile (/= ' ') $ versionLine+ _ -> return Nothing --- | Read the compiler version specified by Cabal, optionally--- changing the version number.-inputCompiler' :: Top -> Verbosity -> Maybe Version -> IO CompilerId-inputCompiler' top vb mCompilerVersion =- withCurrentDirectory (unTop top) $ do- (Compiler {compilerId = CompilerId flavour version}, _) <- configCompiler (Just GHC) Nothing Nothing defaultProgramConfiguration vb- return $ case mCompilerVersion of- Nothing -> CompilerId flavour version- Just version' -> CompilerId flavour version'+chroot :: NFData a => FilePath -> IO a -> IO a+chroot "/" task = task+chroot root task = useEnv root (return . force) task++-- | Return a Data.Version.Version with the major and minor digits of the compiler version.+ghcVersion' :: MonadIO m => FilePath -> m (Maybe CompilerId)+ghcVersion' root = do+ ghcVersion root >>= return . maybe Nothing (Just . cabVersion)+ where+ cabVersion :: DebianVersion -> CompilerId+ cabVersion debVersion =+ let (Version ds ts) = greatestLowerBound debVersion (map (\ d -> Version [d] []) [0..]) in+ CompilerId GHC (greatestLowerBound debVersion (map (\ d -> Version (ds ++ [d]) ts) [0..]))+ greatestLowerBound :: DebianVersion -> [Version] -> Version+ greatestLowerBound b xs = last $ takeWhile (\ v -> parseDebianVersion (showVersion v) < b) xs -- | Try to compute a string for the the debian "Maintainer:" field using, in this order -- 1. the maintainer explicitly specified using "Debian.Debianize.Monad.maintainer"
src/Debian/Debianize/Options.hs view
@@ -11,11 +11,10 @@ import Data.Char (toLower, isDigit, ord) import Data.Lens.Lazy (Lens) import Data.Set (singleton)-import Data.Version (parseVersion) import Debian.Debianize.Goodies (doExecutable) import Debian.Debianize.Types- (verbosity, dryRun, debAction, compilerVersion, noDocumentationLibrary, noProfilingLibrary,- missingDependencies, sourcePackageName, cabalFlagAssignments, maintainer, buildDir, omitLTDeps,+ (verbosity, dryRun, debAction, noDocumentationLibrary, noProfilingLibrary,+ missingDependencies, sourcePackageName, cabalFlagAssignments, maintainer, buildDir, buildEnv, omitLTDeps, sourceFormat, buildDepends, buildDependsIndep, extraDevDeps, depends, conflicts, replaces, provides, extraLibMap, debVersion, revision, epochMap, execMap) import Debian.Debianize.Monad (DebT)@@ -34,7 +33,6 @@ import System.FilePath ((</>), splitFileName) import System.IO.Error (tryIOError) import System.Posix.Env (setEnv)-import Text.ParserCombinators.ReadP (readP_to_S) import Text.Regex.TDFA ((=~)) compileArgs :: [String] -> DebT IO ()@@ -75,13 +73,6 @@ Option "" ["executable"] (ReqArg (\ path -> executableOption path (\ bin e -> doExecutable bin e)) "SOURCEPATH or SOURCEPATH:DESTDIR") (unlines [ "Create an individual binary package to hold this executable. Other executables " , " and data files are gathered into a single utils package named 'haskell-packagename-utils'."]),- Option "" ["ghc-version"] (ReqArg (\ ver -> compilerVersion ~= Just (last (map fst (readP_to_S parseVersion ver)))) "VERSION")- (unlines [ "Version of GHC in build environment. Without this option it is assumed that"- , "the version of GHC in the build environment is the same as the one in the"- , "environment in which cabal-debian is running. (the usual case.) The GHC"- , "version is used to determine which packages are bundled with GHC - if a"- , "package is bundled with GHC it is not necessary to add a build dependency for"- , "that package to the debian/control file."]), Option "" ["disable-haddock"] (NoArg (noDocumentationLibrary ~= singleton True)) (unlines [ "Don't generate API documentation packages, usually named" , "libghc-packagename-doc. Use this if your build is crashing due to a"@@ -167,6 +158,11 @@ , "run by haskell-devscripts. The build subdirectory is added to match the" , "behavior of the --builddir option in the Setup script."]), + Option "" ["buildenv"] (ReqArg (\ s -> buildEnv ~= s) "PATH")+ (unlines [ "Directory containing the build environment for which the debianization will"+ , "be generated. This determines which compiler will be available, which in turn"+ , "determines which basic libraries can be provided by the compiler. This can be"+ , "set to /, but it must be set."]), Option "f" ["flags"] (ReqArg (\ fs -> mapM_ (cabalFlagAssignments +=) (flagList fs)) "FLAGS") (unlines [ "Flags to pass to the finalizePackageDescription function in" , "Distribution.PackageDescription.Configuration when loading the cabal file."]),
src/Debian/Debianize/Output.hs view
@@ -40,7 +40,7 @@ import System.Environment (getEnv) import System.Exit (ExitCode(ExitSuccess)) import System.FilePath ((</>), takeDirectory)-import System.Process (readProcessWithExitCode)+import System.Process (readProcessWithExitCode, showCommandForUser) -- | Run the script in @debian/Debianize.hs@ with the given command -- line arguments. Returns @True@ if the script exists and succeeds.@@ -57,12 +57,13 @@ case exists of False -> return False True ->- let autobuilderd = "-i.:" ++ home </> ".autobuilder.d" in- putEnvironmentArgs args >> readProcessWithExitCode "runhaskell" ([autobuilderd, "debian/Debianize.hs"] ++ args) "" >>= \ result ->+ let autobuilderd = "-i.:" ++ home </> ".autobuilder.d"+ args' = [autobuilderd, "debian/Debianize.hs"] ++ args in+ putEnvironmentArgs args >> readProcessWithExitCode "runhaskell" args' "" >>= \ result -> case result of (ExitSuccess, _, _) -> return True (code, out, err) ->- error ("runDebianize failed with " ++ show code ++ ":\n stdout: " ++ show out ++"\n stderr: " ++ show err)+ error ("runDebianizeScript: " ++ showCommandForUser "runhaskell" args' ++ " -> " ++ show code ++ "\n stdout: " ++ show out ++"\n stderr: " ++ show err) -- | Depending on the options in @atoms@, either validate, describe, -- or write the generated debianization.
src/Debian/Debianize/SubstVars.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ScopedTypeVariables, TupleSections, TypeSynonymInstances #-}+{-# LANGUAGE CPP, ScopedTypeVariables, TupleSections, TypeSynonymInstances #-} {-# OPTIONS -Wall -fno-warn-name-shadowing #-} -- | Support for generating Debianization from Cabal data.@@ -21,7 +21,7 @@ import qualified Data.Set as Set (member, Set) import Data.Text (pack) import Debian.Control (Control'(unControl), ControlFunctions(lookupP, parseControl, stripWS), Field'(Field))-import Debian.Debianize.Input (inputCompiler, inputCabalization)+import Debian.Debianize.Input (inputCabalization) import Debian.Debianize.Monad (DebT) import Debian.Debianize.Prelude ((!), buildDebVersionMap, cond, DebMap, debOfFile, diffFile, dpkgFileMap, replaceFile, showDeps, modifyM) import Debian.Debianize.Types (Top)@@ -30,15 +30,25 @@ import Debian.Pretty (pretty) import Debian.Relation (BinPkgName(BinPkgName), Relation, Relations) import qualified Debian.Relation as D (BinPkgName(BinPkgName), ParseRelations(parseRelations), Relation(Rel), Relations, VersionReq(GRE))+#if MIN_VERSION_Cabal(1,18,0)+import Distribution.Compiler (buildCompilerId)+#else+import Data.Version+import Distribution.Compiler+#endif import Distribution.Package (Dependency(..), PackageName(PackageName)) import Distribution.PackageDescription as Cabal (allBuildInfo, buildTools, extraLibs, PackageDescription(..), pkgconfigDepends)-import Distribution.Simple.Compiler (CompilerId(CompilerId)) import Distribution.Simple.Utils (die) import Distribution.Text (display) import Prelude hiding (unlines) import System.Directory (doesDirectoryExist, getDirectoryContents) import System.FilePath ((</>)) +#if !MIN_VERSION_Cabal(1,18,0)+buildCompilerId :: CompilerId+buildCompilerId = CompilerId GHC (Version [7,6,3] [])+#endif+ -- | Expand the contents of the .substvars file for a library package. -- Each cabal package corresponds to a directory <name>-<version>, -- either in /usr/lib or in /usr/lib/haskell-packages/ghc/lib. In@@ -55,8 +65,7 @@ substvars top debType = do inputCabalization top debVersions <- lift buildDebVersionMap- comp <- inputCompiler top- modifyM (lift . libPaths comp debVersions)+ modifyM (lift . libPaths debVersions) control <- lift $ readFile "debian/control" >>= either (error . show) return . parseControl "debian/control" substvars' debType control @@ -116,17 +125,17 @@ bd = maybe "" (\ (Field (_a, b)) -> stripWS b) . lookupP "Build-Depends" . head . unControl $ control bdi = maybe "" (\ (Field (_a, b)) -> stripWS b) . lookupP "Build-Depends-Indep" . head . unControl $ control -libPaths :: CompilerId -> DebMap -> T.Atoms -> IO T.Atoms-libPaths compiler@(CompilerId comp _) debVersions atoms =+libPaths :: DebMap -> T.Atoms -> IO T.Atoms+libPaths debVersions atoms = do a <- getDirPaths "/usr/lib"- b <- getDirPaths ("/usr/lib/haskell-packages" </> display comp </> "lib")+ b <- getDirPaths ("/usr/lib/haskell-packages" </> display buildCompilerId </> "lib") -- Build a map from names of installed debs to version numbers- dpkgFileMap >>= runReaderT (foldM (packageInfo' compiler debVersions) atoms (a ++ b))+ dpkgFileMap >>= runReaderT (foldM (packageInfo' debVersions) atoms (a ++ b)) where getDirPaths path = try (getDirectoryContents path) >>= return . map (\ x -> (path, x)) . either (\ (_ :: SomeException) -> []) id -packageInfo' :: CompilerId -> DebMap -> T.Atoms -> (FilePath, String) -> ReaderT (Map.Map FilePath (Set.Set D.BinPkgName)) IO T.Atoms-packageInfo' compiler debVersions atoms (d, f) =+packageInfo' :: DebMap -> T.Atoms -> (FilePath, String) -> ReaderT (Map.Map FilePath (Set.Set D.BinPkgName)) IO T.Atoms+packageInfo' debVersions atoms (d, f) = case parseNameVersion f of Nothing -> return atoms Just (p, v) -> lift (doesDirectoryExist (d </> f </> cdir)) >>= cond (return atoms) (info (p, v))@@ -135,7 +144,7 @@ case (break (== '-') (reverse s)) of (_a, "") -> Nothing (a, b) -> Just (reverse (tail b), reverse a)- cdir = display compiler+ cdir = display buildCompilerId info (p, v) = do dev <- debOfFile ("^" ++ d </> p ++ "-" ++ v </> cdir </> "libHS" ++ p ++ "-" ++ v ++ ".a$") prof <- debOfFile ("^" ++ d </> p ++ "-" ++ v </> cdir </> "libHS" ++ p ++ "-" ++ v ++ "_p.a$")
src/Debian/Debianize/Tests.hs view
@@ -31,10 +31,11 @@ import qualified Debian.Debianize.Types.BinaryDebDescription as B import qualified Debian.Debianize.Types.SourceDebDescription as S import Debian.Policy (databaseDirectory, PackageArchitectures(All), PackagePriority(Extra), parseMaintainer, Section(MainSection), SourceFormat(Native3), StandardsVersion(..), getDebhelperCompatLevel, getDebianStandardsVersion)-import Debian.Pretty (pretty, Pretty, text, Doc)+import Debian.Pretty (pretty, text, Doc) import Debian.Relation (BinPkgName(..), Relation(..), SrcPkgName(..), VersionReq(..)) import Debian.Release (ReleaseName(ReleaseName, relName)) import Debian.Version (parseDebianVersion, buildDebianVersion)+import Distribution.Simple.Compiler (CompilerId(CompilerId), CompilerFlavor(GHC)) import Distribution.License (License(..)) import Distribution.Package (PackageName(PackageName)) import Prelude hiding (log)
src/Debian/Debianize/Types.hs view
@@ -9,7 +9,6 @@ -- * Cabal package info , packageDescription- , compiler -- * Repository info , execMap@@ -40,11 +39,12 @@ , noDocumentationLibrary , utilsPackageNames , buildDir+ , buildEnv , watch -- * Source Package Build Dependencies , omitLTDeps- , compilerVersion+ -- , compilerVersion -- * Binary Package Info , binaryArchitectures
src/Debian/Debianize/Types/Atoms.hs view
@@ -20,7 +20,6 @@ import Data.Monoid (Monoid(..)) import Data.Set as Set (Set) import Data.Text (Text)-import Data.Version (Version) import Debian.Changes (ChangeLog) import qualified Debian.Debianize.Types.SourceDebDescription as S import Debian.Debianize.VersionSplits (VersionSplits)@@ -31,7 +30,6 @@ import Distribution.License (License) import Distribution.Package (PackageName) import Distribution.PackageDescription as Cabal (FlagName, PackageDescription)-import Distribution.Simple.Compiler (CompilerId) import Prelude hiding (init, init, log, log, unlines, (.)) import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr) @@ -51,13 +49,6 @@ -- ^ If present, don't generate the << dependency when we see a cabal -- equals dependency. (The implementation of this was somehow lost.) -- FIXME: make this Bool or Maybe Bool- , compilerVersion_ :: Maybe Version- -- ^ Specify the version number of the GHC compiler in the build- -- environment. The default is to assume that version is the same- -- as the one in the environment where cabal-debian is running.- -- This is used to look up hard coded lists of packages bundled- -- with the compiler and their version numbers. (This could- -- certainly be done in a more beautiful way.) , buildDir_ :: Set FilePath -- ^ The build directory used by cabal, typically dist/build when -- building manually or dist-ghc/build when building using GHC and@@ -66,6 +57,12 @@ -- the --builddir option of runhaskell Setup appends the "/build" -- to the value it receives, so, yes, try not to get confused. -- FIXME: make this FilePath or Maybe FilePath+ , buildEnv_ :: FilePath+ -- ^ Directory containing the build environment for which the+ -- debianization will be generated. This determines which+ -- compiler will be available, which in turn determines which+ -- basic libraries can be provided by the compiler. This may be+ -- set to /, but it must be set. , flags_ :: Flags -- ^ Information regarding mode of operation - verbosity, dry-run, usage, etc , debianNameMap_ :: Map PackageName VersionSplits@@ -204,8 +201,6 @@ -- reason to use this is because we don't yet know the name of the dev library package. , packageDescription_ :: Maybe PackageDescription -- ^ The result of reading a cabal configuration file.- , compiler_ :: Maybe CompilerId- -- ^ The compiler value from cabal } deriving (Eq, Show) newAtoms :: Atoms@@ -214,8 +209,8 @@ { noDocumentationLibrary_ = mempty , noProfilingLibrary_ = mempty , omitLTDeps_ = mempty- , compilerVersion_ = Nothing , buildDir_ = mempty+ , buildEnv_ = "/" , flags_ = defaultFlags , debianNameMap_ = mempty , control_ = S.newSourceDebDescription@@ -269,7 +264,6 @@ , backups_ = mempty , extraDevDeps_ = mempty , packageDescription_ = Nothing- , compiler_ = Nothing } -- | This record supplies information about the task we want done -@@ -376,10 +370,6 @@ warning :: Lens Atoms (Set Text) warning = lens warning_ (\ a b -> b {warning_ = a}) --- | Set the compiler version, this is used when loading the cabal file to-compilerVersion :: Lens Atoms (Maybe Version)-compilerVersion = lens compilerVersion_ (\ b a -> a {compilerVersion_ = b})- -- | The build directory. This can be set by an argument to the @Setup@ script. -- When @Setup@ is run manually it is just @dist@, when it is run by -- @dpkg-buildpackage@ the compiler name is appended, so it is typically@@ -388,6 +378,9 @@ buildDir :: Lens Atoms (Set FilePath) buildDir = lens buildDir_ (\ b a -> a {buildDir_ = b}) +buildEnv :: Lens Atoms FilePath+buildEnv = lens buildEnv_ (\ b a -> a {buildEnv_ = b})+ -- | Map from cabal Extra-Lib names to debian binary package names. extraLibMap :: Lens Atoms (Map String Relations) extraLibMap = lens extraLibMap_ (\ a b -> b {extraLibMap_ = a})@@ -403,10 +396,6 @@ -- | The result of loading a .cabal file packageDescription :: Lens Atoms (Maybe PackageDescription) packageDescription = lens packageDescription_ (\ a b -> b {packageDescription_ = a})---- | Another result of loading a .cabal file-compiler :: Lens Atoms (Maybe CompilerId)-compiler = lens compiler_ (\ a b -> b {compiler_ = a}) -- | Map from cabal version number ranges to debian package names. This is a -- result of the fact that only one version of a debian package can be
src/Debian/Orphans.hs view
@@ -14,7 +14,10 @@ import Debian.Relation (Relation(..), VersionReq(..), ArchitectureReq(..), BinPkgName(..), SrcPkgName(..)) import Debian.Version (DebianVersion)-import Distribution.Compiler (CompilerId(..), CompilerFlavor(..))+import Distribution.Compiler (CompilerId(..))+#if !MIN_VERSION_Cabal(1,18,0)+import Distribution.Compiler (CompilerFlavor(..))+#endif import Distribution.License (License(..)) import Distribution.PackageDescription (PackageDescription(package), Executable(..)) import Distribution.Simple.Compiler (Compiler(..))