summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Partition.hs
diff options
context:
space:
mode:
authorJoey Hess2015-08-25 21:48:31 -0700
committerJoey Hess2015-08-25 21:52:28 -0700
commit474119770bd54a905fcdda25a7bb12f2b1ea1307 (patch)
treee73de192ec61ebfdee5a528e27b0296ef2284f1c /src/Propellor/Property/Partition.hs
parentd48e5ca96e371946befd234f384eeb673099d3b2 (diff)
idempotency fix for kpartx
noticed kpartx could get confused if a disk image it had mapped was deleted and a fresh one mapped
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]