disk/partition_table: expose GetBuildPackages() function

This describes the packages necessary to create the partition table.

Use this in the pipelines and drop the explicit mentions from the build
pipeline.
This commit is contained in:
Tom Gundersen 2022-07-07 19:12:28 +01:00
parent 0d3d35e154
commit fed620b861
4 changed files with 56 additions and 46 deletions

View file

@ -571,3 +571,54 @@ func (pt *PartitionTable) ensureLVM() error {
return nil
}
func (pt *PartitionTable) GetBuildPackages() []string {
packages := []string{}
hasLVM := false
hasBtrfs := false
hasXFS := false
hasFAT := false
hasEXT4 := false
introspectPT := func(e Entity, path []Entity) error {
switch ent := e.(type) {
case *LVMLogicalVolume:
hasLVM = true
case *Btrfs:
hasBtrfs = true
case *Filesystem:
switch ent.GetFSType() {
case "vfat":
hasFAT = true
case "btrfs":
hasBtrfs = true
case "xfs":
hasXFS = true
case "ext4":
hasEXT4 = true
}
}
return nil
}
_ = pt.ForEachEntity(introspectPT)
// TODO: LUKS
if hasLVM {
packages = append(packages, "lvm2")
}
if hasBtrfs {
packages = append(packages, "btrfs-progs")
}
if hasXFS {
packages = append(packages, "xfsprogs")
}
if hasFAT {
packages = append(packages, "dosfstools")
}
if hasEXT4 {
packages = append(packages, "e2fsprogs")
}
return packages
}