summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2018-01-06 14:48:34 -0400
committerJoey Hess2018-01-06 14:48:34 -0400
commitbc6045c8b5333ac5d407e8f4b96bb0d9f50dfa9a (patch)
tree303bf5f1e584e58a31bfb45f6b8c714b2e3d622e /src
parent48196467d11a856f411208ba5eadb20dd9455c10 (diff)
changes to allow GPT BIOS boot partitions
* Parted: Allow partitions to have no filesystem, for eg, GPT BIOS boot partitions. (API change) * Added rawPartition to PartSpec, for specifying partitions with no filesystem. * Added BiosGrubFlag to PartFlag. Note that man parted does not list the "bios_boot" flag, but I found it in its html documentation. Other flags may also be missing. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/DiskImage.hs2
-rw-r--r--src/Propellor/Property/DiskImage/PartSpec.hs9
-rw-r--r--src/Propellor/Property/Installer/Target.hs4
-rw-r--r--src/Propellor/Property/Parted.hs18
-rw-r--r--src/Propellor/Property/Parted/Types.hs7
5 files changed, 24 insertions, 16 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 24459476..289de151 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -420,7 +420,7 @@ imageFinalized final img mnts mntopts devs (PartTable _ _ parts) =
orderedmntsdevs = sortBy (compare `on` fst) $ zip mnts (zip mntopts devs)
swaps = map (SwapPartition . partitionLoopDev . snd) $
- filter ((== LinuxSwap) . partFs . fst) $
+ filter ((== Just LinuxSwap) . partFs . fst) $
zip parts devs
mountall top = forM_ orderedmntsdevs $ \(mp, (mopts, loopdev)) -> case mp of
diff --git a/src/Propellor/Property/DiskImage/PartSpec.hs b/src/Propellor/Property/DiskImage/PartSpec.hs
index 942cfa3e..b78e4280 100644
--- a/src/Propellor/Property/DiskImage/PartSpec.hs
+++ b/src/Propellor/Property/DiskImage/PartSpec.hs
@@ -9,6 +9,7 @@ module Propellor.Property.DiskImage.PartSpec (
partition,
-- * PartSpec combinators
swapPartition,
+ rawPartition,
mountedAt,
addFreeSpace,
setSize,
@@ -48,11 +49,15 @@ import Data.Ord
-- The partition is not mounted anywhere by default; use the combinators
-- below to configure it.
partition :: Monoid t => Fs -> PartSpec t
-partition fs = (Nothing, mempty, mkPartition fs, mempty)
+partition fs = (Nothing, mempty, mkPartition (Just fs), mempty)
-- | Specifies a swap partition of a given size.
swapPartition :: Monoid t => PartSize -> PartSpec t
-swapPartition sz = (Nothing, mempty, const (mkPartition LinuxSwap sz), mempty)
+swapPartition sz = (Nothing, mempty, const (mkPartition (Just LinuxSwap) sz), mempty)
+
+-- | Specifies a partition without any filesystem, of a given size.
+rawPartition :: Monoid t => PartSize -> PartSpec t
+rawPartition sz = (Nothing, mempty, const (mkPartition Nothing sz), mempty)
-- | Specifies where to mount a partition.
mountedAt :: PartSpec t -> MountPoint -> PartSpec t
diff --git a/src/Propellor/Property/Installer/Target.hs b/src/Propellor/Property/Installer/Target.hs
index 62ec4082..80e660ad 100644
--- a/src/Propellor/Property/Installer/Target.hs
+++ b/src/Propellor/Property/Installer/Target.hs
@@ -246,10 +246,10 @@ fstabLists userinput (TargetPartTable _ partspecs) = setup <!> doNothing
partitions = map (\(mp, _, mkpart, _) -> (mp, mkpart mempty)) partspecs
mnts = mapMaybe fst $
- filter (\(_, p) -> partFs p /= LinuxSwap) partitions
+ filter (\(_, p) -> partFs p /= Just LinuxSwap && partFs p /= Nothing) partitions
swaps targetdev =
map (Fstab.SwapPartition . diskPartition targetdev . snd) $
- filter (\((_, p), _) -> partFs p == LinuxSwap)
+ filter (\((_, p), _) -> partFs p == Just LinuxSwap)
(zip partitions partNums)
-- | Make the target bootable using whatever bootloader is installed on it.
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs
index 97cf815e..81b84972 100644
--- a/src/Propellor/Property/Parted.hs
+++ b/src/Propellor/Property/Parted.hs
@@ -62,8 +62,10 @@ partitioned eep disk parttable@(PartTable _ _ parts) = property' desc $ \w -> do
where
desc = disk ++ " partitioned"
formatl devs = combineProperties desc (toProps $ map format (zip parts devs))
- format (p, dev) = Partition.formatted' (partMkFsOpts p)
- Partition.YesReallyFormatPartition (partFs p) dev
+ format (p, dev) = case partFs p of
+ Just fs -> Partition.formatted' (partMkFsOpts p)
+ Partition.YesReallyFormatPartition fs dev
+ Nothing -> doNothing
-- | Gets the total size of the disk specified by the partition table.
partTableSize :: PartTable -> ByteSize
@@ -81,12 +83,12 @@ calcPartedParamsSize (PartTable tabletype alignment parts) =
, pval f
, pval b
]
- mkpart partnum startpos endpos p =
- [ "mkpart"
- , pval (partType p)
- , pval (partFs p)
- , partposexact startpos
- , partposfuzzy endpos
+ mkpart partnum startpos endpos p = catMaybes
+ [ Just "mkpart"
+ , Just $ pval (partType p)
+ , fmap pval (partFs p)
+ , Just $ partposexact startpos
+ , Just $ partposfuzzy endpos
] ++ case partName p of
Just n -> ["name", show partnum, n]
Nothing -> []
diff --git a/src/Propellor/Property/Parted/Types.hs b/src/Propellor/Property/Parted/Types.hs
index e5c62739..cfd8760d 100644
--- a/src/Propellor/Property/Parted/Types.hs
+++ b/src/Propellor/Property/Parted/Types.hs
@@ -31,7 +31,7 @@ instance Monoid PartTable where
data Partition = Partition
{ partType :: PartType
, partSize :: PartSize
- , partFs :: Partition.Fs
+ , partFs :: Maybe Partition.Fs
, partMkFsOpts :: Partition.MkfsOpts
, partFlags :: [(PartFlag, Bool)] -- ^ flags can be set or unset (parted may set some flags by default)
, partName :: Maybe String -- ^ optional name for partition (only works for GPT, PC98, MAC)
@@ -39,7 +39,7 @@ data Partition = Partition
deriving (Show)
-- | Makes a Partition with defaults for non-important values.
-mkPartition :: Partition.Fs -> PartSize -> Partition
+mkPartition :: Maybe Partition.Fs -> PartSize -> Partition
mkPartition fs sz = Partition
{ partType = Primary
, partSize = sz
@@ -105,7 +105,7 @@ fromAlignment :: Alignment -> ByteSize
fromAlignment (Alignment n) = n
-- | Flags that can be set on a partition.
-data PartFlag = BootFlag | RootFlag | SwapFlag | HiddenFlag | RaidFlag | LvmFlag | LbaFlag | LegacyBootFlag | IrstFlag | EspFlag | PaloFlag
+data PartFlag = BootFlag | RootFlag | SwapFlag | HiddenFlag | RaidFlag | LvmFlag | LbaFlag | LegacyBootFlag | IrstFlag | EspFlag | PaloFlag | BiosGrubFlag
deriving (Show)
instance PartedVal PartFlag where
@@ -120,6 +120,7 @@ instance PartedVal PartFlag where
pval IrstFlag = "irst"
pval EspFlag = "esp"
pval PaloFlag = "palo"
+ pval BiosGrubFlag = "bios_grub"
instance PartedVal Bool where
pval True = "on"