diff options
| author | Sean Whitton <spwhitton@spwhitton.name> | 2017-03-19 07:58:23 -0700 |
|---|---|---|
| committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-03-19 07:58:23 -0700 |
| commit | 21eaec2416dc44a9341699e0772d54397d5f5201 (patch) | |
| tree | 510e59586b4ec2caba1817a0c91dfe937b411eac /src | |
| parent | 2805cb7239ea7308cb10ad2e7e7c24223dddb8b5 (diff) | |
add HostMirror info type
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Apt.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index c681eee6..70b9474e 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -1,9 +1,11 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DeriveDataTypeable #-} module Propellor.Property.Apt where import Data.Maybe import Data.List +import Data.Typeable import System.IO import Control.Monad import Control.Applicative @@ -13,6 +15,23 @@ import Propellor.Base import qualified Propellor.Property.File as File import qualified Propellor.Property.Service as Service import Propellor.Property.File (Line) +import Propellor.Types.Info + +data HostMirror = HostMirror Url + deriving (Eq, Show, Typeable) + +getHostMirror :: Propellor Url +getHostMirror = do + mirrorInfo <- getHostMirrorInfo + osInfo <- getOS + return $ case (osInfo, mirrorInfo) of + (_, Just (HostMirror u)) -> u + (Just (System (Debian _ _) _), _) -> + "http://deb.debian.org/debian" + _ -> error "no Apt mirror defined for this host or OS" + where + getHostMirrorInfo :: Propellor (Maybe HostMirror) + getHostMirrorInfo = fromInfoVal <$> askInfo sourcesList :: FilePath sourcesList = "/etc/apt/sources.list" |
