summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2015-10-23 11:42:59 -0400
committerJoey Hess2015-10-23 11:42:59 -0400
commit2e42b9db53ecf8cc33d92e2374e0d5ca24013a85 (patch)
tree7cb3d3721f50c57cd1b75705e0eb5cbd7674f35d /src/Propellor
parent27635a19c9d9ff654b95e5685a19661272732dd6 (diff)
propellor spin
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/DiskImage.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 56ee2a8c..af8a020b 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -47,7 +47,7 @@ import Propellor.Property.Partition
import Propellor.Property.Rsync
import Utility.Path
-import Data.List (isPrefixOf, sortBy)
+import Data.List (isPrefixOf, isInfixOf, sortBy)
import Data.Function (on)
import qualified Data.Map.Strict as M
import qualified Data.ByteString.Lazy as L
@@ -309,6 +309,10 @@ imageFinalized (_, final) mnts devs (PartTable _ parts) =
-- comes before /usr/local
orderedmntsdevs :: [(Maybe MountPoint, LoopDev)]
orderedmntsdevs = sortBy (compare `on` fst) $ zip mnts devs
+
+ swaps = map (SwapPartition . partitionLoopDev . snd) $
+ filter ((== LinuxSwap) . partFs . fst) $
+ zip parts devs
mountall top = forM_ orderedmntsdevs $ \(mp, loopdev) -> case mp of
Nothing -> noop
@@ -323,13 +327,13 @@ imageFinalized (_, final) mnts devs (PartTable _ parts) =
umountLazy top
writefstab top = do
- old <- catchDefaultIO "" $ readFileStrict "/etc/fstab"
+ old <- catchDefaultIO [] $ filter (not . unconfigured) . lines
+ <$> readFileStrict (top ++ "/etc/fstab")
new <- genFstab (map (top ++) (catMaybes mnts))
swaps (toSysDir top)
- writeFile "/etc/fstab" (unlines new ++ old)
- swaps = map (SwapPartition . partitionLoopDev . snd) $
- filter ((== LinuxSwap) . partFs . fst) $
- zip parts devs
+ writeFile "/etc/fstab" $ unlines $ new ++ old
+ -- Eg "UNCONFIGURED FSTAB FOR BASE SYSTEM"
+ unconfigured s = "UNCONFIGURED" `isInfixOf` s
noFinalization :: Finalization
noFinalization = (doNothing, \_ _ -> doNothing)