summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/Propellor/Property/Parted.hs2
-rw-r--r--src/Propellor/Property/Partition.hs4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs
index f463164e..aa7bece4 100644
--- a/src/Propellor/Property/Parted.hs
+++ b/src/Propellor/Property/Parted.hs
@@ -77,7 +77,7 @@ instance PartedVal PartType where
val Extended = "extended"
-- | All partition sizing is done in megabytes, so that parted can
--- automatically lay out the partitions.
+-- automatically lay out the partitions.
--
-- Note that these are SI megabytes, not mebibytes.
newtype MegaBytes = MegaBytes Integer
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]