boot

package
v0.0.0-...-7c0940c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package boot provides implementations to help manage the bootloader setup and installation on various medium types.

Index

Constants

This section is empty.

Variables

View Source
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",
	}
)
View Source
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")
)
View Source
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",
	}
)
View Source
var (
	// DefaultIsolinuxTemplate is the built-in template for isolinux.cfg
	DefaultIsolinuxTemplate = `` /* 1031-byte string literal not displayed */

)
View Source
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

func NewDracut

func NewDracut(k *Kernel) *Dracut

NewDracut returns a new Dracut object for generation

func (*Dracut) Exec

func (d *Dracut) Exec(path string) error

Exec will build the command run dracut within the chroot

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

func GetKernelFromRoot(root string) (*Kernel, error)

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

func NewLoader

func NewLoader(impl config.LoaderType) (Loader, error)

NewLoader will create a new Loader instance for the given name, if supported

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

Init will attempt to initialise this loader if all host requirements are actually met.

func (*SyslinuxLoader) Install

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL