build

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 59 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkipThisArch = errors.New("error: skip this arch")

Functions

func EmitSignature added in v0.5.0

func EmitSignature(ctx context.Context, signer ApkSigner, controlData []byte, sde time.Time) ([]byte, error)

Types

type ApkSigner added in v0.5.0

type ApkSigner interface {
	Sign(controlData []byte) ([]byte, error)

	SignatureName() string
}

type Build added in v0.5.0

type Build struct {
	Configuration config.Configuration

	// The name of the build configuration file, e.g. "crane.yaml".
	ConfigFile string

	// The URL of the git repository where the build configuration file is stored,
	// e.g. "https://github.com/wolfi-dev/os".
	ConfigFileRepositoryURL string

	// The commit hash of the git repository corresponding to the current state of
	// the build configuration file.
	ConfigFileRepositoryCommit string

	// The SPDX license string to use for the build configuration file.
	ConfigFileLicense string

	SourceDateEpoch time.Time
	WorkspaceDir    string
	WorkspaceIgnore string
	// Ordered directories where to find 'uses' pipelines.
	PipelineDirs      []string
	SourceDir         string
	GuestDir          string
	SigningKey        string
	SigningPassphrase string
	Namespace         string
	GenerateIndex     bool
	EmptyWorkspace    bool
	OutDir            string
	Arch              apko_types.Architecture
	Libc              string
	ExtraKeys         []string
	ExtraRepos        []string
	ExtraPackages     []string
	DependencyLog     string
	BinShOverlay      string
	CreateBuildLog    bool
	CacheDir          string
	ApkCacheDir       string
	CacheSource       string
	StripOriginName   bool
	EnvFile           string
	VarsFile          string
	Runner            container.Runner

	Debug                 bool
	DebugRunner           bool
	Interactive           bool
	Remove                bool
	LintRequire, LintWarn []string
	DefaultCPU            string
	DefaultCPUModel       string
	DefaultDisk           string
	DefaultMemory         string
	DefaultTimeout        time.Duration
	Auth                  map[string]options.Auth
	IgnoreSignatures      bool

	EnabledBuildOptions []string

	// Initialized in New and mutated throughout the build process as we gain
	// visibility into our packages' (including subpackages') composition. This is
	// how we get "build-time" SBOMs!
	SBOMGroup *SBOMGroup
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, opts ...Option) (*Build, error)

func (*Build) BuildPackage added in v0.5.0

func (b *Build) BuildPackage(ctx context.Context) error

func (*Build) Close added in v0.5.8

func (b *Build) Close(ctx context.Context) error

func (*Build) Compile added in v0.9.0

func (b *Build) Compile(ctx context.Context) error

Compile compiles all configuration, including tests, by loading any pipelines and substituting all variables.

func (*Build) Emit added in v0.9.0

func (b *Build) Emit(ctx context.Context, pkg *config.Package) error

func (*Build) SummarizePaths added in v0.5.0

func (b *Build) SummarizePaths(ctx context.Context)

type CacheMembershipMap added in v0.2.0

type CacheMembershipMap map[string]bool

CacheMembershipMap describes a mapping where keys map to 'true' if present.

type Compiled added in v0.9.0

type Compiled struct {
	PipelineDirs []string
	Needs        []string
}

func (*Compiled) CompilePipelines added in v0.9.0

func (c *Compiled) CompilePipelines(ctx context.Context, sm *SubstitutionMap, pipelines []config.Pipeline) error

type KeyApkSigner added in v0.5.0

type KeyApkSigner struct {
	KeyFile       string
	KeyPassphrase string
}

Key base signature (normal) uses a SHA-1 hash on the control digest.

func (KeyApkSigner) Sign added in v0.5.0

func (s KeyApkSigner) Sign(control []byte) ([]byte, error)

func (KeyApkSigner) SignatureName added in v0.5.0

func (s KeyApkSigner) SignatureName() string

type Option

type Option func(*Build) error

func WithArch

func WithArch(arch apko_types.Architecture) Option

WithArch sets the build architecture to use for this build context.

func WithAuth added in v0.8.4

func WithAuth(domain, user, pass string) Option

func WithBinShOverlay added in v0.2.0

func WithBinShOverlay(binShOverlay string) Option

WithBinShOverlay sets a filename to copy from when installing /bin/sh into a build environment.

func WithBuildDate

func WithBuildDate(s string) Option

WithBuildDate sets the timestamps for the build context. The string is parsed according to RFC3339. An empty string is a special case and will default to the unix epoch.

func WithCPU added in v0.5.4

func WithCPU(cpu string) Option

func WithCPUModel added in v0.15.0

func WithCPUModel(cpumodel string) Option

func WithCacheDir added in v0.2.0

func WithCacheDir(cacheDir string) Option

WithCacheDir sets the cache directory to use.

func WithCacheSource added in v0.3.0

func WithCacheSource(sourceDir string) Option

WithCacheSource sets the cache source directory to use. The cache will be pre-populated from this source directory.

func WithConfig

func WithConfig(configFile string) Option

WithConfig sets the configuration file used for the package build context.

func WithConfigFileLicense added in v0.14.0

func WithConfigFileLicense(license string) Option

func WithConfigFileRepositoryCommit added in v0.14.0

func WithConfigFileRepositoryCommit(hash string) Option

func WithConfigFileRepositoryURL added in v0.14.0

func WithConfigFileRepositoryURL(u string) Option

func WithCreateBuildLog added in v0.3.0

func WithCreateBuildLog(createBuildLog bool) Option

WithCreateBuildLog indicates whether to generate a package.log file containing the list of packages that were built. Some packages may have been skipped during the build if , so it can be hard to know exactly which packages were built

func WithDebug added in v0.3.0

func WithDebug(debug bool) Option

WithDebug indicates whether debug logging of pipelines should be enabled.

func WithDebugRunner added in v0.5.0

func WithDebugRunner(debug bool) Option

WithDebugRunner indicates whether the runner should leave the build environment up on failures

func WithDependencyLog added in v0.2.0

func WithDependencyLog(logFile string) Option

WithDependencyLog sets a filename to use for dependency logging.

func WithDisk added in v0.11.3

func WithDisk(disk string) Option

func WithEmptyWorkspace

func WithEmptyWorkspace(emptyWorkspace bool) Option

WithEmptyWorkspace sets whether the workspace should be empty.

func WithEnabledBuildOptions added in v0.3.0

func WithEnabledBuildOptions(enabledBuildOptions []string) Option

WithEnabledBuildOptions takes an array of strings representing enabled build options. These options are referenced in the options block of the Configuration, and represent patches to the configured build process which are optionally applied.

func WithEnvFile added in v0.2.0

func WithEnvFile(envFile string) Option

WithEnvFile specifies an environment file to use to preload the build environment. It should contain the CFLAGS and LDFLAGS used by the C toolchain as well as any other desired environment settings for the build environment.

func WithExtraKeys

func WithExtraKeys(extraKeys []string) Option

WithExtraKeys adds a set of extra keys to the build context.

func WithExtraPackages added in v0.6.2

func WithExtraPackages(extraPackages []string) Option

WithExtraPackages specifies packages that are added to each build by default.

func WithExtraRepos

func WithExtraRepos(extraRepos []string) Option

WithExtraRepos adds a set of extra repos to the build context.

func WithGenerateIndex added in v0.2.0

func WithGenerateIndex(generateIndex bool) Option

WithGenerateIndex sets whether or not the apk index should be generated.

func WithGuestDir added in v0.2.0

func WithGuestDir(guestDir string) Option

WithGuestDir sets the guest directory to use.

func WithIgnoreSignatures added in v0.11.3

func WithIgnoreSignatures(ignore bool) Option

WithIgnoreIndexSignatures sets whether to ignore repository signature verification.

func WithInteractive added in v0.6.0

func WithInteractive(interactive bool) Option

WithInteractive indicates whether to attach stdin and a tty to the runner on failures

func WithLibcFlavorOverride added in v0.9.0

func WithLibcFlavorOverride(libc string) Option

WithLibcFlavorOverride sets the libc flavor for the build.

func WithLintRequire added in v0.10.0

func WithLintRequire(linters []string) Option

WithLintRequire sets required linter checks.

func WithLintWarn added in v0.10.0

func WithLintWarn(linters []string) Option

WithLintWarn sets non-required linter checks.

func WithMemory added in v0.5.4

func WithMemory(memory string) Option

func WithNamespace added in v0.3.0

func WithNamespace(namespace string) Option

WithNamespace takes a string to be used as the namespace in PackageURLs identifying the built apk in the generated SBOM. If no namespace is provided "unknown" will be listed as namespace.

func WithOutDir

func WithOutDir(outDir string) Option

WithOutDir sets the output directory to use for the packages.

func WithPackageCacheDir added in v0.4.0

func WithPackageCacheDir(apkCacheDir string) Option

func WithPipelineDir

func WithPipelineDir(pipelineDir string) Option

WithPipelineDir sets the pipeline directory to extend the built-in pipeline directory. These are searched in order, so the first one found is used.

func WithRemove added in v0.5.8

func WithRemove(remove bool) Option

WithRemove indicates whether the the build will clean up after itself. This includes deleting any intermediate artifacts like container images and temp workspace and guest dirs.

func WithRunner added in v0.4.0

func WithRunner(runner container.Runner) Option

WithRunner specifies what runner to use to wrap the build environment.

func WithSigningKey

func WithSigningKey(signingKey string) Option

WithSigningKey sets the signing key path to use.

func WithSourceDir

func WithSourceDir(sourceDir string) Option

WithSourceDir sets the source directory to use.

func WithStripOriginName added in v0.2.0

func WithStripOriginName(stripOriginName bool) Option

WithStripOriginName determines whether the origin name should be stripped from generated packages. The APK solver uses origin names to flatten possible dependency nodes when solving for a DAG, which means that they should be stripped when building "bootstrap" repositories, as the cross-sysroot packages will be preferred over the native ones otherwise.

func WithTimeout added in v0.5.4

func WithTimeout(dur time.Duration) Option

func WithVarsFile added in v0.3.0

func WithVarsFile(varsFile string) Option

WithVarsFile specifies a variables file to use to populate the build configuration variables block.

func WithWorkspaceDir

func WithWorkspaceDir(workspaceDir string) Option

WithWorkspaceDir sets the workspace directory to use.

func WithWorkspaceIgnore

func WithWorkspaceIgnore(workspaceIgnore string) Option

WithWorkspaceIgnore sets the workspace ignore rules file to use.

type PackageBuild added in v0.5.0

type PackageBuild struct {
	Build         *Build
	Origin        *config.Package
	PackageName   string
	OriginName    string
	InstalledSize int64
	DataHash      string
	OutDir        string
	Dependencies  config.Dependencies
	Arch          string
	Options       *config.PackageOption
	Scriptlets    *config.Scriptlets
	Description   string
	URL           string
	Commit        string
}

func (*PackageBuild) AppendBuildLog added in v0.5.0

func (pc *PackageBuild) AppendBuildLog(dir string) error

AppendBuildLog will create or append a list of packages that were built by melange build

func (*PackageBuild) EmitPackage added in v0.5.0

func (pc *PackageBuild) EmitPackage(ctx context.Context) error

func (*PackageBuild) Filename added in v0.5.0

func (pc *PackageBuild) Filename() string

func (*PackageBuild) GenerateControlData added in v0.5.0

func (pc *PackageBuild) GenerateControlData(w io.Writer) error

func (*PackageBuild) GenerateDependencies added in v0.5.0

func (pc *PackageBuild) GenerateDependencies(ctx context.Context, hdl sca.SCAHandle) error

func (*PackageBuild) Identity added in v0.5.0

func (pc *PackageBuild) Identity() string

func (*PackageBuild) SignatureName added in v0.5.0

func (pc *PackageBuild) SignatureName() string

func (*PackageBuild) Signer added in v0.5.0

func (pc *PackageBuild) Signer() ApkSigner

func (*PackageBuild) WorkspaceSubdir added in v0.5.0

func (pc *PackageBuild) WorkspaceSubdir() string

type Runner added in v0.5.4

type Runner string

func GetAllRunners added in v0.4.0

func GetAllRunners() []Runner

GetAllRunners returns a list of all valid runners.

type SBOMGroup added in v0.14.0

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

An SBOMGroup stores SBOMs corresponding to each package (or subpackage) within a build group. Its purpose is to let the build process easily manage SBOMs for the 1-N number of packages it ends up emitting.

func NewSBOMGroup added in v0.14.0

func NewSBOMGroup(pkgNames ...string) *SBOMGroup

NewSBOMGroup creates a new SBOMGroup, initializing SBOMs for each package and subpackage name provided.

func (*SBOMGroup) AddBuildConfigurationPackage added in v0.14.0

func (sg *SBOMGroup) AddBuildConfigurationPackage(p *sbom.Package)

AddBuildConfigurationPackage adds a package serving as the "build configuration package" to all SBOMs in the group.

func (*SBOMGroup) AddUpstreamSourcePackage added in v0.14.0

func (sg *SBOMGroup) AddUpstreamSourcePackage(p *sbom.Package)

AddUpstreamSourcePackage adds a package serving as an "upstream source package" to all SBOMs in the group.

func (*SBOMGroup) Document added in v0.14.0

func (sg *SBOMGroup) Document(name string) *sbom.Document

Document retrieves the SBOM for the given package or subpackage name.

func (*SBOMGroup) SetCreatedTime added in v0.14.0

func (sg *SBOMGroup) SetCreatedTime(t time.Time)

SetCreatedTime sets the creation time for all SBOMs in the group.

func (*SBOMGroup) SetLicensingInfos added in v0.14.0

func (sg *SBOMGroup) SetLicensingInfos(li map[string]string)

SetLicensingInfos sets the licensing information for all SBOMs in the group.

type SCABuildInterface added in v0.5.2

type SCABuildInterface struct {
	// PackageBuild represents the underlying package build object.
	PackageBuild *PackageBuild
}

SCABuildInterface provides an implementation of SCAHandle which maps to a package build object.

func (*SCABuildInterface) BaseDependencies added in v0.5.2

func (scabi *SCABuildInterface) BaseDependencies() config.Dependencies

BaseDependencies returns the base dependencies for the package being built.

func (*SCABuildInterface) Filesystem added in v0.5.2

func (scabi *SCABuildInterface) Filesystem() (sca.SCAFS, error)

Filesystem implements an abstract filesystem providing access to a package filesystem.

func (*SCABuildInterface) FilesystemForRelative added in v0.5.2

func (scabi *SCABuildInterface) FilesystemForRelative(pkgName string) (sca.SCAFS, error)

FilesystemForRelative implements an abstract filesystem for any of the packages being built.

func (*SCABuildInterface) Options added in v0.5.2

func (scabi *SCABuildInterface) Options() config.PackageOption

Options returns the configured SCA engine options for the package being built.

func (*SCABuildInterface) PackageName added in v0.5.2

func (scabi *SCABuildInterface) PackageName() string

PackageName returns the currently built package name.

func (*SCABuildInterface) RelativeNames added in v0.5.2

func (scabi *SCABuildInterface) RelativeNames() []string

RelativeNames returns all the package names relating to the package being built.

func (*SCABuildInterface) Version added in v0.5.2

func (scabi *SCABuildInterface) Version() string

Version returns the version of the package being built including epoch.

type SubstitutionMap added in v0.9.0

type SubstitutionMap struct {
	Substitutions map[string]string
}

func NewSubstitutionMap added in v0.9.0

func NewSubstitutionMap(cfg *config.Configuration, arch apko_types.Architecture, flavor string, buildOpts []string) (*SubstitutionMap, error)

func (*SubstitutionMap) MutateWith added in v0.9.0

func (sm *SubstitutionMap) MutateWith(with map[string]string) (map[string]string, error)

func (*SubstitutionMap) Subpackage added in v0.9.0

func (sm *SubstitutionMap) Subpackage(subpkg *config.Subpackage) *SubstitutionMap

type Test added in v0.5.4

type Test struct {
	// Package to test.
	Package         string
	Configuration   config.Configuration
	ConfigFile      string
	WorkspaceDir    string
	WorkspaceIgnore string
	// Ordered directories where to find 'uses' pipelines.
	PipelineDirs      []string
	SourceDir         string
	GuestDir          string
	Remove            bool
	Arch              apko_types.Architecture
	ExtraKeys         []string
	ExtraRepos        []string
	ExtraTestPackages []string
	BinShOverlay      string
	CacheDir          string
	ApkCacheDir       string
	CacheSource       string
	EnvFile           string
	Runner            container.Runner
	Debug             bool
	DebugRunner       bool
	Interactive       bool
	Auth              map[string]options.Auth
	IgnoreSignatures  bool
}

func NewTest added in v0.5.4

func NewTest(ctx context.Context, opts ...TestOption) (*Test, error)

func (*Test) BuildGuest added in v0.5.4

func (t *Test) BuildGuest(ctx context.Context, imgConfig apko_types.ImageConfiguration, guestFS apkofs.FullFS) (string, error)

BuildGuest invokes apko to create the test image for the guest environment. imgConfig specifies the environment for the test to run (e.g. packages to install). Returns the imgRef for the created image, or error.

func (*Test) Close added in v0.5.8

func (t *Test) Close() error

func (*Test) Compile added in v0.9.0

func (t *Test) Compile(ctx context.Context) error

func (*Test) IsTestless added in v0.5.4

func (t *Test) IsTestless() bool

IsTestless returns true if the test context does not actually do any testing.

func (*Test) OverlayBinSh added in v0.5.4

func (t *Test) OverlayBinSh(suffix string) error

func (*Test) PopulateCache added in v0.5.4

func (t *Test) PopulateCache(ctx context.Context) error

func (*Test) PopulateWorkspace added in v0.5.4

func (t *Test) PopulateWorkspace(ctx context.Context, src fs.FS) error

func (*Test) Summarize added in v0.5.4

func (t *Test) Summarize(ctx context.Context)

func (*Test) SummarizePaths added in v0.5.4

func (t *Test) SummarizePaths(ctx context.Context)

func (*Test) TestPackage added in v0.5.4

func (t *Test) TestPackage(ctx context.Context) error

type TestOption added in v0.5.4

type TestOption func(*Test) error

func WithExtraTestPackages added in v0.5.6

func WithExtraTestPackages(extraTestPackages []string) TestOption

WithExtraTestPackages specifies packages that are added to each test by default.

func WithTestArch added in v0.5.4

func WithTestArch(arch apko_types.Architecture) TestOption

WithTestArch sets the build architecture to use for this test context.

func WithTestAuth added in v0.8.4

func WithTestAuth(domain, user, pass string) TestOption

func WithTestBinShOverlay added in v0.5.4

func WithTestBinShOverlay(binShOverlay string) TestOption

WithTestBinShOverlay sets a filename to copy from when installing /bin/sh into a test environment.

func WithTestCacheDir added in v0.5.4

func WithTestCacheDir(cacheDir string) TestOption

WithCacheDir sets the cache directory to use.

func WithTestCacheSource added in v0.5.4

func WithTestCacheSource(sourceDir string) TestOption

WithCacheSource sets the cache source directory to use. The cache will be pre-populated from this source directory.

func WithTestConfig added in v0.5.4

func WithTestConfig(configFile string) TestOption

WithTestConfig sets the configuration file used for the package test context.

func WithTestDebug added in v0.5.4

func WithTestDebug(debug bool) TestOption

WithTestDebug indicates whether debug logging of pipelines should be enabled.

func WithTestDebugRunner added in v0.5.4

func WithTestDebugRunner(debugRunner bool) TestOption

func WithTestEnvFile added in v0.8.4

func WithTestEnvFile(envFile string) TestOption

WithTestEnvFile specifies an environment file to use to preload the build environment. It should contain the CFLAGS and LDFLAGS used by the C toolchain as well as any other desired environment settings for the build environment.

func WithTestExtraKeys added in v0.5.4

func WithTestExtraKeys(extraKeys []string) TestOption

WithTestExtraKeys adds a set of extra keys to the test context.

func WithTestExtraRepos added in v0.5.4

func WithTestExtraRepos(extraRepos []string) TestOption

WithTestExtraRepos adds a set of extra repos to the test context.

func WithTestGuestDir added in v0.5.4

func WithTestGuestDir(guestDir string) TestOption

WithGuestDir sets the guest directory to use.

func WithTestInteractive added in v0.6.0

func WithTestInteractive(interactive bool) TestOption

WithTestInteractive indicates whether to attach stdin and a tty to the runner on failures

func WithTestPackage added in v0.5.4

func WithTestPackage(pkg string) TestOption

WithTestPackage specifies the package to test.

func WithTestPackageCacheDir added in v0.5.4

func WithTestPackageCacheDir(apkCacheDir string) TestOption

func WithTestPipelineDir added in v0.5.4

func WithTestPipelineDir(pipelineDir string) TestOption

WithPipelineDir sets the pipeline directory to extend the built-in pipeline directory.

func WithTestRemove added in v0.13.7

func WithTestRemove(c bool) TestOption

If true, the test will clean up the test environment after the test is complete.

func WithTestRunner added in v0.5.4

func WithTestRunner(runner container.Runner) TestOption

WithTestRunner specifies what runner to use to wrap the test environment.

func WithTestSourceDir added in v0.5.4

func WithTestSourceDir(sourceDir string) TestOption

WithSourceDir sets the source directory to use.

func WithTestWorkspaceDir added in v0.5.4

func WithTestWorkspaceDir(workspaceDir string) TestOption

WithWorkspaceDir sets the workspace directory to use.

func WithTestWorkspaceIgnore added in v0.5.4

func WithTestWorkspaceIgnore(workspaceIgnore string) TestOption

WithWorkspaceIgnore sets the workspace ignore rules file to use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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