build

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 54 Imported by: 11

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

func GetAllRunners() []runner

GetAllRunners returns a list of all valid runners.

func GetDefaultRunner added in v0.4.0

func GetDefaultRunner() runner

GetDefaultRunner returns the default runner to use. Currently, this is bubblewrap, but will be replaced with determining by platform.

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
	PipelineDir        string
	BuiltinPipelineDir string
	SourceDir          string
	GuestDir           string
	SigningKey         string
	SigningPassphrase  string
	Namespace          string
	GenerateIndex      bool
	EmptyWorkspace     bool
	OutDir             string
	Logger             apko_log.Logger
	Arch               apko_types.Architecture
	ExtraKeys          []string
	ExtraRepos         []string
	DependencyLog      string
	BinShOverlay       string
	CreateBuildLog     bool

	CacheDir        string
	ApkCacheDir     string
	CacheSource     string
	BreakpointLabel string
	ContinueLabel   string

	StripOriginName bool
	EnvFile         string
	VarsFile        string
	Runner          container.Runner
	RunnerName      string

	Debug             bool
	DebugRunner       bool
	LogPolicy         []string
	FailOnLintWarning bool

	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) error

BuildGuest invokes apko to build the guest environment.

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

func (b *Build) LoadIgnoreRules() error

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) error

func (*Build) RetrieveWorkspace added in v0.5.0

func (b *Build) RetrieveWorkspace(ctx context.Context) 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()

func (*Build) SummarizePaths added in v0.5.0

func (b *Build) SummarizePaths()

func (*Build) WorkspaceConfig added in v0.5.0

func (b *Build) WorkspaceConfig() *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 DependencyGenerator

type DependencyGenerator func(*PackageBuild, *config.Dependencies) error

type FulcioApkSigner added in v0.5.0

type FulcioApkSigner struct{}

APKv2+Fulcio style signature is an SHA-256 hash on the control digest. TODO(kaniini): Emit fulcio signature if signing key not configured.

func (*FulcioApkSigner) Sign added in v0.5.0

func (*FulcioApkSigner) Sign(control []byte) ([]byte, error)

Sign implements ApkSigner.

func (*FulcioApkSigner) SignatureName added in v0.5.0

func (*FulcioApkSigner) SignatureName() string

SignatureName implements ApkSigner.

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 WithBreakpointLabel added in v0.2.0

func WithBreakpointLabel(breakpointLabel string) Option

WithBreakpointLabel sets a label to stop build execution at. The build environment and workspace are preserved.

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 WithBuiltinPipelineDirectory added in v0.2.0

func WithBuiltinPipelineDirectory(builtinPipelineDir string) Option

WithBuiltinPipelineDirectory sets the pipeline directory to use.

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 WithContinueLabel added in v0.2.0

func WithContinueLabel(continueLabel string) Option

WithContinueLabel sets a label to continue build execution from. This requires a preserved build environment and workspace.

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

func WithLogPolicy(policy []string) Option

WithLogPolicy sets the logging policy to use during builds.

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.

func WithRunner added in v0.4.0

func WithRunner(runner string) 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 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        *PackageContext
	PackageName   string
	OriginName    string
	InstalledSize int64
	DataHash      string
	OutDir        string
	Logger        log.Logger
	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() 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 PackageContext

type PackageContext struct {
	Package *config.Package
}

func NewPackageContext added in v0.5.0

func NewPackageContext(pkg *config.Package) (*PackageContext, error)

func (*PackageContext) Emit added in v0.5.0

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

type PipelineBuild added in v0.5.0

type PipelineBuild struct {
	Build      *Build
	Package    *PackageContext
	Subpackage *SubpackageContext
}

type PipelineContext

type PipelineContext struct {
	Pipeline *config.Pipeline
	// contains filtered or unexported fields
}

func NewPipelineContext added in v0.5.0

func NewPipelineContext(p *config.Pipeline, logger apko_log.Logger) (*PipelineContext, error)

func NewPipelineContextFromPipelineBuild added in v0.5.0

func NewPipelineContextFromPipelineBuild(pb *PipelineBuild) (*PipelineContext, error)

func (*PipelineContext) ApplyNeeds added in v0.5.0

func (pctx *PipelineContext) ApplyNeeds(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 SubpackageContext added in v0.5.0

type SubpackageContext struct {
	Subpackage *config.Subpackage
}

func NewSubpackageContext added in v0.5.0

func NewSubpackageContext(pkg *config.Subpackage) (*SubpackageContext, error)

Create a new subpackage context

func (*SubpackageContext) Emit added in v0.5.0

func (spkg *SubpackageContext) Emit(ctx context.Context, pb *PipelineBuild) error

func (SubpackageContext) ShouldRun added in v0.5.0

func (sp SubpackageContext) ShouldRun(pb *PipelineBuild) (bool, error)

Jump to

Keyboard shortcuts

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