From 83a07d5c56223fe31d64a691c9775b5d237a9f3f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Oct 2015 11:46:11 -0400 Subject: propellor spin --- src/Propellor/Property/DiskImage.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Property') diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index af8a020b..9da374c7 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -77,6 +77,10 @@ type DiskImage = FilePath -- > `addFreeSpace` MegaBytes 100 -- > , swapPartition (MegaBytes 256) -- > ] +-- +-- Note that the disk image file is reused if it already exists, +-- to avoid expensive IO to generate a new one. And, it's updated in-place, +-- so its contents are undefined during the build process. imageBuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty imageBuilt = imageBuilt' False @@ -327,11 +331,12 @@ imageFinalized (_, final) mnts devs (PartTable _ parts) = umountLazy top writefstab top = do + let fstab = top ++ "/etc/fstab" old <- catchDefaultIO [] $ filter (not . unconfigured) . lines - <$> readFileStrict (top ++ "/etc/fstab") + <$> readFileStrict fstab new <- genFstab (map (top ++) (catMaybes mnts)) swaps (toSysDir top) - writeFile "/etc/fstab" $ unlines $ new ++ old + writeFile fstab $ unlines $ new ++ old -- Eg "UNCONFIGURED FSTAB FOR BASE SYSTEM" unconfigured s = "UNCONFIGURED" `isInfixOf` s -- cgit v1.2.3