module Debian.Debianize.BinaryDebDescription
( Canonical(canonical)
, BinaryDebDescription
, newBinaryDebDescription
, package
, multiArch
, description
, packageType
, architecture
, binarySection
, binaryPriority
, essential
, relations
, PackageType(..)
, PackageRelations
, newPackageRelations
, depends
, recommends
, suggests
, preDepends
, breaks
, conflicts
, provides
, replaces
, builtUsing
) where
import Data.Function (on)
import Data.Generics (Data, Typeable)
import Control.Lens.TH (makeLenses)
import Data.List (sort, sortBy)
import Data.Monoid (Monoid(..))
import Data.Text (Text)
import Debian.Policy (PackageArchitectures, PackagePriority, Section, MultiArch)
import Debian.Relation (BinPkgName, Relations)
import Prelude hiding ((.))
class Canonical a where
canonical :: a -> a
data BinaryDebDescription
= BinaryDebDescription
{ _package :: BinPkgName
, _packageType :: Maybe PackageType
, _architecture :: Maybe PackageArchitectures
, _binarySection :: Maybe Section
, _binaryPriority :: Maybe PackagePriority
, _multiArch :: Maybe MultiArch
, _essential :: Maybe Bool
, _description :: Maybe Text
, _relations :: PackageRelations
} deriving (Eq, Ord, Read, Show, Data, Typeable)
data PackageType
= Development
| Profiling
| Documentation
| Exec
| Utilities
| Source
| HaskellSource
| Cabal
deriving (Eq, Ord, Show, Read, Data, Typeable)
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)
instance Canonical [BinaryDebDescription] where
canonical xs = sortBy (compare `on` _package) (map canonical xs)
instance Canonical BinaryDebDescription where
canonical x = x {_relations = canonical (_relations x)}
instance Canonical PackageRelations where
canonical x = x { _depends = canonical (_depends x)
, _recommends = canonical (_recommends x)
, _suggests = canonical (_suggests x)
, _preDepends = canonical (_preDepends x)
, _breaks = canonical (_breaks x)
, _conflicts = canonical (_conflicts x)
, _provides = canonical (_provides x)
, _replaces = canonical (_replaces x)
, _builtUsing = canonical (_builtUsing x) }
instance Canonical Relations where
canonical xss = sort xss
newBinaryDebDescription :: BinPkgName -> BinaryDebDescription
newBinaryDebDescription name =
BinaryDebDescription
{ _package = name
, _packageType = Nothing
, _architecture = Nothing
, _multiArch = Nothing
, _binarySection = Nothing
, _binaryPriority = Nothing
, _essential = Nothing
, _description = mempty
, _relations = newPackageRelations }
newPackageRelations :: PackageRelations
newPackageRelations =
PackageRelations
{ _depends = []
, _recommends = []
, _suggests = []
, _preDepends = []
, _breaks = []
, _conflicts = []
, _provides = []
, _replaces = []
, _builtUsing = [] }
$(makeLenses ''BinaryDebDescription)
$(makeLenses ''PackageRelations)