-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A library for manipulating RPM files
--   
--   This module provides a library for reading RPM files and converting
--   them into useful data structures. There is currently no way to operate
--   in reverse - that is, for building an RPM file out of a data
--   structure.
@package codec-rpm
@version 0.2.2


module Codec.RPM.Tags

-- | A very large data type that holds all the possibilities for the
--   various tags that can be contained in an <a>RPM</a> <a>Header</a>.
--   Each tag describes one piece of metadata. Most tags include some typed
--   value, such as a <a>String</a> or <a>Word32</a>. Many tags contain
--   lists of these values, for instance any tag involving files or
--   changelog entries. Some tags contain no useful value at all.
--   
--   Because there are so many possibilities for tags and each <a>RPM</a>
--   likely contains dozens of tags, it is unwieldy to write functions that
--   pattern match on tags and take some action. This module therefore
--   provides a variety of find*Tag functions for searching the list of
--   tags by name and returning a <a>Maybe</a> value. The name provided to
--   each should be the constructor you are looking for in this data type.
--   
--   To find the list of all files in the RPM, you would therefore do:
--   
--   <pre>
--   findStringTag "FileNames" tags
--   </pre>
data Tag
DEPRECATED :: Tag -> Tag
INTERNAL :: Tag -> Tag
OBSOLETE :: Tag -> Tag
UNIMPLEMENTED :: Tag -> Tag
UNUSED :: Tag -> Tag
HeaderImage :: Null -> Tag
HeaderSignatures :: Null -> Tag
HeaderImmutable :: Null -> Tag
HeaderRegions :: Null -> Tag
HeaderI18NTable :: [String] -> Tag
SigBase :: Null -> Tag
SigSize :: Word32 -> Tag
SigLEMD5_1 :: Null -> Tag
SigPGP :: ByteString -> Tag
SigLEMD5_2 :: Null -> Tag
SigMD5 :: ByteString -> Tag
SigGPG :: ByteString -> Tag
SigPGP5 :: Null -> Tag
SigBadSHA1_1 :: Null -> Tag
SigBadSHA1_2 :: Null -> Tag
PubKeys :: [String] -> Tag
DSAHeader :: ByteString -> Tag
RSAHeader :: ByteString -> Tag
SHA1Header :: String -> Tag
LongSigSize :: Word64 -> Tag
LongArchiveSize :: Word64 -> Tag
Name :: String -> Tag
Version :: String -> Tag
Release :: String -> Tag
Epoch :: Word32 -> Tag
Summary :: ByteString -> Tag
Description :: ByteString -> Tag
BuildTime :: Word32 -> Tag
BuildHost :: String -> Tag
InstallTime :: Word32 -> Tag
Size :: Word32 -> Tag
Distribution :: String -> Tag
Vendor :: String -> Tag
GIF :: ByteString -> Tag
XPM :: ByteString -> Tag
License :: String -> Tag
Packager :: String -> Tag
Group :: ByteString -> Tag
ChangeLog :: [String] -> Tag
Source :: [String] -> Tag
Patch :: [String] -> Tag
URL :: String -> Tag
OS :: String -> Tag
Arch :: String -> Tag
PreIn :: String -> Tag
PostIn :: String -> Tag
PreUn :: String -> Tag
PostUn :: String -> Tag
OldFileNames :: [String] -> Tag
FileSizes :: [Word32] -> Tag
FileStates :: [Char] -> Tag
FileModes :: [Word16] -> Tag
FileUIDs :: [Word32] -> Tag
FileGIDs :: [Word32] -> Tag
FileRDevs :: [Word16] -> Tag
FileMTimes :: [Word32] -> Tag
FileMD5s :: [String] -> Tag
FileLinkTos :: [String] -> Tag
FileFlags :: [Word32] -> Tag
Root :: Null -> Tag
FileUserName :: [String] -> Tag
FileGroupName :: [String] -> Tag
Exclude :: Null -> Tag
Exclusive :: Null -> Tag
Icon :: ByteString -> Tag
SourceRPM :: String -> Tag
FileVerifyFlags :: [Word32] -> Tag
ArchiveSize :: Word32 -> Tag
ProvideName :: [String] -> Tag
RequireFlags :: [Word32] -> Tag
RequireName :: [String] -> Tag
RequireVersion :: [String] -> Tag
NoSource :: [Word32] -> Tag
NoPatch :: [Word32] -> Tag
ConflictFlags :: [Word32] -> Tag
ConflictName :: [String] -> Tag
ConflictVersion :: [String] -> Tag
DefaultPrefix :: String -> Tag
BuildRoot :: String -> Tag
InstallPrefix :: String -> Tag
ExcludeArch :: [String] -> Tag
ExcludeOS :: [String] -> Tag
ExclusiveArch :: [String] -> Tag
ExclusiveOS :: [String] -> Tag
AutoReqProv :: String -> Tag
RPMVersion :: String -> Tag
TriggerScripts :: [String] -> Tag
TriggerName :: [String] -> Tag
TriggerVersion :: [String] -> Tag
TriggerFlags :: [Word32] -> Tag
TriggerIndex :: [Word32] -> Tag
VerifyScript :: String -> Tag
ChangeLogTime :: [Word32] -> Tag
ChangeLogName :: [String] -> Tag
ChangeLogText :: [String] -> Tag
BrokenMD5 :: Null -> Tag
PreReq :: Null -> Tag
PreInProg :: [String] -> Tag
PostInProg :: [String] -> Tag
PreUnProg :: [String] -> Tag
PostUnProg :: [String] -> Tag
BuildArchs :: [String] -> Tag
ObsoleteName :: [String] -> Tag
VerifyScriptProg :: [String] -> Tag
TriggerScriptProg :: [String] -> Tag
DocDir :: Null -> Tag
Cookie :: String -> Tag
FileDevices :: [Word32] -> Tag
FileINodes :: [Word32] -> Tag
FileLangs :: [String] -> Tag
Prefixes :: [String] -> Tag
InstPrefixes :: [String] -> Tag
TriggerIn :: Null -> Tag
TriggerUn :: Null -> Tag
TriggerPostUn :: Null -> Tag
AutoReq :: Null -> Tag
AutoProv :: Null -> Tag
Capability :: Word32 -> Tag
SourcePackage :: Word32 -> Tag
OldOrigFileNames :: Null -> Tag
BuildPreReq :: Null -> Tag
BuildRequires :: Null -> Tag
BuildConflicts :: Null -> Tag
BuildMacros :: Null -> Tag
ProvideFlags :: [Word32] -> Tag
ProvideVersion :: [String] -> Tag
ObsoleteFlags :: [Word32] -> Tag
ObsoleteVersion :: [String] -> Tag
DirIndexes :: [Word32] -> Tag
BaseNames :: [String] -> Tag
DirNames :: [String] -> Tag
OrigDirIndexes :: [Word32] -> Tag
OrigBaseNames :: [String] -> Tag
OrigDirNames :: [String] -> Tag
OptFlags :: String -> Tag
DistURL :: String -> Tag
PayloadFormat :: String -> Tag
PayloadCompressor :: String -> Tag
PayloadFlags :: String -> Tag
InstallColor :: Word32 -> Tag
InstallTID :: Word32 -> Tag
RemoveTID :: Word32 -> Tag
SHA1RHN :: Null -> Tag
RHNPlatform :: String -> Tag
Platform :: String -> Tag
PatchesName :: [String] -> Tag
PatchesFlags :: [Word32] -> Tag
PatchesVersion :: [String] -> Tag
CacheCTime :: Word32 -> Tag
CachePkgPath :: String -> Tag
CachePkgSize :: Word32 -> Tag
CachePkgMTime :: Word32 -> Tag
FileColors :: [Word32] -> Tag
FileClass :: [Word32] -> Tag
ClassDict :: [String] -> Tag
FileDependsX :: [Word32] -> Tag
FileDependsN :: [Word32] -> Tag
DependsDict :: [(Word32, Word32)] -> Tag
SourcePkgID :: ByteString -> Tag
FileContexts :: [String] -> Tag
FSContexts :: [String] -> Tag
ReContexts :: [String] -> Tag
Policies :: [String] -> Tag
PreTrans :: String -> Tag
PostTrans :: String -> Tag
PreTransProg :: [String] -> Tag
PostTransProg :: [String] -> Tag
DistTag :: String -> Tag
OldSuggestsName :: [String] -> Tag
OldSuggestsVersion :: [String] -> Tag
OldSuggestsFlags :: [Word32] -> Tag
OldEnhancesName :: [String] -> Tag
OldEnhancesVersion :: [String] -> Tag
OldEnhancesFlags :: [Word32] -> Tag
Priority :: [Word32] -> Tag
CVSID :: String -> Tag
BLinkPkgID :: [String] -> Tag
BLinkHdrID :: [String] -> Tag
BLinkNEVRA :: [String] -> Tag
FLinkPkgID :: [String] -> Tag
FLinkHdrID :: [String] -> Tag
FLinkNEVRA :: [String] -> Tag
PackageOrigin :: String -> Tag
TriggerPreIn :: Null -> Tag
BuildSuggests :: Null -> Tag
BuildEnhances :: Null -> Tag
ScriptStates :: [Word32] -> Tag
ScriptMetrics :: [Word32] -> Tag
BuildCPUClock :: Word32 -> Tag
FileDigestAlgos :: [Word32] -> Tag
Variants :: [String] -> Tag
XMajor :: Word32 -> Tag
XMinor :: Word32 -> Tag
RepoTag :: String -> Tag
Keywords :: [String] -> Tag
BuildPlatforms :: [String] -> Tag
PackageColor :: Word32 -> Tag
PackagePrefColor :: Word32 -> Tag
XattrsDict :: [String] -> Tag
FileXattrsx :: [Word32] -> Tag
DepAttrsDict :: [String] -> Tag
ConflictAttrsx :: [Word32] -> Tag
ObsoleteAttrsx :: [Word32] -> Tag
ProvideAttrsx :: [Word32] -> Tag
RequireAttrsx :: [Word32] -> Tag
BuildProvides :: Null -> Tag
BuildObsoletes :: Null -> Tag
DBInstance :: Word32 -> Tag
NVRA :: String -> Tag
FileNames :: [String] -> Tag
FileProvide :: [String] -> Tag
FileRequire :: [String] -> Tag
FSNames :: [String] -> Tag
FSSizes :: [Word64] -> Tag
TriggerConds :: [String] -> Tag
TriggerType :: [String] -> Tag
OrigFileNames :: [String] -> Tag
LongFileSizes :: [Word64] -> Tag
LongSize :: Word64 -> Tag
FileCaps :: [String] -> Tag
FileDigestAlgo :: Word32 -> Tag
BugURL :: String -> Tag
EVR :: String -> Tag
NVR :: String -> Tag
NEVR :: String -> Tag
NEVRA :: String -> Tag
HeaderColor :: Word32 -> Tag
Verbose :: Word32 -> Tag
EpochNum :: Word32 -> Tag
PreInFlags :: Word32 -> Tag
PostInFlags :: Word32 -> Tag
PreUnFlags :: Word32 -> Tag
PostUnFlags :: Word32 -> Tag
PreTransFlags :: Word32 -> Tag
PostTransFlags :: Word32 -> Tag
VerifyScriptFlags :: Word32 -> Tag
TriggerScriptFlags :: [Word32] -> Tag
Collections :: [String] -> Tag
PolicyNames :: [String] -> Tag
PolicyTypes :: [String] -> Tag
PolicyTypesIndexes :: [Word32] -> Tag
PolicyFlags :: [Word32] -> Tag
PolicyVCS :: String -> Tag
OrderName :: [String] -> Tag
OrderVersion :: [String] -> Tag
OrderFlags :: [Word32] -> Tag
MSSFManifest :: [String] -> Tag
MSSFDomain :: [String] -> Tag
InstFileNames :: [String] -> Tag
RequireNEVRs :: [String] -> Tag
ProvideNEVRs :: [String] -> Tag
ObsoleteNEVRs :: [String] -> Tag
ConflictNEVRs :: [String] -> Tag
FileNLinks :: [Word32] -> Tag
RecommendName :: [String] -> Tag
RecommendVersion :: [String] -> Tag
RecommendFlags :: [Word32] -> Tag
SuggestName :: [String] -> Tag
SuggestVersion :: [String] -> Tag
SuggestFlags :: [Word32] -> Tag
SupplementName :: [String] -> Tag
SupplementVersion :: [String] -> Tag
SupplementFlags :: [Word32] -> Tag
EnhanceName :: [String] -> Tag
EnhanceVersion :: [String] -> Tag
EnhanceFlags :: [Word32] -> Tag
RecommendNEVRs :: [String] -> Tag
SuggestNEVRs :: [String] -> Tag
SupplementNEVRs :: [String] -> Tag
EnhanceNEVRs :: [String] -> Tag
Encoding :: String -> Tag
FileTriggerIn :: Null -> Tag
FileTriggerUn :: Null -> Tag
FileTriggerPostUn :: Null -> Tag
FileTriggerScripts :: [String] -> Tag
FileTriggerScriptProg :: [String] -> Tag
FileTriggerScriptFlags :: [Word32] -> Tag
FileTriggerName :: [String] -> Tag
FileTriggerIndex :: [Word32] -> Tag
FileTriggerVersion :: [String] -> Tag
FileTriggerFlags :: [Word32] -> Tag
TransFileTriggerIn :: Null -> Tag
TransFileTriggerUn :: Null -> Tag
TransFileTriggerPostUn :: Null -> Tag
TransFileTriggerScripts :: [String] -> Tag
TransFileTriggerScriptProg :: [String] -> Tag
TransFileTriggerScriptFlags :: [Word32] -> Tag
TransFileTriggerName :: [String] -> Tag
TransFileTriggerIndex :: [Word32] -> Tag
TransFileTriggerVersion :: [String] -> Tag
TransFileTriggerFlags :: [Word32] -> Tag
RemovePathPostFixes :: String -> Tag
FileTriggerPriorities :: [Word32] -> Tag
TransFileTriggerPriorities :: [Word32] -> Tag
FileTriggerConds :: [String] -> Tag
FileTriggerType :: [String] -> Tag
TransFileTriggerConds :: [String] -> Tag
TransFileTriggerType :: [String] -> Tag
FileSignatures :: [String] -> Tag
FileSignatureLength :: Word32 -> Tag

-- | Some <a>Tag</a>s do not contain any value, likely because support for
--   that tag has been removed. RPM never removes a tag from its list of
--   known values, however, so we must still recognize them. These tags
--   have a special value of <a>Null</a>, which contains no value.
data Null
Null :: Null

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s (say, from
--   the <a>Header</a> of some <a>RPM</a>), find the match and return it as
--   a <a>Maybe</a>. This is the most generic of the various finding
--   functions - it will return any match regardless of its type. You are
--   expected to know what type you are looking for.
findTag :: String -> [Tag] -> Maybe Tag

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find the
--   match, convert it into a <tt>ByteString</tt>, and return it as a
--   <a>Maybe</a>. If the value of the <a>Tag</a> cannot be converted into
--   a <tt>ByteString</tt> (say, because it is of the wrong type),
--   <a>Nothing</a> will be returned. Thus, this should only be used on
--   tags whose value is known - see the definition of <a>Tag</a> for the
--   possibilities.
findByteStringTag :: String -> [Tag] -> Maybe ByteString

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find the
--   match, convert it into a <a>String</a>, and return it as a
--   <a>Maybe</a>. If the value of the <a>Tag</a> cannot be converted into
--   a <a>String</a> (say, because it is of the wrong type), <a>Nothing</a>
--   will be returned. Thus, this should only be used on tags whose value
--   is known - see the definition of <a>Tag</a> for the possibilities.
findStringTag :: String -> [Tag] -> Maybe String

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find all
--   matches, convert them into <a>String</a>s, and return a list. If no
--   results are found or the value of a single <a>Tag</a> cannot be
--   converted into a <a>String</a> (say, because it is of the wrong type),
--   an empty list will be returned. Thus, this should only be used on tags
--   whose value is known - see the definition of <a>Tag</a> for the
--   possibilities.
findStringListTag :: String -> [Tag] -> [String]

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find the
--   match, convert it into a <a>Word16</a>, and return it as a
--   <a>Maybe</a>. If the value of the <a>Tag</a> cannot be converted into
--   a <a>Word16</a> (say, because it is of the wrong type), <a>Nothing</a>
--   will be returned. Thus, this should only be used on tags whose value
--   is known - see the definition of <a>Tag</a> for the possibilities.
findWord16Tag :: String -> [Tag] -> Maybe Word16

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find all
--   matches, convert them into <a>Word16</a>s, and return a list. If no
--   results are found or the value of a single <a>Tag</a> cannot be
--   converted into a <a>Word16</a> (say, because it is of the wrong type),
--   an empty list will be returned. Thus, this should only be used on tags
--   whose value is known - see the definition of <a>Tag</a> for the
--   possibilities.
findWord16ListTag :: String -> [Tag] -> [Word16]

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find the
--   match, convert it into a <a>Word16</a>, and return it as a
--   <a>Maybe</a>. If the value of the <a>Tag</a> cannot be converted into
--   a <a>Word16</a> (say, because it is of the wrong type), <a>Nothing</a>
--   will be returned. Thus, this should only be used on tags whose value
--   is known - see the definition of <a>Tag</a> for the possibilities.
findWord32Tag :: String -> [Tag] -> Maybe Word32

-- | Given the name of a <a>Tag</a> and a list of <a>Tag</a>s, find all
--   matches, convert them into <a>Word32</a>s, and return a list. If no
--   results are found or the value of a single <a>Tag</a> cannot be
--   converted into a <a>Word32</a> (say, because it is of the wrong type),
--   an empty list will be returned. Thus, this should only be used on tags
--   whose value is known - see the definition of <a>Tag</a> for the
--   possibilities.
findWord32ListTag :: String -> [Tag] -> [Word32]

-- | Attempt to create a <a>Tag</a> based on various parameters.
mkTag :: ByteString -> Int -> Word32 -> Word32 -> Word32 -> Maybe Tag

-- | Given a <a>Tag</a>, return its value. This is a helper function to be
--   used with <a>findTag</a>, essentially as a type-safe way to cast the
--   value into a known type. It is used internally in all the
--   type-specific find*Tag functions but can also be used on its own. A
--   function to find the Epoch tag could be written as follows:
--   
--   <pre>
--   epoch = findTag "Epoch" tags &gt;&gt;= \t -&gt; tagValue t :: Maybe Word32
--   </pre>
tagValue :: Typeable a => Tag -> Maybe a
instance Data.Data.Data Codec.RPM.Tags.Tag
instance GHC.Show.Show Codec.RPM.Tags.Tag
instance GHC.Classes.Eq Codec.RPM.Tags.Tag
instance Data.Data.Data Codec.RPM.Tags.Null
instance GHC.Show.Show Codec.RPM.Tags.Null
instance GHC.Classes.Eq Codec.RPM.Tags.Null
instance Text.PrettyPrint.HughesPJClass.Pretty Codec.RPM.Tags.Tag


module Codec.RPM.Types

-- | The top level RPM record. This contains everything in an RPM file,
--   except for the magic value.
data RPM
RPM :: Lead -> [Header] -> [Header] -> ByteString -> RPM

-- | The <a>Lead</a>, an obsolete record used for identifying RPMs.
[rpmLead] :: RPM -> Lead

-- | Special <a>Header</a> entries that can be used to verify the integrity
--   of an RPM. This is represented as a list because it is technically
--   possible for there to be multiple signature headers, but in practice
--   there is only ever one. This is the case even if multiple signatures
--   are present. This situation will be represented by multiple
--   <a>Tag</a>s that can be examined to get each signature. When checking
--   signatures, note that they only apply to the <a>rpmHeaders</a> and the
--   <a>rpmArchive</a>.
[rpmSignatures] :: RPM -> [Header]

-- | <a>Header</a> entries that contain all the metadata about an RPM.
--   There could technically be several entries here too, but in practice
--   there is only ever one. It is likely that each <a>Header</a> will
--   contain many <a>Tag</a>s, as RPMs tend to have a large amount of
--   metadata.
[rpmHeaders] :: RPM -> [Header]

-- | The contents of the RPM, stored as a compressed CPIO archive.
[rpmArchive] :: RPM -> ByteString

-- | Following the magic value that identifies a data stream as an RPM, the
--   Lead is the very first part of the file. Due to its small size and
--   inflexibility, it is largely obsolete and its use is discouraged even
--   inside of the RPM library. It is generally only used as additional
--   help beyond the magic value in verifying something is an RPM. The lead
--   is only exposed here for completeness.
data Lead
Lead :: Word8 -> Word8 -> Word16 -> Word16 -> String -> Word16 -> Word16 -> Lead

-- | The major version number of this RPM, for instance 0x03 for version
--   3.x.
[rpmMajor] :: Lead -> Word8

-- | The minor version number of this RPM, for instance 0x00 for version
--   3.0.
[rpmMinor] :: Lead -> Word8

-- | Is this a binary package (0x0000) or a source package (0x0001)? Other
--   types may be defined in the future.
[rpmType] :: Lead -> Word16

-- | What platform was this package built for? x86 is 0x0001. Many other
--   values are defined. See /usr/lib/rpm/rpmrc for the possibilities.
[rpmArchNum] :: Lead -> Word16

-- | The package name, as a NEVRA. This name is constrained to 66 bytes.
--   Shorter names are padded with nulls.
[rpmName] :: Lead -> String

-- | What operating system was this package built for? Linux is 0x0001.
--   Many other values are defined. See /usr/lib/rpm/rpmrc for the
--   possibilities.
[rpmOSNum] :: Lead -> Word16

-- | What type of signature is used in this RPM? For now, this appears to
--   always be set to 0x0005.
[rpmSigType] :: Lead -> Word16

-- | A Header represents a block of metadata. It is used twice in the RPM -
--   as the representation for signatures and as the representation for
--   regular metadata. Internally, the header is a list of tag descriptors
--   followed by a data store. These descriptors index into the store and
--   explain what type of thing should be found and how many things should
--   be read.
--   
--   Here, the hard work of figuring that out is already done and the
--   results provided as a list of <a>Tag</a>s. The raw store itself is
--   provided for completeness, in case further processing needs to be done
--   on the RPM. For most users, this will never be needed.
data Header
Header :: SectionHeader -> [Tag] -> ByteString -> Header

-- | Each header begins with its own <a>SectionHeader</a>, describing what
--   type of header follows and how many entries that header contains.
[headerSectionHeader] :: Header -> SectionHeader

-- | A list of <a>Tag</a> entries and their values. There are many, many
--   types of tags.
[headerTags] :: Header -> [Tag]

-- | The raw header store.
[headerStore] :: Header -> ByteString

-- | The SectionHeader is useful in parsing an RPM. It allows for figuring
--   out where each section occurs, how large it is, and so forth. It is
--   likely not useful for consumers of this libary. Just like with the
--   top-level <a>RPM</a> record, section headers are preceeded with a
--   magic value that is not exposed here.
data SectionHeader
SectionHeader :: Word8 -> Word32 -> Word32 -> SectionHeader

-- | The version of this header structure, currently only 0x01.
[sectionVersion] :: SectionHeader -> Word8

-- | How many <a>Tag</a> entries are stored in this header?
[sectionCount] :: SectionHeader -> Word32

-- | What is the size of the data store in this header?
[sectionSize] :: SectionHeader -> Word32
instance GHC.Show.Show Codec.RPM.Types.RPM
instance GHC.Classes.Eq Codec.RPM.Types.RPM
instance GHC.Show.Show Codec.RPM.Types.Header
instance GHC.Classes.Eq Codec.RPM.Types.Header
instance GHC.Show.Show Codec.RPM.Types.SectionHeader
instance GHC.Classes.Eq Codec.RPM.Types.SectionHeader
instance GHC.Show.Show Codec.RPM.Types.Lead
instance GHC.Classes.Eq Codec.RPM.Types.Lead
instance Text.PrettyPrint.HughesPJClass.Pretty Codec.RPM.Types.RPM
instance Text.PrettyPrint.HughesPJClass.Pretty Codec.RPM.Types.Header
instance Text.PrettyPrint.HughesPJClass.Pretty Codec.RPM.Types.SectionHeader
instance Text.PrettyPrint.HughesPJClass.Pretty Codec.RPM.Types.Lead


-- | A module for creating <a>RPM</a> records from various data sources.
module Codec.RPM.Parse

-- | A parser (in the attoparsec sense of the term) that constructs
--   <a>RPM</a> records. The parser can be run against a <a>ByteString</a>
--   of RPM data using any of the usual functions. <a>parse</a> and
--   <a>parseOnly</a> are especially useful:
--   
--   <pre>
--   import Data.Attoparsec.ByteString(parse)
--   import qualified Data.ByteString as BS
--   s &lt;- BS.readFile "some.rpm"
--   result &lt;- parse parseRPM s
--   </pre>
--   
--   The <a>Result</a> can then be examined directly or converted using
--   <a>maybeResult</a> (for converting it into a <a>Maybe</a> <a>RPM</a>)
--   or <a>eitherResult</a> (for converting it into an <a>Either</a>
--   <a>String</a> <a>RPM</a>). In the latter case, the String contains any
--   parse error that occurred when reading the RPM data.
parseRPM :: Parser RPM


-- | A module for interacting with an <a>RPM</a> record using conduits.
module Codec.RPM.Conduit

-- | Like <a>parseRPM</a>, but puts the result into a <a>Conduit</a> as an
--   <a>Either</a>, containing either a <a>ParseError</a> or an <a>RPM</a>.
--   The result can be extracted with <a>runExceptT</a>, like so:
--   
--   <pre>
--   import Conduit((.|), runConduitRes, sourceFile)
--   import Control.Monad.Except(runExceptT)
--   result &lt;- runExceptT $ runConduitRes $ sourceFile "some.rpm" .| parseRPMC .| someConsumer
--   </pre>
--   
--   On success, the <a>RPM</a> record will be passed down the conduit for
--   futher processing or consumption. On error, the rest of the conduit
--   will be skipped and the <a>ParseError</a> will be returned as the
--   result to be dealt with.
parseRPMC :: MonadError ParseError m => Conduit ByteString m RPM

-- | Extract the package payload from an <a>RPM</a>, returning it in the
--   conduit.
payloadC :: Monad m => Conduit RPM m ByteString

-- | Extract the package payload from an <a>RPM</a>, decompress it, and
--   return each element of the payload as a <a>Entry</a>.
payloadContentsC :: (MonadResource m, MonadThrow m) => Conduit RPM m Entry


-- | Functions and types for working with version numbers, as understood by
--   RPM.
module Codec.RPM.Version

-- | Like <a>Ordering</a>, but with support for less-than-or-equal and
--   greater-than-or-equal.
data DepOrdering
LT :: DepOrdering
LTE :: DepOrdering
EQ :: DepOrdering
GTE :: DepOrdering
GT :: DepOrdering

-- | RPM supports the concept of dependencies between packages.
--   Collectively, these dependencies are commonly referred to as PRCO -
--   Provides, Requires, Conflicts, and Obsoletes. These dependencies can
--   optionally include version information. These relationships can be
--   examined with various RPM inspection tools or can be found in the spec
--   files that define how a package is built. Examples include:
--   
--   <pre>
--   Requires: python-six
--   Requires: python3-blivet &gt;= 1:1.0
--   Obsoletes: booty &lt;= 0.107-1
--   </pre>
--   
--   This data type expresses a single dependency relationship. The example
--   dependencies above would be represented like so:
--   
--   <pre>
--   DepRequirement "python-six" Nothing
--   DepRequirement "python3-blivet" (Just (GTE, EVR (Just 1) "1.0" ""))
--   DepRequirement "booty" (Just (LTE, EVR Nothing "0.107" "1"))
--   </pre>
--   
--   It is not in the scope of this type to know what kind of relationship
--   a <a>DepRequirement</a> describes.
--   
--   This type derives <a>Ord</a> so that it can be easily be used with
--   collection types, but the derived ordering will not make sense for the
--   purpose of comparing requirements. Use <a>satisfies</a> to determine
--   if requirements match one another.
data DepRequirement
DepRequirement :: Text -> (Maybe (DepOrdering, EVR)) -> DepRequirement

-- | The versioning information portion of a package's name - epoch,
--   version, release.
data EVR
EVR :: Maybe Word32 -> Text -> Text -> EVR

-- | The epoch of a package. This is sort of a super version number, used
--   when a package with an earlier version number must upgrade a package
--   with a later version number. The package with a larger epoch will
--   always in version comparisons. Most packages do not have an epoch.
[epoch] :: EVR -> Maybe Word32

-- | The version number provided by the package's upstream, represented as
--   <a>Text</a>.
[version] :: EVR -> Text

-- | The release number, represented as <a>Text</a>. The release value is
--   added on by a distribution and allows them to make multiple releases
--   of the same upstream version, fixing bugs and applying
--   distribution-specific tweaks.
[release] :: EVR -> Text

-- | Convert a <a>Text</a> representation into an <a>EVR</a> or a
--   <a>ParseError</a> if something goes wrong.
parseEVR :: Text -> Either ParseError EVR

-- | Convert a <a>Text</a> representation into a <a>DepRequirement</a> or a
--   <a>ParseError</a> if something goes wrong.
parseDepRequirement :: Text -> Either ParseError DepRequirement

-- | Determine if a candidate package satisfies the dependency relationship
--   required by some other package.
satisfies :: DepRequirement -> DepRequirement -> Bool

-- | Compare two version numbers and return an <a>Ordering</a>.
vercmp :: Text -> Text -> Ordering
instance GHC.Show.Show Codec.RPM.Version.DepRequirement
instance GHC.Classes.Ord Codec.RPM.Version.DepRequirement
instance GHC.Classes.Eq Codec.RPM.Version.DepRequirement
instance GHC.Show.Show Codec.RPM.Version.DepOrdering
instance GHC.Classes.Ord Codec.RPM.Version.DepOrdering
instance GHC.Classes.Eq Codec.RPM.Version.DepOrdering
instance GHC.Show.Show Codec.RPM.Version.EVR
instance GHC.Classes.Eq Codec.RPM.Version.EVR
instance GHC.Classes.Ord Codec.RPM.Version.EVR
