diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-01-24 22:38:10 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-01-24 22:38:51 -0400 |
| commit | 0ee04ecc43e047b00437fb660e71f7dd67dd3afc (patch) | |
| tree | 621e0ebc68a2afb9410ce6f368bec865f31cc507 /src/Propellor/Property/OS.hs | |
| parent | 141a7c028bba8d5b9743f2ab1397e69c313a523c (diff) | |
GADT properties seem to work (untested)
* Property has been converted to a GADT, and will be Property NoInfo
or Property HasInfo.
This was done to make sure that ensureProperty is only used on
properties that do not have Info.
Transition guide:
- Change all "Property" to "Property NoInfo" or "Property WithInfo"
(The compiler can tell you if you got it wrong!)
- To construct a RevertableProperty, it is useful to use the new
(<!>) operator
- Constructing a list of properties can be problimatic, since
Property NoInto and Property WithInfo are different types and cannot
appear in the same list. To deal with this, "props" has been added,
and can built up a list of properties of different types,
using the same (&) and (!) operators that are used to build
up a host's properties.
Diffstat (limited to 'src/Propellor/Property/OS.hs')
| -rw-r--r-- | src/Propellor/Property/OS.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs index c1b085a6..710428d4 100644 --- a/src/Propellor/Property/OS.hs +++ b/src/Propellor/Property/OS.hs @@ -65,7 +65,7 @@ import Control.Exception (throw) -- > & User.accountFor "joey" -- > & User.hasSomePassword "joey" -- > -- rest of system properties here -cleanInstallOnce :: Confirmation -> Property +cleanInstallOnce :: Confirmation -> Property NoInfo cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $ go `requires` confirmed "clean install confirmed" confirmation where @@ -89,10 +89,10 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $ (Just u@(System (Ubuntu _) _)) -> debootstrap u _ -> error "os is not declared to be Debian or Ubuntu" - debootstrap targetos = ensureProperty $ toProp $ + debootstrap targetos = ensureProperty $ fromJust $ toSimpleProp $ -- Ignore the os setting, and install debootstrap from -- source, since we don't know what OS we're running in yet. - Debootstrap.built' Debootstrap.sourceInstall + Debootstrap.built' (toProp Debootstrap.sourceInstall) newOSDir targetos Debootstrap.DefaultConfig -- debootstrap, I wish it was faster.. -- TODO eatmydata to speed it up @@ -180,7 +180,7 @@ massRename = go [] data Confirmation = Confirmed HostName -confirmed :: Desc -> Confirmation -> Property +confirmed :: Desc -> Confirmation -> Property NoInfo confirmed desc (Confirmed c) = property desc $ do hostname <- asks hostName if hostname /= c @@ -192,7 +192,7 @@ confirmed desc (Confirmed c) = property desc $ do -- | </etc/network/interfaces> is configured to bring up the network -- interface that currently has a default route configured, using -- the same (static) IP address. -preserveNetwork :: Property +preserveNetwork :: Property NoInfo preserveNetwork = go `requires` Network.cleanInterfacesFile where go = property "preserve network configuration" $ do @@ -206,7 +206,7 @@ preserveNetwork = go `requires` Network.cleanInterfacesFile return FailedChange -- | </etc/resolv.conf> is copied from the old OS -preserveResolvConf :: Property +preserveResolvConf :: Property NoInfo preserveResolvConf = check (fileExist oldloc) $ property (newloc ++ " copied from old OS") $ do ls <- liftIO $ lines <$> readFile oldloc @@ -218,7 +218,7 @@ preserveResolvConf = check (fileExist oldloc) $ -- | </root/.ssh/authorized_keys> has added to it any ssh keys that -- were authorized in the old OS. Any other contents of the file are -- retained. -preserveRootSshAuthorized :: Property +preserveRootSshAuthorized :: Property NoInfo preserveRootSshAuthorized = check (fileExist oldloc) $ property (newloc ++ " copied from old OS") $ do ks <- liftIO $ lines <$> readFile oldloc @@ -228,7 +228,7 @@ preserveRootSshAuthorized = check (fileExist oldloc) $ oldloc = oldOSDir ++ newloc -- Removes the old OS's backup from </old-os> -oldOSRemoved :: Confirmation -> Property +oldOSRemoved :: Confirmation -> Property NoInfo oldOSRemoved confirmation = check (doesDirectoryExist oldOSDir) $ go `requires` confirmed "old OS backup removal confirmed" confirmation where |
