Documentation
¶
Overview ¶
Package boot provides implementations to help manage the bootloader setup and installation on various medium types.
Index ¶
- Variables
- func HaveLoaderWithMask(loaders []Loader, mask Capability) bool
- type Capability
- type ConfigurationSource
- type Dracut
- type FileType
- type IsolinuxTemplate
- type Kernel
- type Loader
- type SyslinuxLoader
- func (s *SyslinuxLoader) GetCapabilities() Capability
- func (s *SyslinuxLoader) GetSpecialFile(t FileType) string
- func (s *SyslinuxLoader) Init(c *config.ImageConfiguration) error
- func (s *SyslinuxLoader) Install(op Capability, c ConfigurationSource) error
- func (s *SyslinuxLoader) LocateAsset(name string) error
Constants ¶
This section is empty.
Variables ¶
var ( // DracutLiveOSModules are modules to enable for Live OS Usage // TODO: Make systemd dependent on the presence of systemd in the sysroot DracutLiveOSModules = []string{"dmsquash-live", "systemd", "pollcdrom"} // DracutLiveOSDrivers are drivers that should be shipped for LiveOS functionality to work // TODO: Investigate now-dead stuff and curate this list DracutLiveOSDrivers = []string{ "squashfs", "ext2", "vfat", "msdos", "sr_mod", "sd_mod", "ehci_hcd", "uhci_hcd", "xhci_hcd", "xhci_pci", "ohci_hcd", "usb_storage", "usbhid", "dm_mod", "ata_generic", "libata", } )
var ( // ErrNotYetImplemented is just a placeholder ErrNotYetImplemented = errors.New("Not yet implemented") // ErrUnknownLoader is reported for an unknown bootloader ErrUnknownLoader = errors.New("Unknown bootloader configured") )
var ( // SyslinuxPaths contains paths known to be used by the majority of Linux // distributions, so that we can search for required files prior to actually // trying to spin an ISO. SyslinuxPaths = []string{ "/usr/lib64/syslinux", "/usr/lib/syslinux", "/usr/share/syslinux", } // SyslinuxAssets is the core set of assets required by all syslinux usages SyslinuxAssets = []string{ "libutil.c32", "libcom32.c32", "ldlinux.c32", } // SyslinuxAssetsISO are the assets required explicitly for ISOs, i.e. menu bits SyslinuxAssetsISO = []string{ "vesamenu.c32", "isolinux.bin", "vesa.c32", "isohdpfx.bin", } )
var ( // DefaultIsolinuxTemplate is the built-in template for isolinux.cfg DefaultIsolinuxTemplate = `` /* 1031-byte string literal not displayed */ )
var ( // ErrNoKernelFound is returned when a builder cannot find a kernel in the given root ErrNoKernelFound = errors.New("Could not find a valid kernel") )
Functions ¶
func HaveLoaderWithMask ¶
func HaveLoaderWithMask(loaders []Loader, mask Capability) bool
HaveLoaderWithMask will look in the set of loaders for the given mask, and simply return if the given mask is supported or not.
Types ¶
type Capability ¶
type Capability uint8
Capability refers to the type of operations that a bootloader supports
const ( // CapInstallUEFI means the bootloader supports UEFI loading CapInstallUEFI Capability = 1 << iota // CapInstallLegacy means the bootloader supports MBR/legacy loading CapInstallLegacy Capability = 1 << iota // CapInstallISO is used for bootloaders reporting ISO support CapInstallISO Capability = 1 << iota // CapInstallRaw is reported by bootloaders that can install to block devices CapInstallRaw Capability = 1 << iota )
type ConfigurationSource ¶
type ConfigurationSource interface {
// JoinRootPath is used by implementations to join a resource path on the rootfs
JoinRootPath(paths ...string) string
// JoinDeployPath is used by implementations to join a resource path on the deployment
// directory.
// This is mostly of interest to ISO deployments
JoinDeployPath(paths ...string) string
// GetRootDevice should return the device used for / mount, if relevant. This
// should return "" unless used in Raw capability
GetRootDevice() string
// GetBootDevice should return the device used for the boot mount, if relevant.
// This should return "" unless used in the Raw capability
GetBootDevice() string
// GetKernel should return the default kernel, configured with the correct
// asset path
GetKernel() *Kernel
}
ConfigurationSource should be implemented by Builder instances (or their helpers) to help with bootloader installation.
type Dracut ¶
type Dracut struct {
// Additional options to pass to dracut when generating
Options []string
// Extra modules to enable
Modules []string
// Extra drivers to enable
Drivers []string
// The filename to use within the root (should include / prefix)
OutputFilename string
// Compression method, i.e. --lz4, --gzip, etc.
CompressionMethod string
// contains filtered or unexported fields
}
Dracut provides wrapping around dracut generation in chroots
type FileType ¶
type FileType string
A FileType is a named special file
const ( // FileTypeBootElToritoCatalog should be within the boot directory on an ISO's // boot directory, depending on the bootloader implementation. Note this is not // a "real" file but one created by xorriso. FileTypeBootElToritoCatalog FileType = "boot.cat" // FileTypeBootElToritoBinary is the isolinux.bin style file, i.e. the actual // bootloader itself. FileTypeBootElToritoBinary FileType = "boot.bin" // FileTypeBootMBR is the ISO MBR file. This permits hybrid ISO generation for // both USB & CD. FileTypeBootMBR FileType = "boot.mbr" )
type IsolinuxTemplate ¶
type IsolinuxTemplate struct {
Kernel *Kernel
Label string // CDLABEL
Title string // Needs to come from config!
StartString string
}
IsolinuxTemplate is used to populate fields in the isolinux.cfg
type Kernel ¶
type Kernel struct {
Version string
Path string
BaseName string
TargetPath string // Relative path within the filesystem
TargetInitrd string // Relative initrd path within the filesystem
}
A Kernel is exactly what it looks like. :p
func GetKernelFromRoot ¶
GetKernelFromRoot will attempt to "learn" about the kernel from the rootfs and return a populated kernel struct.
type Loader ¶
type Loader interface {
// Init is used by bootloader implementations to assert sanity & host-side tooling
// is present.
Init(c *config.ImageConfiguration) error
// GetCapabilities returns the supported capabilities of this bootloader implementation
GetCapabilities() Capability
// Install will have this boot loader implementation install using the given boot
// configuration.
Install(mode Capability, c ConfigurationSource) error
// GetSpecialFile is to enable a private communication method between builder and
// loader to get well known file types, i.e. "boot.cat"
// These should *always* respect the relative path rules of the builders
GetSpecialFile(t FileType) string
}
A Loader provides abstraction around various bootloader implementations.
func GetLoaderWithMask ¶
func GetLoaderWithMask(loaders []Loader, mask Capability) Loader
GetLoaderWithMask will look in the set of loaders for the given mask. Note it will always return the *first* one found, i.e. the first one specified in the configuration
func InitLoaders ¶
func InitLoaders(c *config.ImageConfiguration, loaderType []config.LoaderType) ([]Loader, error)
InitLoaders will attempt to return an initialised set of loaders as a helper to other Builder implementations
type SyslinuxLoader ¶
type SyslinuxLoader struct {
// contains filtered or unexported fields
}
SyslinuxLoader wraps isolinux/syslinux into a single set of management routines
func NewSyslinuxLoader ¶
func NewSyslinuxLoader() *SyslinuxLoader
NewSyslinuxLoader will return a newly created SyslinuxLoader instance
func (*SyslinuxLoader) GetCapabilities ¶
func (s *SyslinuxLoader) GetCapabilities() Capability
GetCapabilities will return isolinux support only for syslinux right now
func (*SyslinuxLoader) GetSpecialFile ¶
func (s *SyslinuxLoader) GetSpecialFile(t FileType) string
GetSpecialFile will return the special paths for isolinux
func (*SyslinuxLoader) Init ¶
func (s *SyslinuxLoader) Init(c *config.ImageConfiguration) error
Init will attempt to initialise this loader if all host requirements are actually met.
func (*SyslinuxLoader) Install ¶
func (s *SyslinuxLoader) Install(op Capability, c ConfigurationSource) error
Install will do the real work of installing syslinux bootloader
func (*SyslinuxLoader) LocateAsset ¶
func (s *SyslinuxLoader) LocateAsset(name string) error
LocateAsset will attempt to find the given asset and then cache it