diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-08-26 17:29:01 -0700 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-08-31 13:54:49 -0700 |
| commit | 94d6f453e7441749a83f0ea69d0e7c12737565a1 (patch) | |
| tree | 6d13ab00a5594b77a1bfeccb9e87cc78c3b02859 | |
| parent | c95f05ef8874b21c9a4f9756b8af79e178d80232 (diff) | |
propellor spin
(cherry picked from commit 7087a94b21a086a98784d17b45dd2b7779e320e9)
| -rw-r--r-- | src/Propellor/Property/DiskImage.hs | 6 | ||||
| -rw-r--r-- | src/Propellor/Property/Parted.hs | 18 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index a3d4073a..691f79bc 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -57,8 +57,8 @@ type MountPoint = Maybe FilePath -- exploiting laziness and tying the knot. -- -- (Partitions that are not mounted (ie, LinuxSwap) will have 128 MegaBytes --- provides as a default size.) -type MkPartTable = [MegaBytes] -> ([MountPoint], PartTable) +-- provided as a default size.) +type MkPartTable = [PartSize] -> ([MountPoint], PartTable) -- TODO tie the knot -- let f = fitChrootSize MSDOS [(Just "/", mkPartition EXT2)] @@ -69,7 +69,7 @@ type MkPartTable = [MegaBytes] -> ([MountPoint], PartTable) -- -- Partitions that are not mounted (ie, LinuxSwap) will have their size -- set to 128 MegaBytes, unless it's overridden. -fitChrootSize :: TableType -> [(MountPoint, MegaBytes -> Partition)] -> MkPartTable +fitChrootSize :: TableType -> [(MountPoint, PartSize -> Partition)] -> MkPartTable fitChrootSize tt l basesizes = (mounts, parttable) where (mounts, sizers) = unzip l diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs index aa7bece4..29d94b4c 100644 --- a/src/Propellor/Property/Parted.hs +++ b/src/Propellor/Property/Parted.hs @@ -6,9 +6,9 @@ module Propellor.Property.Parted ( Partition(..), mkPartition, Partition.Fs(..), - MegaBytes(..), + PartSize(..), ByteSize, - toMegaBytes, + toPartSize, Partition.MkfsOpts, PartType(..), PartFlag(..), @@ -48,7 +48,7 @@ instance Monoid PartTable where -- | A partition on the disk. data Partition = Partition { partType :: PartType - , partSize :: MegaBytes + , partSize :: PartSize , partFs :: Partition.Fs , partMkFsOpts :: Partition.MkfsOpts , partFlags :: [(PartFlag, Bool)] -- ^ flags can be set or unset (parted may set some flags by default) @@ -57,7 +57,7 @@ data Partition = Partition deriving (Show) -- | Makes a Partition with defaults for non-important values. -mkPartition :: Partition.Fs -> MegaBytes -> Partition +mkPartition :: Partition.Fs -> PartSize -> Partition mkPartition fs sz = Partition { partType = Primary , partSize = sz @@ -80,16 +80,16 @@ instance PartedVal PartType where -- automatically lay out the partitions. -- -- Note that these are SI megabytes, not mebibytes. -newtype MegaBytes = MegaBytes Integer +newtype PartSize = MegaBytes Integer deriving (Show) -instance PartedVal MegaBytes where +instance PartedVal PartSize where val (MegaBytes n) = show n ++ "MB" -toMegaBytes :: ByteSize -> MegaBytes -toMegaBytes b = MegaBytes (b `div` 1000000) +toPartSize :: ByteSize -> PartSize +toPartSize b = MegaBytes (b `div` 1000000) -instance Monoid MegaBytes where +instance Monoid PartSize where mempty = MegaBytes 0 mappend (MegaBytes a) (MegaBytes b) = MegaBytes (a + b) |
