From 21eaec2416dc44a9341699e0772d54397d5f5201 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Mar 2017 07:58:23 -0700 Subject: add HostMirror info type --- src/Propellor/Property/Apt.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Propellor/Property/Apt.hs') 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" -- cgit v1.2.3