uroot

package
Version: v0.0.0-...-ed07a65 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRamfs = cpio.ArchiveFromRecords([]cpio.Record{
	cpio.Directory("tcz", 0755),
	cpio.Directory("etc", 0755),
	cpio.Directory("dev", 0755),
	cpio.Directory("tmp", 0777),
	cpio.Directory("ubin", 0755),
	cpio.Directory("usr", 0755),
	cpio.Directory("usr/lib", 0755),
	cpio.Directory("var/log", 0777),
	cpio.Directory("lib64", 0755),
	cpio.Directory("bin", 0755),
	cpio.CharDev("dev/console", 0600, 5, 1),
	cpio.CharDev("dev/tty", 0666, 5, 0),
	cpio.CharDev("dev/null", 0666, 1, 3),
	cpio.CharDev("dev/port", 0640, 1, 4),
	cpio.CharDev("dev/urandom", 0666, 1, 9),
	cpio.StaticFile("etc/resolv.conf", nameserver, 0644),
	cpio.StaticFile("etc/localtime", gmt0, 0644),
})

DefaultRamfs are files that are contained in all u-root initramfs archives by default.

Functions

func CreateInitramfs

func CreateInitramfs(logger logger.Logger, opts Opts) error

CreateInitramfs creates an initramfs built to opts' specifications.

func ParseExtraFiles

func ParseExtraFiles(logger logger.Logger, archive *initramfs.Files, extraFiles []string, lddDeps bool) error

ParseExtraFiles adds files from the extraFiles list to the archive.

The following formats are allowed in the extraFiles list:

- "/home/chrisko/foo:root/bar" adds the file from absolute path
  /home/chrisko/foo on the host at the relative root/bar in the
  archive.
- "/home/foo" is equivalent to "/home/foo:home/foo".

ParseExtraFiles will also add ldd-listed dependencies if lddDeps is true.

func ResolvePackagePaths

func ResolvePackagePaths(logger logger.Logger, env golang.Environ, pkgs []string) ([]string, error)

ResolvePackagePaths takes a list of Go package import paths and directories and turns them into exclusively import paths.

Currently allowed formats:

- package imports; e.g. github.com/u-root/u-root/cmds/ls
- globs of package imports, e.g. github.com/u-root/u-root/cmds/*
- paths to package directories; e.g. $GOPATH/src/github.com/u-root/u-root/cmds/ls
- globs of paths to package directories; e.g. ./cmds/*

Directories may be relative or absolute, with or without globs. Globs are resolved using filepath.Glob.

Types

type Commands

type Commands struct {
	// Builder is the Go compiler mode.
	Builder builder.Builder

	// Packages are the Go commands to include (compiled or otherwise) and
	// add to the archive.
	//
	// Currently allowed formats:
	//
	//   - package imports; e.g. github.com/u-root/u-root/cmds/ls
	//   - globs of package imports; e.g. github.com/u-root/u-root/cmds/*
	//   - paths to package directories; e.g. $GOPATH/src/github.com/u-root/u-root/cmds/ls
	//   - globs of paths to package directories; e.g. ./cmds/*
	//
	// Directories may be relative or absolute, with or without globs.
	// Globs are resolved using filepath.Glob.
	Packages []string

	// BinaryDir is the directory in which the resulting binaries are
	// placed inside the initramfs.
	//
	// BinaryDir may be empty, in which case Builder.DefaultBinaryDir()
	// will be used.
	BinaryDir string
}

Commands specifies a list of Golang packages to build with a builder, e.g. in busybox mode, source mode, or binary mode.

See Builder for an explanation of build modes.

func BinaryCmds

func BinaryCmds(cmds ...string) []Commands

BinaryCmds returns a list of Commands with cmds built as a busybox.

func BusyBoxCmds

func BusyBoxCmds(cmds ...string) []Commands

BusyBoxCmds returns a list of Commands with cmds built as a busybox.

func (Commands) TargetDir

func (c Commands) TargetDir() string

TargetDir returns the initramfs binary directory for these Commands.

type Opts

type Opts struct {
	// Env is the Golang build environment (GOOS, GOARCH, etc).
	Env golang.Environ

	// Commands specify packages to build using a specific builder.
	//
	// E.g. the following will build 'ls' and 'ip' in busybox mode, but
	// 'cd' and 'cat' as separate binaries. 'cd', 'cat', 'bb', and symlinks
	// from 'ls' and 'ip' will be added to the final initramfs.
	//
	//   []Commands{
	//     Commands{
	//       Builder: builder.BusyBox,
	//       Packages: []string{
	//         "github.com/u-root/u-root/cmds/ls",
	//         "github.com/u-root/u-root/cmds/ip",
	//       },
	//     },
	//     Commands{
	//       Builder: builder.Binary,
	//       Packages: []string{
	//         "github.com/u-root/u-root/cmds/cd",
	//         "github.com/u-root/u-root/cmds/cat",
	//       },
	//     },
	//   }
	Commands []Commands

	// TempDir is a temporary directory for builders to store files in.
	TempDir 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, unless SkipLDD (below) is true.
	//
	// The following formats are allowed in the list:
	//
	//   - "/home/chrisko/foo:root/bar" adds the file from absolute path
	//     /home/chrisko/foo on the host at the relative root/bar in the
	//     archive.
	//   - "/home/foo" is equivalent to "/home/foo:home/foo".
	ExtraFiles []string

	// If true, do not use ldd to pick up dependencies from local machine for
	// ExtraFiles. Useful if you have all deps revision controlled and wish to
	// ensure builds are repeatable, and/or if the local machine's binaries use
	// instructions unavailable on the emulated cpu.
	//
	// If you turn this on but do not manually list all deps, affected binaries
	// will misbehave.
	SkipLDD bool

	// OutputFile is the archive output file.
	OutputFile initramfs.Writer

	// BaseArchive is an existing initramfs to include in the resulting
	// initramfs.
	BaseArchive initramfs.Reader

	// UseExistingInit determines whether the existing init from
	// BaseArchive should be used.
	//
	// If this is false, the "init" from BaseArchive will be renamed to
	// "inito" (init-original).
	UseExistingInit bool

	// InitCmd is the name of a command to link /init to.
	//
	// This can be an absolute path or the name of a command included in
	// Commands.
	//
	// If this is empty, no init symlink will be created.
	InitCmd string

	// DefaultShell is the default shell to start after init.
	//
	// This can be an absolute path or the name of a command included in
	// Commands.
	//
	// This must be specified to have a default shell.
	DefaultShell string
}

Opts are the arguments to CreateInitramfs.

Opts contains everything that influences initramfs creation such as the Go build environment.

func (*Opts) AddBusyBoxCommands

func (o *Opts) AddBusyBoxCommands(pkgs ...string)

func (*Opts) AddCommands

func (o *Opts) AddCommands(c ...Commands)

AddCommands adds commands to the build.

Source Files

Directories

Path Synopsis
test
foo
Package util contains various u-root utility functions.
Package util contains various u-root utility functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL