build

package
v0.0.0-...-531a4e7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(pkg *pkgen.PackageGenerator, opts Options) (err error)

Build builds a package.

func BuildDepsDocker

func BuildDepsDocker(pkg *pkgen.PackageGenerator, deps DependencyFinder, img Image) ([]string, error)

BuildDepsDocker finds build deps not provided by docker.

func Graph

func Graph(rpi RawPackageIndex, opts GraphOptions) (*xgraph.Graph, error)

Graph creates a *xgraph.Graph for mass-building packages. A meta-rule called "all" is created, which depends on all package rules.

func HashPackage

func HashPackage(ctx context.Context, pkg *pkgen.PackageGenerator, loader pkgen.Loader, hc *HashCache, docker Image, deps DependencyFinder) (hashhh [sha256.Size]byte, err error)

HashPackage hashes the inputs of a package.

Types

type BuildCache

type BuildCache interface {
	// Valid checks if the given build Info matches the cache entry.
	Valid(Info) (bool, error)

	// Update updates the cache with the given build Info.
	Update(Info) error
}

BuildCache is an interface used to cache builds.

func DirJSONCache

func DirJSONCache(dir string) BuildCache

DirJSONCache creates a BuildCache storing JSON blobs in the dir.

type DepWalker

type DepWalker func(string) ([]string, error)

DepWalker is a function to walk a package dependency tree.

func (DepWalker) Walk

func (dw DepWalker) Walk(pkgs ...string) ([]string, error)

Walk walks the dependency tree.

type DependencyFinder

type DependencyFinder interface {
	FindDependencies(...string) ([]string, error)
}

DependencyFinder is an interface used to find dependencies of packages recursively. Implemented by RawPackageIndex.

type ErrPkgNotFound

type ErrPkgNotFound struct {
	PkgName string
}

ErrPkgNotFound is an error type indicating that the specified package was not found.

func (ErrPkgNotFound) Error

func (err ErrPkgNotFound) Error() string

func (ErrPkgNotFound) String

func (err ErrPkgNotFound) String() string

type GraphOptions

type GraphOptions struct {
	// Options contains the base options for the graph.
	Options

	// HashCache is the HashCache used for the build.
	// Optional - will be populated if left empty.
	HashCache *HashCache

	// Cache is the BuildCache to use to implement incremental builds.
	Cache BuildCache

	// Logger is a logging mechanism to use for build jobs.
	Logger buildlog.Logger

	// Arch is the arch to build on.
	Arch pkgen.Arch

	// SourceTree is a vfs used to store the rootfs.
	SourceTree vfs.FileSystem
	// contains filtered or unexported fields
}

GraphOptions is a set of options for a build graph.

type HashCache

type HashCache struct {
	// contains filtered or unexported fields
}

HashCache is a cache of hashes

func (*HashCache) Clean

func (hc *HashCache) Clean()

Clean prepares the HashCache for reuse. Any cache entries not used since the last call to Clean will be deleted. In addition, all entries will be timestamp-validated on their next use.

func (*HashCache) PackageHash

func (hc *HashCache) PackageHash(name string, arch pkgen.Arch) (hash [sha256.Size]byte, err error)

PackageHash hashes the corresponding package file. Cache entries will not be revalidated until the next call to Clean. After a call to Clean, a cache entry may be revalidated via timestamp. Timestamp caching is only available if the PackageRetriever returns a *os.File.

type Image

type Image struct {
	// Image is a docker image to use.
	Image string `json:"image"`

	// Packages are the packages included in the image.
	Packages []string `json:"packages"`
}

Image is a container image usable for building.

type Info

type Info struct {
	// PackageName is the name of the package being built.
	PackageName string `json:"name"`

	// Arch is the arch for which the build is being run.
	Arch pkgen.Arch `json:"arch"`

	// Hash is the SHA256 hash of the build inputs.
	Hash [sha256.Size]byte `json:"hash"`
}

Info is a struct containing identifying information for the build.

type Options

type Options struct {
	// Docker is the docker client to use.
	// Optional: if nil, attempts to create a docker client from the environment.
	Docker *client.Client

	// DockerImage is the docker image to use.
	DockerImage Image

	// Output is the OutputHandler to store the output to.
	Output OutputHandler

	// Packages is the PackageRetriever to use to fetch dependencies.
	Packages PackageRetriever

	// Dependencies is the DependencyFinder to use to search for dependencies.
	Dependencies DependencyFinder

	// Loader is a source loader for the build.
	// Must include the file:// loader for Build.
	// This loader should not have a file:// loader for BuildGraph.
	// This loader must implement buffering of variable-length data.
	Loader pkgen.Loader

	// Log is the log handler to use.
	// This field is ignored by BuildGraph.
	// If nil, defaults to buildlog.DefaultHandler.
	Log buildlog.Handler

	// Ctx is the context to use for the build.
	// If nil, defaults to context.Background()
	Ctx context.Context
	// contains filtered or unexported fields
}

Options are the options for a build operation.

type OutputHandler

type OutputHandler interface {
	// Store stores the output of a build to an external location.
	// The body is in tar format, containing the packages with path in relative format (./example.tar.gz).
	Store(name string, arch pkgen.Arch, body io.Reader) error
}

OutputHandler is an interface to handle the output of builds.

type PackageRetriever

type PackageRetriever interface {
	// GetPkg gets a package with the given name and arch in tar format.
	// Also must return length of stream.
	GetPkg(name string, arch pkgen.Arch) (io.ReadCloser, int64, error)
}

PackageRetriever is an interface to load packages.

type PackageStore

type PackageStore interface {
	OutputHandler
	PackageRetriever
}

PackageStore is an interface for storing and retrieving packages.

func DirStore

func DirStore(dir string) PackageStore

DirStore creates a PackageStore which stores packages in a directory.

type RawPackageIndex

type RawPackageIndex map[string]*RawPkent

RawPackageIndex is an in-memory index of packages.

func IndexDir

func IndexDir(dir vfs.FileSystem) (RawPackageIndex, error)

IndexDir finds all pkgens in a dir and uses them to make a RawPackageIndex.

func (RawPackageIndex) DepWalker

func (rpi RawPackageIndex) DepWalker(pkg string) ([]string, error)

DepWalker returns a DepWalker function which resolves dependencies using the RawPackageIndex.

func (RawPackageIndex) FindDependencies

func (rpi RawPackageIndex) FindDependencies(pkgs ...string) ([]string, error)

FindDependencies finds the dependencies of the given packages recursively

func (RawPackageIndex) List

func (rpi RawPackageIndex) List() []string

List gets a list of packages.

type RawPkent

type RawPkent struct {
	Path  string
	Pkgen *pkgen.RawPackageGenerator
}

RawPkent is an entry in a RawPackageIndex.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL