Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateInitramfs ¶
CreateInitramfs creates an initramfs built to `opts`' specifications.
Types ¶
type ArchiveFiles ¶
type ArchiveFiles struct { // Files is a map of relative archive path -> absolute host file path. Files map[string]string // Records is a map of relative archive path -> Record to use. // // TODO: While the only archive mode is cpio, this will be a // cpio.Record. If or when there is another archival mode, we can add a // similar uroot.Record type. Records map[string]cpio.Record }
ArchiveFiles are host files and records to add to
func BBBuild ¶
func BBBuild(opts BuildOpts) (ArchiveFiles, error)
BBBuild is an implementation of Build for the busybox-like u-root initramfs.
BBBuild rewrites the source files of the packages given to create one busybox-like binary containing all commands in `opts.Packages`.
func NewArchiveFiles ¶
func NewArchiveFiles() ArchiveFiles
NewArchiveFiles returns a new archive files map.
func SourceBuild ¶
func SourceBuild(opts BuildOpts) (ArchiveFiles, error)
SourceBuild is an implementation of Build that compiles the Go toolchain (go, compile, link, asm) and an init process. It includes source files for packages listed in `opts.Packages` to build from scratch.
func (ArchiveFiles) AddFile ¶
func (af ArchiveFiles) AddFile(src string, dest string) error
AddFile adds a host file at `src` into the archive at `dest`.
func (ArchiveFiles) AddRecord ¶
func (af ArchiveFiles) AddRecord(r cpio.Record) error
AddRecord adds a cpio.Record into the archive at `r.Name`.
func (ArchiveFiles) Contains ¶
func (af ArchiveFiles) Contains(dest string) bool
Contains returns whether path `dest` is already contained in the archive.
func (ArchiveFiles) SortedKeys ¶
func (af ArchiveFiles) SortedKeys() []string
SortedKeys returns a list of sorted paths in the archive.
type ArchiveOpts ¶
type ArchiveOpts struct { // ArchiveFiles are the files to be included. ArchiveFiles // TempDir is a temporary directory that can be used at the archiver's // discretion. // // TempDir should contain no files. TempDir string // OutputFile is the file to write to. OutputFile *os.File // BaseArchive is an existing archive to add files to. // // BaseArchive may be nil. BaseArchive *os.File // UseExistingInit determines whether the init from BaseArchive is used // or not, if BaseArchive is specified. // // If this is false, the "init" file in BaseArchive will be renamed // "inito" in the output archive. UseExistingInit bool }
ArchiveOpts are the options for building the initramfs archive.
type Archiver ¶
type Archiver interface { // Archive builds an archive file. Archive(ArchiveOpts) error // DefaultExtension is the default file extension of the archive format. DefaultExtension() string }
Archiver is an archive format that builds an archive using a given set of files.
func GetArchiver ¶
GetArchiver returns the archive mode for the named archive.
type Build ¶
type Build func(BuildOpts) (ArchiveFiles, error)
Build uses the given options to build Go packages and returns a list of files to be included in an initramfs archive.
func GetBuilder ¶
GetBuilder returns the Build function for the named build mode.
type BuildOpts ¶
type BuildOpts struct { // Env is the Go environment to use to compile and link packages. Env golang.Environ // Packages are the Go package import paths to compile. // // Builders need not support resolving packages by path. // // E.g. cmd/go or github.com/u-root/u-root/cmds/ls. Packages []string // TempDir is a temporary directory where the compilation mode compiled // binaries can be placed. // // TempDir should contain no files. TempDir string }
BuildOpts are arguments to the Build function.
type CPIOArchiver ¶
type CPIOArchiver struct { // Format is the name of the cpio format to use. Format string }
CPIOArchiver is an implementation of Archiver for the cpio format.
func (CPIOArchiver) Archive ¶
func (ca CPIOArchiver) Archive(opts ArchiveOpts) error
Archive implements Archiver.Archive.
func (CPIOArchiver) DefaultExtension ¶
func (ca CPIOArchiver) DefaultExtension() string
DefaultExtension implements Archiver.DefaultExtension.
type CommandTemplate ¶
type Opts ¶
type Opts struct { // Env is the build environment (OS, arch, etc). Env golang.Environ // Builder is the build format. // // This can currently be "source" or "bb". Builder Build // Archiver is the initramfs archival format. // // Only "cpio" is currently supported. Archiver Archiver // Packages are the Go packages to add to the archive. // // Currently allowed formats: // Go package imports; e.g. github.com/u-root/u-root/cmds/ls // Paths to Go package directories; e.g. $GOPATH/src/github.com/u-root/u-root/cmds/ls // Globs of paths to Go package directories; e.g. ./cmds/* Packages []string // ExtraFiles are files to add to the archive in addition to the Go // packages. // // Shared library dependencies will automatically also be added to the // archive using ldd. ExtraFiles []string // TempDir is a temporary directory for the builder to store files in. TempDir string // OutputFile is the archive output file. OutputFile *os.File // BaseArchive is an existing initramfs to include in the resulting // initramfs. BaseArchive *os.File // UseExistingInit determines whether the existing init from // BaseArchive should be used. // // If this is false, the "init" from BaseArchive will be renamed to // "inito". UseExistingInit bool }
Opts are the arguments to CreateInitramfs.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
func (*Package) CommandTemplate ¶
func (p *Package) CommandTemplate() CommandTemplate