module Debian.Debianize.ControlFile
( SourceDebDescription(..)
, newSourceDebDescription
, newSourceDebDescription'
, VersionControlSpec(..)
, XField(..)
, XFieldDest(..)
, BinaryDebDescription(..)
, newBinaryDebDescription
, modifyBinaryDeb
, PackageRelations(..)
, PackageType(..)
, packageArch
) where
import Data.Generics (Data, Typeable)
import Data.Monoid (mempty)
import Data.Set as Set (Set, empty)
import Data.Text (Text)
import Debian.Orphans ()
import Debian.Policy (StandardsVersion, PackagePriority, PackageArchitectures(..), Section)
import Debian.Relation (Relations, SrcPkgName(..), BinPkgName)
import Prelude hiding (init, log)
import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr)
data SourceDebDescription
= SourceDebDescription
{ source :: Maybe SrcPkgName
, maintainer :: Maybe NameAddr
, changedBy :: Maybe NameAddr
, uploaders :: [NameAddr]
, dmUploadAllowed :: Bool
, priority :: Maybe PackagePriority
, section :: Maybe Section
, standardsVersion :: Maybe StandardsVersion
, homepage :: Maybe Text
, vcsFields :: Set VersionControlSpec
, xFields :: Set XField
, buildDepends :: Relations
, buildConflicts :: Relations
, buildDependsIndep :: Relations
, buildConflictsIndep :: Relations
, binaryPackages :: [BinaryDebDescription]
} deriving (Eq, Ord, Show, Data, Typeable)
newSourceDebDescription :: SourceDebDescription
newSourceDebDescription =
SourceDebDescription
{ source = Nothing
, maintainer = Nothing
, changedBy = Nothing
, uploaders = []
, dmUploadAllowed = False
, priority = Nothing
, section = Nothing
, buildDepends = []
, buildConflicts = []
, buildDependsIndep = []
, buildConflictsIndep = []
, standardsVersion = Nothing
, homepage = Nothing
, vcsFields = Set.empty
, xFields = Set.empty
, binaryPackages = [] }
newSourceDebDescription' :: SrcPkgName -> NameAddr -> SourceDebDescription
newSourceDebDescription' src who =
newSourceDebDescription
{ source = Just src
, maintainer = Just who }
data VersionControlSpec
= VCSBrowser Text
| VCSArch Text
| VCSBzr Text
| VCSCvs Text
| VCSDarcs Text
| VCSGit Text
| VCSHg Text
| VCSMtn Text
| VCSSvn Text
deriving (Eq, Ord, Show, Data, Typeable)
data XField
= XField (Set XFieldDest) Text Text
deriving (Eq, Ord, Show, Data, Typeable)
data XFieldDest
= B
| S
| C
deriving (Eq, Ord, Read, Show, Data, Typeable)
data BinaryDebDescription
= BinaryDebDescription
{ package :: BinPkgName
, architecture :: PackageArchitectures
, binarySection :: Maybe Section
, binaryPriority :: Maybe PackagePriority
, essential :: Bool
, description :: Text
, relations :: PackageRelations
} deriving (Eq, Ord, Read, Show, Data, Typeable)
newBinaryDebDescription :: BinPkgName -> PackageArchitectures -> BinaryDebDescription
newBinaryDebDescription name arch =
BinaryDebDescription
{ package = name
, architecture = arch
, binarySection = Nothing
, binaryPriority = Nothing
, essential = False
, description = mempty
, relations = newPackageRelations }
modifyBinaryDeb :: BinPkgName -> (Maybe BinaryDebDescription -> BinaryDebDescription) -> SourceDebDescription -> SourceDebDescription
modifyBinaryDeb bin f deb =
deb {binaryPackages = bins'}
where
bins' = if any (\ x -> package x == bin) bins
then map g (binaryPackages deb)
else binaryPackages deb ++ [f Nothing]
g x = if package x == bin then f (Just x) else x
bins = binaryPackages deb
data PackageRelations
= PackageRelations
{ depends :: Relations
, recommends :: Relations
, suggests :: Relations
, preDepends :: Relations
, breaks :: Relations
, conflicts :: Relations
, provides_ :: Relations
, replaces_ :: Relations
, builtUsing :: Relations
} deriving (Eq, Ord, Read, Show, Data, Typeable)
newPackageRelations :: PackageRelations
newPackageRelations =
PackageRelations
{ depends = []
, recommends = []
, suggests = []
, preDepends = []
, breaks = []
, conflicts = []
, provides_ = []
, replaces_ = []
, builtUsing = [] }
data PackageType
= Development
| Profiling
| Documentation
| Exec
| Utilities
| Source'
| Cabal
deriving (Eq, Show)
packageArch :: PackageType -> PackageArchitectures
packageArch Development = Any
packageArch Profiling = Any
packageArch Documentation = All
packageArch Utilities = All
packageArch Exec = Any
packageArch Cabal = undefined
packageArch Source' = undefined