summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/DiskImage.hs19
-rw-r--r--src/Propellor/Property/Mount.hs4
-rw-r--r--src/Propellor/Property/Parted.hs1
-rw-r--r--src/Propellor/Property/Parted/Types.hs2
4 files changed, 18 insertions, 8 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 79865db4..c9998d3c 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -274,13 +274,18 @@ partitionsPopulated chrootdir mnts mntopts devs = property' desc $ \w ->
desc = "partitions populated from " ++ chrootdir
go _ Nothing _ _ = noChange
- go w (Just mnt) mntopt loopdev = withTmpDir "mnt" $ \tmpdir -> bracket
- (liftIO $ mount "auto" (partitionLoopDev loopdev) tmpdir mntopt)
- (const $ liftIO $ umountLazy tmpdir)
- $ \ismounted -> if ismounted
- then ensureProperty w $
- syncDirFiltered (filtersfor mnt) (chrootdir ++ mnt) tmpdir
- else return FailedChange
+ go w (Just mnt) mntopt loopdev = ifM (liftIO $ doesDirectoryExist srcdir) $
+ ( withTmpDir "mnt" $ \tmpdir -> bracket
+ (liftIO $ mount "auto" (partitionLoopDev loopdev) tmpdir mntopt)
+ (const $ liftIO $ umountLazy tmpdir)
+ $ \ismounted -> if ismounted
+ then ensureProperty w $
+ syncDirFiltered (filtersfor mnt) srcdir tmpdir
+ else return FailedChange
+ , return NoChange
+ )
+ where
+ srcdir = chrootdir ++ mnt
filtersfor mnt =
let childmnts = map (drop (length (dropTrailingPathSeparator mnt))) $
diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs
index c047161d..e8f3f092 100644
--- a/src/Propellor/Property/Mount.hs
+++ b/src/Propellor/Property/Mount.hs
@@ -149,4 +149,6 @@ umountLazy mnt =
unmountBelow :: FilePath -> IO ()
unmountBelow d = do
submnts <- mountPointsBelow d
- forM_ submnts umountLazy
+ -- sort so sub-mounts are unmounted before the mount point
+ -- containing them
+ forM_ (sort submnts) umountLazy
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs
index 8afd62ea..38c55b93 100644
--- a/src/Propellor/Property/Parted.hs
+++ b/src/Propellor/Property/Parted.hs
@@ -192,6 +192,7 @@ defSz = MegaBytes 128
-- Add an additional 200 mb for temp files, journals, etc.
fudgeSz :: PartSize -> PartSize
fudgeSz (MegaBytes n) = MegaBytes (n + n `div` 100 * 2 + 3 + 200)
+fudgeSz (Bytes n) = fudgeSz (toPartSize n)
alignTo :: Alignment -> PartSize -> ByteSize
alignTo _ (Bytes n) = n -- no alignment done for Bytes
diff --git a/src/Propellor/Property/Parted/Types.hs b/src/Propellor/Property/Parted/Types.hs
index 6b6b42e2..e5c62739 100644
--- a/src/Propellor/Property/Parted/Types.hs
+++ b/src/Propellor/Property/Parted/Types.hs
@@ -88,6 +88,8 @@ instance Monoid PartSize where
reducePartSize :: PartSize -> PartSize -> PartSize
reducePartSize (MegaBytes a) (MegaBytes b) = MegaBytes (a - b)
+reducePartSize (Bytes a) b = Bytes (a - fromPartSize b)
+reducePartSize a (Bytes b) = Bytes (fromPartSize a - b)
-- | Partitions need to be aligned for optimal efficiency.
-- The alignment is a number of bytes.