Documentation ¶
Index ¶
- Variables
- func Write(opts *Opts) error
- type Archiver
- type CPIOArchiver
- type DirArchiver
- type Files
- func (af *Files) AddFile(src string, dest string) error
- func (af *Files) AddFileNoFollow(src string, dest string) error
- func (af *Files) AddRecord(r cpio.Record) error
- func (af *Files) Contains(dest string) bool
- func (af *Files) Rename(name string, newname string)
- func (af *Files) WriteTo(w Writer) error
- type Opts
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( CPIO = CPIOArchiver{ RecordFormat: cpio.Newc, } Dir = DirArchiver{} // Archivers are the supported initramfs archivers at the moment. // // - cpio: writes the initramfs to a cpio. // - dir: writes the initramfs relative to a specified directory. Archivers = map[string]Archiver{ "cpio": CPIO, "dir": Dir, } )
Functions ¶
Types ¶
type Archiver ¶
type Archiver interface { // OpenWriter opens an archive writer at `path`. // // If `path` is unspecified, implementations may choose an arbitrary // default location, potentially based on `goos` and `goarch`. OpenWriter(l logger.Logger, path, goos, goarch string) (Writer, error) // Reader returns a Reader that allows reading files from a file. Reader(file io.ReaderAt) Reader }
Archiver is an archive format that builds an archive using a given set of files.
func GetArchiver ¶
GetArchiver finds a registered initramfs archiver by name.
Good to use with command-line arguments.
type CPIOArchiver ¶
type CPIOArchiver struct {
cpio.RecordFormat
}
CPIOArchiver is an implementation of Archiver for the cpio format.
func (CPIOArchiver) OpenWriter ¶
OpenWriter opens `path` as the correct file type and returns an Writer pointing to `path`.
If `path` is empty, a default path of /tmp/initramfs.GOOS_GOARCH.cpio is used.
type DirArchiver ¶
type DirArchiver struct{}
DirArchiver implements Archiver for a directory.
func (DirArchiver) OpenWriter ¶
OpenWriter implements Archiver.OpenWriter.
type Files ¶
type Files 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 }
Files are host files and records to add to the resulting initramfs.
func (*Files) AddFile ¶
AddFile adds a host file at src into the archive at dest. It follows symlinks.
If src is a directory, it and its children will be added to the archive relative to dest.
Duplicate files with identical content will be silently ignored.
func (*Files) AddFileNoFollow ¶
AddFileNoFollow adds a host file at src into the archive at dest. It does not follow symlinks.
If src is a directory, it and its children will be added to the archive relative to dest.
Duplicate files with identical content will be silently ignored.
type Opts ¶
type Opts struct { // Files are the files to be included. // // Files here generally have priority over files in DefaultRecords or // BaseArchive. *Files // OutputFile is the file to write to. OutputFile Writer // BaseArchive is an existing archive to add files to. // // BaseArchive may be nil. BaseArchive Reader // 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" (for init-original) in the output archive. UseExistingInit bool }
Opts are options for building an initramfs archive.
type Writer ¶
type Writer interface { cpio.RecordWriter // Finish finishes the archive. Finish() error }
Writer is an initramfs archive that files can be written to.