summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Partition.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/Partition.hs')
-rw-r--r--src/Propellor/Property/Partition.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Propellor/Property/Partition.hs b/src/Propellor/Property/Partition.hs
index 53d8a946..41bdf795 100644
--- a/src/Propellor/Property/Partition.hs
+++ b/src/Propellor/Property/Partition.hs
@@ -45,10 +45,12 @@ kpartx :: FilePath -> ([FilePath] -> Property NoInfo) -> Property NoInfo
kpartx diskimage mkprop = go `requires` Apt.installed ["kpartx"]
where
go = property (propertyDesc (mkprop [])) $ do
+ cleanup -- idempotency
s <- liftIO $ readProcess "kpartx" ["-avs", diskimage]
r <- ensureProperty (mkprop (devlist s))
- void $ liftIO $ boolSystem "kpartx" [Param "-d", File diskimage]
+ cleanup
return r
devlist = mapMaybe (finddev . words) . lines
finddev ("add":"map":s:_) = Just ("/dev/mapper/" ++ s)
finddev _ = Nothing
+ cleanup = void $ liftIO $ boolSystem "kpartx" [Param "-d", File diskimage]