grub

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 16 Imported by: 10

Documentation

Overview

Package grub implements a grub config file parser.

See the grub manual https://www.gnu.org/software/grub/manual/grub/ for a reference of the configuration format In particular the following pages: - https://www.gnu.org/software/grub/manual/grub/html_node/Shell_002dlike-scripting.html - https://www.gnu.org/software/grub/manual/grub/html_node/Commands.html

Currently, only the linux[16|efi], initrd[16|efi], menuentry and set directives are partially supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseConfigFile

func ParseConfigFile(ctx context.Context, s curl.Schemes, configFile string, wd *url.URL) ([]boot.OSImage, error)

ParseConfigFile parses a grub configuration as specified in https://www.gnu.org/software/grub/manual/grub/

Currently, only the linux[16|efi], initrd[16|efi], menuentry and set directives are partially supported.

`wd` is the default scheme, host, and path for any files named as a relative path - e.g. kernel, include, and initramfs paths are requested relative to the wd.

func ParseLocalConfig

func ParseLocalConfig(ctx context.Context, diskDir string) ([]boot.OSImage, error)

ParseLocalConfig looks for a GRUB config in the disk partition mounted at diskDir and parses out OSes to boot.

This... is at best crude, at worst totally wrong, since we fundamentally assume that the kernels we boot are only on this one partition. But so is this whole parser.

Types

type EnvFile

type EnvFile struct {
	Vars map[string]string
}

EnvFile is a GRUB environment file consisting of key-value pairs akin to the GRUB commands load_env and save_env.

func NewEnvFile

func NewEnvFile() *EnvFile

NewEnvFile allocates a new env file.

func ParseEnvFile

func ParseEnvFile(r io.Reader) (*EnvFile, error)

ParseEnvFile reads a key-value pair GRUB environment file.

ParseEnvFile accepts incorrectly padded GRUB env files, as opposed to GRUB.

func (*EnvFile) WriteTo

func (env *EnvFile) WriteTo(w io.Writer) (int64, error)

WriteTo writes key-value pairs to a file, padded to 1024 bytes, as save_env does.

Jump to

Keyboard shortcuts

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