module Debian.Release where
import Debian.URI
data ReleaseName = ReleaseName { relName :: String } deriving (Eq, Ord, Read, Show)
parseReleaseName :: String -> ReleaseName
parseReleaseName name = ReleaseName {relName = unEscapeString name}
releaseName' :: ReleaseName -> String
releaseName' (ReleaseName {relName = s}) = escapeURIString isAllowedInURI s
data Arch = Source | Binary String deriving (Read, Show, Eq, Ord)
archName :: Arch -> String
archName Source = "source"
archName (Binary arch) = arch
newtype Section = Section String deriving (Read, Show, Eq, Ord)
data SubSection = SubSection { section :: Section, subSectionName :: String } deriving (Read, Eq, Ord)
sectionName :: SubSection -> String
sectionName (SubSection (Section "main") y) = y
sectionName (SubSection x y) = sectionName' x ++ "/" ++ y
sectionName' :: Section -> String
sectionName' (Section s) = escapeURIString isAllowedInURI s
sectionNameOfSubSection :: SubSection -> String
sectionNameOfSubSection = sectionName' . section
parseSection section =
case span (/= '/') section of
(x, "") -> SubSection (Section "main") x
("main", y) -> SubSection (Section "main") y
(x, y) -> SubSection (Section x) (tail y)
parseSection' name =
Section (unEscapeString name)