Documentation ¶
Overview ¶
Package build contains configuration structures and functions for building Fuchsia packages.
Package build contains configuration structures and functions for building Fuchsia packages.
Index ¶
- Variables
- func Archive(cfg *Config, outputPath string) error
- func BuildTestPackage(cfg *Config)
- func Init(cfg *Config) error
- func Seal(cfg *Config) (string, error)
- func TestPackage(cfg *Config)
- func Update(cfg *Config) error
- func Validate(cfg *Config) error
- type BlobInfo
- type Config
- func (c *Config) BlobInfo() ([]PackageBlobInfo, error)
- func (c *Config) InitFlags(fs *flag.FlagSet)
- func (c *Config) Manifest() (*Manifest, error)
- func (c *Config) MetaFAR() string
- func (c *Config) MetaFARMerkle() string
- func (c *Config) OutputManifest() (*PackageManifest, error)
- func (c *Config) Package() (pkg.Package, error)
- type DeltaBlobStats
- type DeltaPackageBlobStats
- type DeltaPackageStats
- type ErrInconsistentSnapshotBlobs
- type ErrInvalidMetaContentsLine
- type ErrRequiredFileMissing
- type Manifest
- type MerkleRoot
- type MetaContents
- type Package
- type PackageBlobInfo
- type PackageFileRef
- type PackageManifest
- type Snapshot
- type SnapshotDelta
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidMerkleRootLength = errors.New("decoded merkle root does not contain 32 bytes")
ErrInvalidMerkleRootLength indicates a MerkleRoot string did not contain 32 hex bytes
var RequiredFiles = []string{"meta/contents", "meta/package"}
RequiredFiles is a list of files that are required before a package can be sealed.
var TestFiles = []string{"a", "b", "dir/c", "rand1", "rand2", "meta/test/t"}
TestFiles is the list of files created by the default factories in this package.
Functions ¶
func BuildTestPackage ¶
func BuildTestPackage(cfg *Config)
func Init ¶
Init initializes package metadata in the output directory. A manifest is generated with a name matching the output directory name.
func TestPackage ¶
func TestPackage(cfg *Config)
TestPackage initializes a set of files into a package directory next to the config manifest
Types ¶
type BlobInfo ¶
type BlobInfo struct {
Size uint64 `json:"size"`
}
BlobInfo contains metadata about a single blob
type Config ¶
type Config struct { OutputDir string ManifestPath string KeyPath string TempDir string PkgName string PkgVersion string // contains filtered or unexported fields }
Config contains global build configuration for other build commands
func NewConfig ¶
func NewConfig() *Config
NewConfig initializes a new configuration with conventional defaults
func TestConfig ¶
func TestConfig() *Config
TestConfig produces a configuration suitable for testing. It creates a temporary directory as a parent of the returned config.OutputDir and config.TempDir. Callers should remove this directory.
func (*Config) BlobInfo ¶
func (c *Config) BlobInfo() ([]PackageBlobInfo, error)
func (*Config) Manifest ¶
Manifest initializes and returns the configured manifest. The manifest may be modified during the build process to add/remove files.
func (*Config) MetaFARMerkle ¶
MetaFARMerkle returns the path to the meta.far.merkle that build.Seal generates
func (*Config) OutputManifest ¶
func (c *Config) OutputManifest() (*PackageManifest, error)
type DeltaBlobStats ¶
type DeltaBlobStats struct { Merkle MerkleRoot `json:"merkle"` Size uint64 `json:"size"` References []PackageFileRef `json:"references"` }
DeltaBlobStats contains the size of a blob, its hash, and all paths to it from all packages.
type DeltaPackageBlobStats ¶
type DeltaPackageBlobStats struct { Merkle MerkleRoot `json:"merkle"` Size uint64 `json:"size"` Paths []string `json:"paths"` }
DeltaPackageBlobStats contains the size of a blob, its hash, and all paths to it within a particular package.
func (*DeltaPackageBlobStats) PathsDisplay ¶
func (d *DeltaPackageBlobStats) PathsDisplay() string
PathsDisplay produces a string representation of DeltaPackageBlobStats.Paths suitable for display.
type DeltaPackageStats ¶
type DeltaPackageStats struct { Name string `json:"name"` DownloadSize uint64 `json:"download_size"` DiscardSize uint64 `json:"discard_size"` UnchangedSize uint64 `json:"unchanged_size"` // AddedBlobs contains all blobs included in the target package that do // not exist in the source package, reverse sorted by blob size AddedBlobs []DeltaPackageBlobStats `json:"added_blobs"` }
DeltaPackageStats contains statistics for a package update
type ErrInconsistentSnapshotBlobs ¶
type ErrInconsistentSnapshotBlobs struct { Merkle MerkleRoot Source BlobInfo Target BlobInfo }
ErrInconsistentSnapshotBlobs indicates that two package snapshots contain blobs with the same hash but different metadata. This situation should require a hash collision and be nearly impossible to encounter.
func (ErrInconsistentSnapshotBlobs) Error ¶
func (e ErrInconsistentSnapshotBlobs) Error() string
Error generates a display string for ErrInconsistentSnapshotBlobs
type ErrInvalidMetaContentsLine ¶
type ErrInvalidMetaContentsLine struct {
Line string
}
ErrInvalidMetaContentsLine indicates that a line in a meta/contents file was not valid
func (ErrInvalidMetaContentsLine) Error ¶
func (e ErrInvalidMetaContentsLine) Error() string
type ErrRequiredFileMissing ¶
type ErrRequiredFileMissing struct {
Path string
}
ErrRequiredFileMissing is returned by operations when the operation depends on a file that was not found on disk.
func (ErrRequiredFileMissing) Error ¶
func (e ErrRequiredFileMissing) Error() string
type Manifest ¶
type Manifest struct { // Srcs is a set of manifests and/or directories that are the contents of the package Srcs []string // Paths is the fully computed contents of a package in the form of "destination": "source" Paths map[string]string }
Manifest describes the list of files that are to become the contents of a package
func NewManifest ¶
NewManifest initializes a manifest from the given paths. If a path is a directory, it is globbed and the manifest includes all unignored files under that directory. If the path is a manifest file, the file is parsed and all files are mapped as described by the manifest file. Manifest files contain lines with "destination=source". Lines that do not match this pattern are ignored.
func (*Manifest) Content ¶
Content returns the list of files from the manifest that are not to be included in the meta.far.
type MerkleRoot ¶
type MerkleRoot [32]byte
MerkleRoot is the root hash of a merkle tree
func DecodeMerkleRoot ¶
func DecodeMerkleRoot(text []byte) (MerkleRoot, error)
DecodeMerkleRoot attempts to parse a MerkleRoot from a string
func MustDecodeMerkleRoot ¶
func MustDecodeMerkleRoot(s string) MerkleRoot
MustDecodeMerkleRoot parses a MerkleRoot from a string, or panics
func (MerkleRoot) LessThan ¶
func (m MerkleRoot) LessThan(other MerkleRoot) bool
LessThan provides a sort ordering for MerkleRoot
func (MerkleRoot) MarshalText ¶
func (m MerkleRoot) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (MerkleRoot) String ¶
func (m MerkleRoot) String() string
String encodes a MerkleRoot as a lower case 32 byte hex string
func (*MerkleRoot) UnmarshalText ¶
func (m *MerkleRoot) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type MetaContents ¶
type MetaContents map[string]MerkleRoot
MetaContents maps file paths within a package to their content IDs
func LoadMetaContents ¶
func LoadMetaContents(path string) (MetaContents, error)
LoadMetaContents attempts to parse a meta/contents file from disk
func ParseMetaContents ¶
func ParseMetaContents(r io.Reader) (MetaContents, error)
ParseMetaContents attempts to parse a meta/contents file from an io.Reader
func (MetaContents) String ¶
func (m MetaContents) String() string
String serializes the instance in the manifest file format, which could be parsed by ParseMetaContents.
type Package ¶
type Package struct { Files map[string]MerkleRoot `json:"files"` Tags []string `json:"tags,omitempty"` }
Package contains metadata about a package, including a list of all files in the package
type PackageBlobInfo ¶
type PackageBlobInfo struct { // The path of the blob relative to the output directory SourcePath string `json:"source_path"` // The path within the package Path string `json:"path"` // Merkle root for the blob Merkle MerkleRoot `json:"merkle"` // Size of blob, in bytes Size uint64 `json:"size"` }
PackageBlobInfo contains metadata for a single blob in a package
func LoadBlobs ¶
func LoadBlobs(path string) ([]PackageBlobInfo, error)
LoadBlobs attempts to read and parse a blobs manifest from the given path
type PackageFileRef ¶
PackageFileRef is a tuple of a package name and a path within that package
func (PackageFileRef) String ¶
func (r PackageFileRef) String() string
type PackageManifest ¶
type PackageManifest struct { Version string `json:"version"` Package pkg.Package `json:"package"` Blobs []PackageBlobInfo `json:"blobs"` }
PackageManifest is the json structure representation of a full package manifest.
type Snapshot ¶
type Snapshot struct { Packages map[string]Package `json:"packages"` Blobs map[MerkleRoot]BlobInfo `json:"blobs"` }
Snapshot contains metadata from one or more packages
func LoadSnapshot ¶
LoadSnapshot reads and verifies a JSON formatted Snapshot from the provided path.
func ParseSnapshot ¶
ParseSnapshot deserializes and verifies a JSON formatted Snapshot from the provided data.
func (*Snapshot) AddPackage ¶
func (s *Snapshot) AddPackage(name string, blobs []PackageBlobInfo, tags []string) error
AddPackage adds the metadata for a single package to the given package snapshot, detecting and reporting any inconsistencies with the provided metadata.
func (*Snapshot) Filter ¶
Filter produces a subset of the Snapshot based on a series of include and exclude filters. In order for a package to be included in the result, its tags (including the package name itself) must match at least one include filter and must not match any exclude filters. Include and exclude filters may contain wildcard characters ("*"), which will match 0 or more characters.
type SnapshotDelta ¶
type SnapshotDelta struct { DownloadSize uint64 `json:"download_size"` DiscardSize uint64 `json:"discard_size"` UnchangedSize uint64 `json:"unchanged_size"` SourceSize uint64 `json:"source_size"` TargetSize uint64 `json:"target_size"` // AddedBlobs contains all blobs included in target that do not exist // in source, reverse sorted by blob size AddedBlobs []DeltaBlobStats `json:"added_blobs"` // Packages contains per-package update statistics, reverse sorted by // update size Packages []DeltaPackageStats `json:"packages"` }
SnapshotDelta contains update statistics from one Snapshot to another.
All slices within a snapshot are canonically ordered as follows: 1. Reverse sorted by download size/file size 2. Sorted alphabetically by path/name/merkle
func DeltaSnapshots ¶
func DeltaSnapshots(source Snapshot, target Snapshot) (SnapshotDelta, error)
DeltaSnapshots compares two Snapshots, producing various statistics about an update from source to target