build

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 53 Imported by: 7

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)

func MutateWith added in v0.4.0

func MutateWith(pb *PipelineBuild, with map[string]string) (map[string]string, 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
	ConfigFile      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
	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
	LogPolicy         []string
	FailOnLintWarning bool
	DefaultCPU        string
	DefaultMemory     string
	DefaultTimeout    time.Duration

	EnabledBuildOptions []string
	// contains filtered or unexported fields
}

func New

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

func (*Build) ApplyBuildOption added in v0.5.0

func (b *Build) ApplyBuildOption(bo config.BuildOption) error

ApplyBuildOption applies a patch described by a BuildOption to a package build.

func (*Build) BuildFlavor added in v0.5.0

func (b *Build) BuildFlavor() string

BuildFlavor determines if a build context uses glibc or musl, it returns "gnu" for GNU systems, and "musl" for musl systems.

func (*Build) BuildGuest added in v0.5.0

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

BuildGuest invokes apko to build the guest environment, returning a reference to the image loaded by the OCI Image loader.

func (*Build) BuildPackage added in v0.5.0

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

func (*Build) BuildTripletGnu added in v0.5.0

func (b *Build) BuildTripletGnu() string

BuildTripletGnu returns the GNU autoconf build triplet, for example `x86_64-pc-linux-gnu`.

func (*Build) BuildTripletRust added in v0.5.0

func (b *Build) BuildTripletRust() string

BuildTripletRust returns the Rust/Cargo build triplet, for example `x86_64-unknown-linux-gnu`.

func (*Build) Close added in v0.5.8

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

func (*Build) IsBuildLess added in v0.5.0

func (b *Build) IsBuildLess() bool

IsBuildLess returns true if the build context does not actually do any building. TODO(kaniini): Improve the heuristic for this by checking for uses/runs statements in the pipeline.

func (*Build) OverlayBinSh added in v0.5.0

func (b *Build) OverlayBinSh() error

func (*Build) PopulateCache added in v0.5.0

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

func (*Build) PopulateWorkspace added in v0.5.0

func (b *Build) PopulateWorkspace(ctx context.Context, src fs.FS) error

func (*Build) RetrieveWorkspace added in v0.5.0

func (b *Build) RetrieveWorkspace(ctx context.Context, fs apkofs.FullFS) error

RetrieveWorkspace retrieves the workspace from the container and unpacks it to the workspace directory. The workspace retrieved from the runner is in a tar stream containing the workspace contents rooted at ./melange-out

func (*Build) Summarize added in v0.5.0

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

func (*Build) SummarizePaths added in v0.5.0

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

func (*Build) WorkspaceConfig added in v0.5.0

func (b *Build) WorkspaceConfig(ctx context.Context) *container.Config

type CacheMembershipMap added in v0.2.0

type CacheMembershipMap map[string]bool

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

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 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 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 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 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 WithFailOnLintWarning added in v0.5.0

func WithFailOnLintWarning(fail bool) Option

WithFailOnLintWarning sets whether or not to fail on linter warnings.

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 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 WithLogPolicy added in v0.4.0

func WithLogPolicy(policy []string) Option

WithLogPolicy sets the logging policy to use during builds.

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.

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 {
	MelangeVersion string
	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) 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 PipelineBuild added in v0.5.0

type PipelineBuild struct {
	Build      *Build
	Test       *Test
	Package    *config.Package
	Subpackage *config.Subpackage
}

func (*PipelineBuild) Emit added in v0.5.2

func (pb *PipelineBuild) Emit(ctx context.Context, pkg *config.Package) error

func (*PipelineBuild) GetConfiguration added in v0.5.4

func (pb *PipelineBuild) GetConfiguration() *config.Configuration

GetConfiguration returns the configuration for the current pipeline. This is either for the Test or the Build

func (*PipelineBuild) GetRunner added in v0.5.4

func (pb *PipelineBuild) GetRunner() container.Runner

GetRunner returns the runner for the current pipeline. This is either for the Test or the Build

func (*PipelineBuild) Interactive added in v0.6.0

func (pb *PipelineBuild) Interactive() bool

func (*PipelineBuild) ShouldRun added in v0.5.2

func (pb *PipelineBuild) ShouldRun(sp config.Subpackage) (bool, error)

type PipelineContext

type PipelineContext struct {
	Pipeline        *config.Pipeline
	Environment     *apko_types.ImageConfiguration
	WorkspaceConfig *container.Config
	// Ordered list of pipeline directories to search for pipelines
	PipelineDirs []string
	// contains filtered or unexported fields
}

func NewPipelineContext added in v0.5.0

func NewPipelineContext(p *config.Pipeline, environment *apko_types.ImageConfiguration, config *container.Config, pipelineDirs []string) *PipelineContext

func (*PipelineContext) ApplyNeeds added in v0.5.0

func (pctx *PipelineContext) ApplyNeeds(ctx context.Context, pb *PipelineBuild) error

TODO(kaniini): Precompile pipeline before running / evaluating its needs.

func (*PipelineContext) Identity added in v0.5.0

func (pctx *PipelineContext) Identity() string

func (*PipelineContext) Run added in v0.5.0

func (pctx *PipelineContext) Run(ctx context.Context, pb *PipelineBuild) (bool, error)

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 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 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
	Arch              apko_types.Architecture
	ExtraKeys         []string
	ExtraRepos        []string
	ExtraTestPackages []string
	BinShOverlay      string
	CacheDir          string
	ApkCacheDir       string
	CacheSource       string
	Runner            container.Runner
	Debug             bool
	DebugRunner       bool
	Interactive       bool
	LogPolicy         []string
}

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) 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 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 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 WithTestLogPolicy added in v0.5.4

func WithTestLogPolicy(policy []string) TestOption

WithTestLogPolicy sets the logging policy to use during tests.

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 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.

Jump to

Keyboard shortcuts

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