summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2015-09-02 15:23:47 -0700
committerJoey Hess2015-09-02 15:23:47 -0700
commitfe59ea1a62ff8dd15e30646802b9ca045df3008b (patch)
treefcceba43ff80d83fdd50d1aeb8407db47aa92145
parent418e6a5b4ee36360911cdff14f70357c5c2bfc80 (diff)
propellor spin
-rw-r--r--src/Propellor/Property/DiskImage.hs4
-rw-r--r--src/Propellor/Property/Parted.hs3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 86be3a9b..1d087cc0 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -88,9 +88,9 @@ imageBuilt' rebuild img mkchroot mkparttable final =
liftIO $ unmountBelow chrootdir
szm <- M.mapKeys (toSysDir chrootdir) . M.map toPartSize
<$> liftIO (dirSizes chrootdir)
+ let calcsz = \mnts -> saneSz . fromMaybe defSz . getMountSz szm mnts
-- tie the knot!
- -- TODO if any size is < 1 MB, use 1 MB for sanity
- let (mnts, t) = mkparttable (map (saneSz . fromMaybe defSz . getMountSz szm mnts) mnts)
+ let (mnts, t) = mkparttable (map (calcsz mnts) mnts)
liftIO $ print (mnts, t)
ensureProperty $
imageExists img (partTableSize t)
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs
index 1ff8677a..0b77fad1 100644
--- a/src/Propellor/Property/Parted.hs
+++ b/src/Propellor/Property/Parted.hs
@@ -95,8 +95,9 @@ newtype PartSize = MegaBytes Integer
instance PartedVal PartSize where
val (MegaBytes n) = show n ++ "MB"
+-- | Rounds up to the nearest MegaByte.
toPartSize :: ByteSize -> PartSize
-toPartSize b = MegaBytes (b `div` 1000000)
+toPartSize b = MegaBytes $ ceiling (fromInteger b / 1000000 :: Double)
fromPartSize :: PartSize -> ByteSize
fromPartSize (MegaBytes b) = b * 1000000