Documentation
¶
Overview ¶
Package recipes / config
Package recipes / coreboot
Package recipes / edk2
Package recipes / linux
Package recipes yay!
Package recipes / stitching
Package recipes / universal
Package recipes / uroot
Index ¶
- Variables
- func Execute(ctx context.Context, target string, config *Config, interactive bool) error
- func ExtractSizeFromString(text string) ([]uint64, error)
- func FindAllEnvVars(text string) []string
- func IsDirEmpty(path string) (bool, error)
- func JSONVerboseError(jsonString string, err error)
- func NormalizeArchitecture(arch string) string
- func NormalizeArchitectureForLinux(arch string) string
- func StringToSizeMB(text string) (uint64, error)
- func ValidateConfig(conf Config) error
- func WriteConfig(filepath string, config *Config) error
- type BlobDef
- type BuildResults
- type CommonOpts
- type Config
- type CorebootBlobs
- type CorebootOpts
- type Edk2Opts
- type Edk2Specific
- type FirmwareModule
- type FirmwareStitchingOpts
- type IfdtoolEntry
- type LinuxOpts
- type LinuxSpecific
- type URootOpts
- type URootSpecific
- type UniversalOpts
- type UniversalSpecific
Constants ¶
This section is empty.
Variables ¶
var ( // ErrVerboseJSON is raised when JSONVerboseError can't find location of problem in JSON configuration file ErrVerboseJSON = errors.New("unable to pinpoint the problem in JSON file") // ErrEnvVarUndefined is raised when undefined environment variable is found in JSON configuration file ErrEnvVarUndefined = errors.New("environment variable used in JSON file is not present in the environment") )
var ( ErrBuildFailed = errors.New("build failed") ErrBuildUpToDate = errors.New("build is up-to-date") ErrDependencyTreeUndefDep = errors.New("module has invalid dependency") ErrDependencyTreeUnderTarget = errors.New("target not found in dependency tree") ErrDependencyOutputMissing = errors.New("output of one or more dependencies is missing") ErrFailedValidation = errors.New("config failed validation") ErrTargetInvalid = errors.New("unsupported target") ErrTargetMissing = errors.New("no target specified") )
Errors for recipes
var ( // ContainerWorkDir specifies directory in container used as work directory ContainerWorkDir = "/workdir" // TimestampsDir specifies directory for timestamps to detect changes in sources TimestampsDir = ".firmware-action/timestamps" )
Functions ¶
func Execute ¶
Execute a build step func Execute(ctx context.Context, target string, config *Config, interactive bool, bulldozeMode bool) error {
func ExtractSizeFromString ¶
ExtractSizeFromString uses regex to find size of ROM in MB
func FindAllEnvVars ¶
FindAllEnvVars returns all environment variables found in the provided string
func IsDirEmpty ¶
IsDirEmpty returns whether given directory is empty or not
func JSONVerboseError ¶
JSONVerboseError is for getting more information out of json.Unmarshal() or Decoder.Decode()
Inspiration: - https://adrianhesketh.com/2017/03/18/getting-line-and-character-positions-from-gos-json-unmarshal-errors/ Docs: - https://pkg.go.dev/encoding/json#Unmarshal
func NormalizeArchitecture ¶
NormalizeArchitecture will translate various architecture strings into expected format
func NormalizeArchitectureForLinux ¶
NormalizeArchitectureForLinux will translate various architecture strings into format expected by Linux
func StringToSizeMB ¶
StringToSizeMB parses string and returns size in MB
func ValidateConfig ¶
ValidateConfig is used to validate the configuration struct read out of JSON file
func WriteConfig ¶
WriteConfig is for writing Config struct into JSON configuration file
Types ¶
type BlobDef ¶
type BlobDef struct {
// Path to the blob (either file or directory)
Path string `validate:"required"`
// Blobs get renamed when moved to this string
DestinationFilename string `validate:"required"`
// Kconfig key specifying the filepath to the blob in defconfig
KconfigKey string `validate:"required"`
// Is blob a directory? If blob is file, set to FALSE
IsDirectory bool `validate:"required,boolean"`
}
BlobDef is used to store information about a single blob. This structure is not exposed to the user, it is filled in automatically based on user input.
type BuildResults ¶
BuildResults contains target name and result of its build
type CommonOpts ¶
type CommonOpts struct {
// Specifies the container toolchain tag to use when building the image.
// This has an influence on the IASL, GCC and host GCC version that is used to build
// the target. You must match the source level and sdk_version.
// NOTE: Updating the sdk_version might result in different binaries using the
// same source code.
// Examples:
// https://ghcr.io/9elements/firmware-action/coreboot_4.19:main
// https://ghcr.io/9elements/firmware-action/coreboot_4.19:latest
// https://ghcr.io/9elements/firmware-action/edk2-stable202111:latest
// See https://github.com/orgs/9elements/packages
SdkURL string `json:"sdk_url" validate:"required"`
// Gives the (relative) path to the target (firmware) repository.
// If the current repository contains the selected target, specify: '.'
// Otherwise the path should point to the target (firmware) repository submodule that
// had been previously checked out.
RepoPath string `json:"repo_path" validate:"required,dirpath"`
// Specifies the (relative) paths to directories where are produced files (inside Container).
ContainerOutputDirs []string `json:"container_output_dirs" validate:"dive,dirpath"`
// Specifies the (relative) paths to produced files (inside Container).
ContainerOutputFiles []string `json:"container_output_files" validate:"dive,filepath"`
// Specifies the (relative) path to directory into which place the produced files.
// Directories listed in ContainerOutputDirs and files listed in ContainerOutputFiles
// will be exported here.
// Example:
// Following setting:
// ContainerOutputDirs = []string{"Build/"}
// ContainerOutputFiles = []string{"coreboot.rom", "defconfig"}
// OutputDir = "myOutput"
// Will result in following structure being copied out of the container:
// myOutput/
// ├── Build/
// ├── coreboot.rom
// └── defconfig
OutputDir string `json:"output_dir" validate:"required,dirpath"`
// Specifies the (relative) paths to directories which should be copied into the container.
InputDirs []string `json:"input_dirs" validate:"dive,dirpath"`
// Specifies the (relative) paths to file which should be copied into the container.
InputFiles []string `json:"input_files" validate:"dive,filepath"`
// Specifies the path to directory where to place input files and directories inside container.
// Directories listed in ContainerInputDirs and files listed in ContainerInputFiles
// will be copied there.
// Example:
// Following setting:
// InputDirs = []string{"config-files/"}
// InputFiles = []string{"README.md", "Taskfile.yml"}
// ContainerInputDir = "myInput"
// Will result in following structure being copied into the container:
// myInput/
// ├── config-files/
// ├── README.md
// └── Taskfile.yml
ContainerInputDir string `json:"container_input_dir" validate:"dirpath"`
}
CommonOpts is common to all targets Used to store data from githubaction.Action For details see action.yml ANCHOR: CommonOpts
func (CommonOpts) GetArtifacts ¶
func (opts CommonOpts) GetArtifacts() *[]container.Artifacts
GetArtifacts returns list of wanted artifacts from container
func (CommonOpts) GetContainerOutputDirs ¶
func (opts CommonOpts) GetContainerOutputDirs() []string
GetContainerOutputDirs returns list of output directories
func (CommonOpts) GetContainerOutputFiles ¶
func (opts CommonOpts) GetContainerOutputFiles() []string
GetContainerOutputFiles returns list of output directories
func (CommonOpts) GetOutputDir ¶
func (opts CommonOpts) GetOutputDir() string
GetOutputDir returns output directory
func (CommonOpts) GetSources ¶
func (opts CommonOpts) GetSources() []string
GetSources returns slice of paths to all sources which are used for build
type Config ¶
type Config struct {
// defined in coreboot.go
Coreboot map[string]CorebootOpts `json:"coreboot" validate:"dive"`
// defined in linux.go
Linux map[string]LinuxOpts `json:"linux" validate:"dive"`
// defined in edk2.go
Edk2 map[string]Edk2Opts `json:"edk2" validate:"dive"`
// defined in stitching.go
FirmwareStitching map[string]FirmwareStitchingOpts `json:"firmware_stitching" validate:"dive"`
// defined in uroot.go
URoot map[string]URootOpts `json:"u-root" validate:"dive"`
// defined in universal.go
Universal map[string]UniversalOpts `json:"universal" validate:"dive"`
}
Config is for storing parsed configuration file
func ReadConfig ¶
ReadConfig is for reading and parsing JSON configuration file into Config struct
func (Config) AllModules ¶
func (c Config) AllModules() map[string]FirmwareModule
AllModules method returns slice with all modules
type CorebootBlobs ¶
type CorebootBlobs struct {
// ** List of supported blobs **
// NOTE: The blobs may not be added to the ROM, depends on provided defconfig.
//
// Gives the (relative) path to the payload.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(MAINBOARDDIR)/payload`.
// The Kconfig `CONFIG_PAYLOAD_FILE` will be changed to point to the same path.
PayloadFilePath string `json:"payload_file_path" type:"blob"`
// Gives the (relative) path to the Intel Flash descriptor binary.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/descriptor.bin`.
// The Kconfig `CONFIG_IFD_BIN_PATH` will be changed to point to the same path.
IntelIfdPath string `json:"intel_ifd_path" type:"blob"`
// Gives the (relative) path to the Intel Management engine binary.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/me.bin`.
// The Kconfig `CONFIG_ME_BIN_PATH` will be changed to point to the same path.
IntelMePath string `json:"intel_me_path" type:"blob"`
// Gives the (relative) path to the Intel Gigabit Ethernet engine binary.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/gbe.bin`.
// The Kconfig `CONFIG_GBE_BIN_PATH` will be changed to point to the same path.
IntelGbePath string `json:"intel_gbe_path" type:"blob"`
// Gives the (relative) path to the Intel 10 Gigabit Ethernet engine binary.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/10gbe0.bin`.
// The Kconfig `CONFIG_10GBE_0_BIN_PATH` will be changed to point to the same path.
Intel10Gbe0Path string `json:"intel_10gbe0_path" type:"blob"`
// Gives the (relative) path to the Intel FSP binary.
// In a 'coreboot' build, the file will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/Fsp.fd`.
// The Kconfig `CONFIG_FSP_FD_PATH` will be changed to point to the same path.
FspBinaryPath string `json:"fsp_binary_path" type:"blob"`
// Gives the (relative) path to the Intel FSP header folder.
// In a 'coreboot' build, the files will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/Include`.
// The Kconfig `CONFIG_FSP_HEADER_PATH` will be changed to point to the same path.
FspHeaderPath string `json:"fsp_header_path" type:"blob"`
// Gives the (relative) path to the Video BIOS Table binary.
// In a 'coreboot' build, the files will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/vbt.bin`.
// The Kconfig `CONFIG_INTEL_GMA_VBT_FILE` will be changed to point to the same path.
VbtPath string `json:"vbt_path" type:"blob"`
// Gives the (relative) path to the Embedded Controller binary.
// In a 'coreboot' build, the files will be placed at
// `3rdparty/blobs/mainboard/$(CONFIG_MAINBOARD_DIR)/ec.bin`.
// The Kconfig `CONFIG_EC_BIN_PATH` will be changed to point to the same path.
EcPath string `json:"ec_path" type:"blob"`
}
CorebootBlobs is used to store data specific to coreboot.
type CorebootOpts ¶
type CorebootOpts struct {
// List of IDs this instance depends on
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// Gives the (relative) path to the defconfig that should be used to build the target.
DefconfigPath string `json:"defconfig_path" validate:"required,filepath"`
// Coreboot specific options
Blobs CorebootBlobs `json:"blobs"`
}
CorebootOpts is used to store all data needed to build coreboot.
func (CorebootOpts) GetArtifacts ¶
func (opts CorebootOpts) GetArtifacts() *[]container.Artifacts
GetArtifacts returns list of wanted artifacts from container
func (CorebootOpts) GetDepends ¶
func (opts CorebootOpts) GetDepends() []string
GetDepends is used to return list of dependencies
func (CorebootOpts) GetSources ¶
func (opts CorebootOpts) GetSources() []string
GetSources returns slice of paths to all sources which are used for build
type Edk2Opts ¶
type Edk2Opts struct {
// List of IDs this instance depends on
// Example: [ "MyLittleCoreboot", "MyLittleLinux"]
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// Specifies target architecture, such as 'x86' or 'arm64'. Currently unused for coreboot.
// Supported options:
// - 'AARCH64'
// - 'ARM'
// - 'IA32'
// - 'IA32X64'
// - 'X64'
Arch string `json:"arch"`
// Gives the (relative) path to the defconfig that should be used to build the target.
// For EDK2 this is a one-line file containing the build arguments such as
// '-D BOOTLOADER=COREBOOT -D TPM_ENABLE=TRUE -D NETWORK_IPXE=TRUE'.
DefconfigPath string `json:"defconfig_path" validate:"filepath"`
// Coreboot specific options
Edk2Specific `validate:"required"`
}
Edk2Opts is used to store all data needed to build edk2.
func (Edk2Opts) GetArtifacts ¶
GetArtifacts returns list of wanted artifacts from container
func (Edk2Opts) GetDepends ¶
GetDepends is used to return list of dependencies
type Edk2Specific ¶
type Edk2Specific struct {
// Specifies which build command to use
// GCC version is exposed in the container container as USE_GCC_VERSION environment variable
// Examples:
// "source ./edksetup.sh; build -t GCC5 -a IA32 -p UefiPayloadPkg/UefiPayloadPkg.dsc"
// "python UefiPayloadPkg/UniversalPayloadBuild.py"
// "Intel/AlderLakeFspPkg/BuildFv.sh"
BuildCommand string `json:"build_command" validate:"required"`
}
Edk2Specific is used to store data specific to coreboot.
simplified because of issue #92
type FirmwareModule ¶
type FirmwareModule interface {
GetDepends() []string
GetArtifacts() *[]container.Artifacts
GetContainerOutputDirs() []string
GetContainerOutputFiles() []string
GetOutputDir() string
GetSources() []string
// contains filtered or unexported methods
}
FirmwareModule interface
type FirmwareStitchingOpts ¶
type FirmwareStitchingOpts struct {
// List of IDs this instance depends on
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// BaseFile into which inject files.
// !!! Must contain IFD !!!
// Examples:
// - coreboot.rom
// - ifd.bin
BaseFilePath string `json:"base_file_path" validate:"required,filepath"`
// Platform - passed to all `ifdtool` calls with `--platform`
Platform string `json:"platform"`
// List of instructions for ifdtool
IfdtoolEntries []IfdtoolEntry `json:"ifdtool_entries"`
}
FirmwareStitchingOpts is used to store all data needed to stitch firmware
func (FirmwareStitchingOpts) GetArtifacts ¶
func (opts FirmwareStitchingOpts) GetArtifacts() *[]container.Artifacts
GetArtifacts returns list of wanted artifacts from container
func (FirmwareStitchingOpts) GetDepends ¶
func (opts FirmwareStitchingOpts) GetDepends() []string
GetDepends is used to return list of dependencies
type IfdtoolEntry ¶
type IfdtoolEntry struct {
// Gives the (relative) path to the binary blob
Path string `json:"path" validate:"required,filepath"`
// Region where to inject the file
// For supported options see `ifdtool --help`
TargetRegion string `json:"target_region" validate:"required"`
// Additional (optional) arguments and flags
// For example:
// `--platform adl`
// For supported options see `ifdtool --help`
OptionalArguments []string `json:"optional_arguments"`
// Ignore entry if the file is missing
IgnoreIfMissing bool `json:"ignore_if_missing" type:"boolean"`
// For internal use only - whether or not the blob should be injected
// Firstly it is checked if the blob file exists, if not a if `IgnoreIfMissing` is set to `true`,
// then `Skip` is set to `true` to remove need for additional repetitive checks later in program
Skip bool
}
IfdtoolEntry is for injecting a file at `path` into region `TargetRegion`
type LinuxOpts ¶
type LinuxOpts struct {
// List of IDs this instance depends on
// Example: [ "MyLittleCoreboot", "MyLittleEdk2"]
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// Specifies target architecture, such as 'x86' or 'arm64'.
// Supported options:
// - 'i386'
// - 'amd64'
// - 'arm'
// - 'arm64'
Arch string `json:"arch"`
// Gives the (relative) path to the defconfig that should be used to build the target.
DefconfigPath string `json:"defconfig_path" validate:"required,filepath"`
// Linux specific options
LinuxSpecific
}
LinuxOpts is used to store all data needed to build linux
func (LinuxOpts) GetArtifacts ¶
GetArtifacts returns list of wanted artifacts from container
func (LinuxOpts) GetDepends ¶
GetDepends is used to return list of dependencies
type LinuxSpecific ¶
type LinuxSpecific struct {
// TODO: either use or remove
GccVersion string `json:"gcc_version"`
}
LinuxSpecific is used to store data specific to linux
type URootOpts ¶
type URootOpts struct {
// List of IDs this instance depends on
// Example: [ "MyLittleCoreboot", "MyLittleEdk2"]
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// u-root specific options
URootSpecific
}
URootOpts is used to store all data needed to build u-root
func (URootOpts) GetArtifacts ¶
GetArtifacts returns list of wanted artifacts from container
func (URootOpts) GetDepends ¶
GetDepends is used to return list of dependencies
type URootSpecific ¶
type URootSpecific struct {
// Specifies build command to use
BuildCommand string `json:"build_command" validate:"required"`
}
URootSpecific is used to store data specific to u-root ANCHOR: URootSpecific
type UniversalOpts ¶
type UniversalOpts struct {
// List of IDs this instance depends on
// Example: [ "MyLittleCoreboot", "MyLittleEdk2"]
Depends []string `json:"depends"`
// Common options like paths etc.
CommonOpts
// Universal specific options
UniversalSpecific
}
UniversalOpts is used to store all data needed to run universal commands
func (UniversalOpts) GetArtifacts ¶
func (opts UniversalOpts) GetArtifacts() *[]container.Artifacts
GetArtifacts returns list of wanted artifacts from container
func (UniversalOpts) GetDepends ¶
func (opts UniversalOpts) GetDepends() []string
GetDepends is used to return list of dependencies
type UniversalSpecific ¶
type UniversalSpecific struct {
// Specifies build commands to execute inside container
BuildCommands []string `json:"build_commands" validate:"required"`
}
UniversalSpecific is used to store data specific to the universal command module ANCHOR: UniversalSpecific