module Propellor.Types.OS (
System(..),
Distribution(..),
TargetOS(..),
DebianSuite(..),
FreeBSDRelease(..),
FBSDVersion(..),
isStable,
Release,
Architecture,
HostName,
UserName,
User(..),
Group(..),
userGroup,
Port(..),
fromPort,
systemToTargetOS,
) where
import Network.BSD (HostName)
import Data.Typeable
import Data.String
data System = System Distribution Architecture
deriving (Show, Eq, Typeable)
data Distribution
= Debian DebianSuite
| Buntish Release
| FreeBSD FreeBSDRelease
deriving (Show, Eq)
data TargetOS
= OSDebian
| OSBuntish
| OSFreeBSD
deriving (Show, Eq, Ord)
systemToTargetOS :: System -> TargetOS
systemToTargetOS (System (Debian _) _) = OSDebian
systemToTargetOS (System (Buntish _) _) = OSBuntish
systemToTargetOS (System (FreeBSD _) _) = OSFreeBSD
data DebianSuite = Experimental | Unstable | Testing | Stable Release
deriving (Show, Eq)
data FreeBSDRelease = FBSDProduction FBSDVersion | FBSDLegacy FBSDVersion
deriving (Show, Eq)
data FBSDVersion = FBSD101 | FBSD102 | FBSD093
deriving (Eq)
instance IsString FBSDVersion where
fromString "10.1-RELEASE" = FBSD101
fromString "10.2-RELEASE" = FBSD102
fromString "9.3-RELEASE" = FBSD093
fromString _ = error "Invalid FreeBSD release"
instance Show FBSDVersion where
show FBSD101 = "10.1-RELEASE"
show FBSD102 = "10.2-RELEASE"
show FBSD093 = "9.3-RELEASE"
isStable :: DebianSuite -> Bool
isStable (Stable _) = True
isStable _ = False
type Release = String
type Architecture = String
type UserName = String
newtype User = User UserName
deriving (Eq, Ord, Show)
newtype Group = Group String
deriving (Eq, Ord, Show)
userGroup :: User -> Group
userGroup (User u) = Group u
newtype Port = Port Int
deriving (Eq, Show)
fromPort :: Port -> String
fromPort (Port p) = show p