debian-4.0.5: Modules for working with the Debian package system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Debian.Control

Description

A module for working with Debian control files http://www.debian.org/doc/debian-policy/ch-controlfields.html

Synopsis

Types

newtype Control' a Source #

Constructors

Control 

Fields

Instances

Instances details
(ControlFunctions a, Pretty (PP a)) => Pretty (Control' a) Source #

This may have bad performance issues (dsf: Whoever wrote this comment should have explained why.)

Instance details

Defined in Debian.Control.Common

Read a => Read (Control' a) Source # 
Instance details

Defined in Debian.Control.Common

Show a => Show (Control' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

showsPrec :: Int -> Control' a -> ShowS #

show :: Control' a -> String #

showList :: [Control' a] -> ShowS #

Eq a => Eq (Control' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

(==) :: Control' a -> Control' a -> Bool #

(/=) :: Control' a -> Control' a -> Bool #

Ord a => Ord (Control' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

compare :: Control' a -> Control' a -> Ordering #

(<) :: Control' a -> Control' a -> Bool #

(<=) :: Control' a -> Control' a -> Bool #

(>) :: Control' a -> Control' a -> Bool #

(>=) :: Control' a -> Control' a -> Bool #

max :: Control' a -> Control' a -> Control' a #

min :: Control' a -> Control' a -> Control' a #

newtype Paragraph' a Source #

Constructors

Paragraph [Field' a] 

Instances

Instances details
(ControlFunctions a, Pretty (PP a)) => Pretty (Paragraph' a) Source # 
Instance details

Defined in Debian.Control.Common

Read a => Read (Paragraph' a) Source # 
Instance details

Defined in Debian.Control.Common

Show a => Show (Paragraph' a) Source # 
Instance details

Defined in Debian.Control.Common

Eq a => Eq (Paragraph' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

(==) :: Paragraph' a -> Paragraph' a -> Bool #

(/=) :: Paragraph' a -> Paragraph' a -> Bool #

Ord a => Ord (Paragraph' a) Source # 
Instance details

Defined in Debian.Control.Common

data Field' a Source #

NOTE: we do not strip the leading or trailing whitespace in the name or value

Constructors

Field (a, a) 
Comment a

Lines beginning with #

Instances

Instances details
(ControlFunctions a, Pretty (PP a)) => Pretty (Field' a) Source # 
Instance details

Defined in Debian.Control.Common

Read a => Read (Field' a) Source # 
Instance details

Defined in Debian.Control.Common

Show a => Show (Field' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

showsPrec :: Int -> Field' a -> ShowS #

show :: Field' a -> String #

showList :: [Field' a] -> ShowS #

Eq a => Eq (Field' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

(==) :: Field' a -> Field' a -> Bool #

(/=) :: Field' a -> Field' a -> Bool #

Ord a => Ord (Field' a) Source # 
Instance details

Defined in Debian.Control.Common

Methods

compare :: Field' a -> Field' a -> Ordering #

(<) :: Field' a -> Field' a -> Bool #

(<=) :: Field' a -> Field' a -> Bool #

(>) :: Field' a -> Field' a -> Bool #

(>=) :: Field' a -> Field' a -> Bool #

max :: Field' a -> Field' a -> Field' a #

min :: Field' a -> Field' a -> Field' a #

class ControlFunctions a where Source #

Methods

parseControlFromFile :: FilePath -> IO (Either ParseError (Control' a)) Source #

parseControlFromFile filepath is a simple wrapper function that parses filepath using pControl

parseControlFromHandle :: String -> Handle -> IO (Either ParseError (Control' a)) Source #

parseControlFromHandle sourceName handle - sourceName is only used for error reporting

parseControl :: String -> a -> Either ParseError (Control' a) Source #

parseControlFromString sourceName text - sourceName is only used for error reporting

lookupP :: String -> Paragraph' a -> Maybe (Field' a) Source #

lookupP fieldName paragraph looks up a Field in a Paragraph. N.B. trailing and leading whitespace is not stripped.

stripWS :: a -> a Source #

Strip the trailing and leading space and tab characters from a string. Folded whitespace is not unfolded. This should probably be moved to someplace more general purpose.

protectFieldText :: a -> a Source #

Protect field value text so the parser doesn't split it into multiple fields or paragraphs. This must modify all field text to enforce two conditions: (1) All lines other than the initial one must begin with a space or a tab, and (2) the trailing white space must not contain newlines. This is called before pretty printing to prevent the parser from misinterpreting field text as multiple fields or paragraphs.

asString :: a -> String Source #

Instances

Instances details
ControlFunctions ByteString Source # 
Instance details

Defined in Debian.Control.ByteString

ControlFunctions Text Source # 
Instance details

Defined in Debian.Control.Text

ControlFunctions Builder Source # 
Instance details

Defined in Debian.Control.Builder

ControlFunctions Text Source # 
Instance details

Defined in Debian.Control.TextLazy

ControlFunctions String Source # 
Instance details

Defined in Debian.Control.String

Control File Parser

pControl :: ControlParser Control Source #

A parser for debian control file. This parser handles control files that end without a newline as well as ones that have several blank lines at the end. It is very liberal and does not attempt validate the fields in any way. All trailing, leading, and folded whitespace is preserved in the field values. See stripWS.

Helper Functions

renameField :: Eq a => a -> a -> Paragraph' a -> Paragraph' a Source #

modifyField :: Eq a => a -> (a -> a) -> Paragraph' a -> Paragraph' a Source #

raiseFields :: Eq a => (a -> Bool) -> Paragraph' a -> Paragraph' a Source #

Move selected fields to the beginning of a paragraph.

Policy classes and functions

class Show a => HasDebianControl a where Source #

Class of things that contain a validated Debian control file.

Instances

Instances details
HasDebianControl DebianControl Source # 
Instance details

Defined in Debian.Control.Policy

data ControlFileError Source #

Errors that control files might throw, with source file name and line number generated by template haskell.

Constructors

NoParagraphs 

Fields

NoBinaryParagraphs 

Fields

MissingField 

Fields

ParseRelationsError 

Fields

ParseControlError 

Fields

IOError 

Fields

validateDebianControl :: MonadCatch m => Control' Text -> m (Either ControlFileError DebianControl) Source #

Validate and return a control file in an opaque wrapper. May throw a ControlFileError. Currently we only verify that it has a Source field in the first paragraph and one or more subsequent paragraphs each with a Package field, and no syntax errors in the build dependencies (though they may be absent.)

debianRelations :: HasDebianControl a => String -> a -> Either ControlFileError (Maybe Relations) Source #

This could access fields we haven't validated, so it can return an error. Additionally, the field might be absent, in which case it returns Nothing.