build

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 47 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advisories added in v0.3.0

type Advisories map[string][]AdvisoryContent

type AdvisoryContent added in v0.3.0

type AdvisoryContent struct {
	Timestamp       time.Time         `yaml:"timestamp"`
	Status          vex.Status        `yaml:"status"`
	Justification   vex.Justification `yaml:"justification,omitempty"`
	ImpactStatement string            `yaml:"impact,omitempty"`
	ActionStatement string            `yaml:"action,omitempty"`
	FixedVersion    string            `yaml:"fixed-version,omitempty"`
}

func (AdvisoryContent) Validate added in v0.3.0

func (ac AdvisoryContent) Validate() error

type BuildOption added in v0.3.0

type BuildOption struct {
	Vars        map[string]string `yaml:"vars,omitempty"`
	Environment EnvironmentOption `yaml:"environment,omitempty"`
}

BuildOption describes an optional deviation to a package build.

func (BuildOption) Apply added in v0.3.0

func (bo BuildOption) Apply(ctx *Context) error

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

type CacheMembershipMap added in v0.2.0

type CacheMembershipMap map[string]bool

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

type Configuration

type Configuration struct {
	Package     Package
	Environment apko_types.ImageConfiguration
	Pipeline    []Pipeline   `yaml:"pipeline,omitempty"`
	Subpackages []Subpackage `yaml:"subpackages,omitempty"`
	Data        []RangeData  `yaml:"data,omitempty"`
	Secfixes    Secfixes     `yaml:"secfixes,omitempty"`
	Advisories  Advisories   `yaml:"advisories,omitempty"`
	Update      Update       `yaml:"update,omitempty"`

	Vars map[string]string `yaml:"vars,omitempty"`

	VarTransforms []VarTransforms `yaml:"var-transforms,omitempty"`

	Options map[string]BuildOption `yaml:"options,omitempty"`
}

func ParseConfiguration added in v0.3.0

func ParseConfiguration(configurationFilePath string, opts ...ConfigurationParsingOption) (*Configuration, error)

ParseConfiguration returns a decoded build Configuration using the parsing options provided.

func (*Configuration) Load

func (cfg *Configuration) Load(ctx Context) error

Load the configuration data from the build context configuration file.

func (Configuration) PackageURLs added in v0.3.0

func (cfg Configuration) PackageURLs(distro string) []string

PackageURLs returns a list of package URLs ("purls") for the given configuration. The first PURL is always the origin package, and any subsequent items are the PURLs for the Configuration's subpackages. For more information on PURLs, see https://github.com/package-url/purl-spec#purl.

type ConfigurationParsingOption added in v0.3.0

type ConfigurationParsingOption func(*configOptions)

func WithEnvFileForParsing added in v0.3.0

func WithEnvFileForParsing(path string) ConfigurationParsingOption

WithEnvFileForParsing set the paths from whcih to read an environment file.

func WithFS added in v0.3.0

func WithFS(filesystem fs.FS) ConfigurationParsingOption

WithFS sets the fs.FS implementation to use. So far this FS is used only for reading the configuration file. If not provided, the default FS will be an os.DirFS created from the configuration file's containing directory.

func WithLogger added in v0.3.0

func WithLogger(logger Logger) ConfigurationParsingOption

WithLogger sets the logger to use during configuration parsing. This is optional, and if not supplied, a no-op logger will be used.

func WithVarsFileForParsing added in v0.3.0

func WithVarsFileForParsing(path string) ConfigurationParsingOption

WithVarsFileForParsing sets the path to the vars file to use if the user wishes to populate the variables block from an external file.

type ContentsOption added in v0.3.0

type ContentsOption struct {
	Packages ListOption `yaml:"packages,omitempty"`
}

ContentsOption describes an optional deviation to an apko environment's contents block.

type Context

type Context struct {
	Configuration      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             *log.Logger
	Arch               apko_types.Architecture
	ExtraKeys          []string
	ExtraRepos         []string
	DependencyLog      string
	BinShOverlay       string
	CreateBuildLog     bool

	CacheDir        string
	CacheSource     string
	BreakpointLabel string
	ContinueLabel   string

	StripOriginName bool
	EnvFile         string
	VarsFile        string
	Runner          container.Runner

	Debug bool

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

func New

func New(opts ...Option) (*Context, error)

func (*Context) BuildAndPushLocalImage added in v0.2.0

func (ctx *Context) BuildAndPushLocalImage(bc *apko_build.Context) error

BuildAndPushLocalImage uses apko to build and push the image to the local Docker daemon.

func (*Context) BuildFlavor added in v0.2.0

func (ctx *Context) BuildFlavor() string

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

func (*Context) BuildGuest added in v0.2.0

func (ctx *Context) BuildGuest() error

BuildGuest invokes apko to build the guest environment.

func (*Context) BuildPackage

func (ctx *Context) BuildPackage() error

func (*Context) BuildTripletGnu added in v0.2.0

func (ctx *Context) BuildTripletGnu() string

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

func (*Context) BuildTripletRust added in v0.2.0

func (ctx *Context) BuildTripletRust() string

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

func (*Context) GenerateBuildLog added in v0.3.0

func (ctx *Context) GenerateBuildLog(dir string) error

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

func (*Context) LoadIgnoreRules

func (ctx *Context) LoadIgnoreRules() error

func (*Context) OverlayBinSh added in v0.2.0

func (ctx *Context) OverlayBinSh() error

func (*Context) PopulateCache added in v0.2.0

func (ctx *Context) PopulateCache() error

func (*Context) PopulateWorkspace

func (ctx *Context) PopulateWorkspace() error

func (*Context) Summarize

func (ctx *Context) Summarize()

func (*Context) SummarizePaths added in v0.2.0

func (ctx *Context) SummarizePaths()

func (*Context) WorkspaceConfig added in v0.2.0

func (ctx *Context) WorkspaceConfig() *container.Config
type Copyright struct {
	Paths       []string `yaml:"paths,omitempty"`
	Attestation string   `yaml:"attestation,omitempty"`
	License     string   `yaml:"license"`
}

type DataItem added in v0.2.0

type DataItem struct {
	Key, Value string
}

type DataItemList added in v0.2.0

type DataItemList []DataItem

func (*DataItemList) MarshalYAML added in v0.2.0

func (d *DataItemList) MarshalYAML() (interface{}, error)

func (*DataItemList) UnmarshalYAML added in v0.2.0

func (d *DataItemList) UnmarshalYAML(n *yaml.Node) error

type Dependencies

type Dependencies struct {
	Runtime  []string `yaml:"runtime,omitempty"`
	Provides []string `yaml:"provides,omitempty"`
	Replaces []string `yaml:"replaces,omitempty"`

	ProviderPriority int `yaml:"provider-priority,omitempty"`
}

func (*Dependencies) Summarize

func (dep *Dependencies) Summarize(logger *log.Logger)

type DependencyGenerator

type DependencyGenerator func(*PackageContext, *Dependencies) error

type EnvironmentOption added in v0.3.0

type EnvironmentOption struct {
	Contents ContentsOption `yaml:"contents,omitempty"`
}

EnvironmentOption describes an optional deviation to an apko environment.

type GitHubMonitor added in v0.3.0

type GitHubMonitor struct {
	Identifier  string `yaml:"identifier"`             // org/repo for GitHub
	StripPrefix string `yaml:"strip-prefix,omitempty"` // if the version in GitHub contains a prefix which needs to be stripped when updating the melange package
	TagFilter   string `yaml:"tag-filter,omitempty"`   // filter to apply when searching tags on a GitHub repository
	UseTags     bool   `yaml:"use-tag,omitempty"`      // override the default of using a GitHub release to identify related tag to fetch.  Not all projects use GitHub releases but just use tags
}

GitHubMonitor indicates using the GitHub API

type Input

type Input struct {
	Description string
	Default     string
	Required    bool
}

type ListOption added in v0.3.0

type ListOption struct {
	Add    []string `yaml:"add,omitempty"`
	Remove []string `yaml:"remove,omitempty"`
}

ListOption describes an optional deviation to a list, for example, a list of packages.

type Logger added in v0.3.0

type Logger interface {
	Printf(format string, v ...any)
	SetPrefix(prefix string)
}

type Needs

type Needs struct {
	Packages []string
}

type Option

type Option func(*Context) 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 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 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 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 WithPipelineDir

func WithPipelineDir(pipelineDir string) Option

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

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 Package

type Package struct {
	Name               string        `yaml:"name"`
	Version            string        `yaml:"version"`
	Epoch              uint64        `yaml:"epoch"`
	Description        string        `yaml:"description,omitempty"`
	URL                string        `yaml:"url,omitempty"`
	Commit             string        `yaml:"commit,omitempty"`
	TargetArchitecture []string      `yaml:"target-architecture,omitempty"`
	Copyright          []Copyright   `yaml:"copyright,omitempty"`
	Dependencies       Dependencies  `yaml:"dependencies,omitempty"`
	Options            PackageOption `yaml:"options,omitempty"`
	Scriptlets         Scriptlets    `yaml:"scriptlets,omitempty"`
}

func (*Package) Emit

func (pkg *Package) Emit(ctx *PipelineContext) error

func (*Package) FullCopyright added in v0.2.0

func (p *Package) FullCopyright() string

FullCopyright returns the concatenated copyright expressions defined in the configuration file.

func (*Package) LicenseExpression added in v0.2.0

func (p *Package) LicenseExpression() string

LicenseExpression returns an SPDX license expression formed from the data in the copyright structs found in the conf. Its a simple OR for now.

func (Package) PackageURL added in v0.3.0

func (p Package) PackageURL(distro string) string

PackageURL returns the package URL ("purl") for the package. For more information, see https://github.com/package-url/purl-spec#purl.

type PackageContext

type PackageContext struct {
	Context       *Context
	Origin        *Package
	PackageName   string
	OriginName    string
	InstalledSize int64
	DataHash      string
	OutDir        string
	Logger        *log.Logger
	Dependencies  Dependencies
	Arch          string
	Options       PackageOption
	Scriptlets    Scriptlets
	Description   string
	URL           string
	Commit        string
}

func (*PackageContext) EmitPackage

func (pc *PackageContext) EmitPackage() error

func (*PackageContext) Filename

func (pc *PackageContext) Filename() string

func (*PackageContext) GenerateControlData

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

func (*PackageContext) GenerateDependencies

func (pc *PackageContext) GenerateDependencies() error

func (*PackageContext) Identity

func (pc *PackageContext) Identity() string

func (*PackageContext) SignatureName

func (pc *PackageContext) SignatureName() string

func (*PackageContext) WorkspaceSubdir

func (pc *PackageContext) WorkspaceSubdir() string

type PackageOption added in v0.2.0

type PackageOption struct {
	NoProvides bool `yaml:"no-provides"`
	NoDepends  bool `yaml:"no-depends"`
	NoCommands bool `yaml:"no-commands"`
}

type Pipeline

type Pipeline struct {
	Name       string             `yaml:"name,omitempty"`
	Uses       string             `yaml:"uses,omitempty"`
	With       map[string]string  `yaml:"with,omitempty"`
	Runs       string             `yaml:"runs,omitempty"`
	Pipeline   []Pipeline         `yaml:"pipeline,omitempty"`
	Inputs     map[string]Input   `yaml:"inputs,omitempty"`
	Needs      Needs              `yaml:"needs,omitempty"`
	Label      string             `yaml:"label,omitempty"`
	If         string             `yaml:"if,omitempty"`
	Assertions PipelineAssertions `yaml:"assertions,omitempty"`
	WorkDir    string             `yaml:"working-directory,omitempty"`

	SBOM SBOM `yaml:"sbom,omitempty"`
	// contains filtered or unexported fields
}

func NewPipeline

func NewPipeline(ctx *PipelineContext) (*Pipeline, error)

func (*Pipeline) ApplyNeeds

func (p *Pipeline) ApplyNeeds(ctx *PipelineContext) error

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

func (*Pipeline) Identity

func (p *Pipeline) Identity() string

func (*Pipeline) Run

func (p *Pipeline) Run(ctx *PipelineContext) (bool, error)

type PipelineAssertions added in v0.2.0

type PipelineAssertions struct {
	RequiredSteps int `yaml:"required-steps,omitempty"`
}

type PipelineContext

type PipelineContext struct {
	Context    *Context
	Package    *Package
	Subpackage *Subpackage
}

type RangeData added in v0.2.0

type RangeData struct {
	Name  string       `yaml:"name"`
	Items DataItemList `yaml:"items"`
}

type ReleaseMonitor added in v0.3.0

type ReleaseMonitor struct {
	Identifier int `yaml:"identifier"` // ID number for release monitor
}

ReleaseMonitor indicates using the API for https://release-monitoring.org/

type SBOM added in v0.2.0

type SBOM struct {
	Language string `yaml:"language"`
}

type Scriptlets added in v0.2.0

type Scriptlets struct {
	Trigger struct {
		Script string
		Paths  []string
	} `yaml:"trigger,omitempty"`

	PreInstall    string `yaml:"pre-install,omitempty"`
	PostInstall   string `yaml:"post-install,omitempty"`
	PreDeinstall  string `yaml:"pre-deinstall,omitempty"`
	PostDeinstall string `yaml:"post-deinstall,omitempty"`
	PreUpgrade    string `yaml:"pre-upgrade,omitempty"`
	PostUpgrade   string `yaml:"post-upgrade,omitempty"`
}

type Secfixes added in v0.3.0

type Secfixes map[string][]string

type Subpackage

type Subpackage struct {
	If           string        `yaml:"if,omitempty"`
	Range        string        `yaml:"range,omitempty"`
	Name         string        `yaml:"name"`
	Pipeline     []Pipeline    `yaml:"pipeline,omitempty"`
	Dependencies Dependencies  `yaml:"dependencies,omitempty"`
	Options      PackageOption `yaml:"options,omitempty"`
	Scriptlets   Scriptlets    `yaml:"scriptlets,omitempty"`
	Description  string        `yaml:"description,omitempty"`
	URL          string        `yaml:"url,omitempty"`
	Commit       string        `yaml:"commit,omitempty"`
}

func (*Subpackage) Emit

func (spkg *Subpackage) Emit(ctx *PipelineContext) error

func (Subpackage) PackageURL added in v0.3.0

func (spkg Subpackage) PackageURL(distro, packageVersionWithRelease string) string

PackageURL returns the package URL ("purl") for the subpackage. For more information, see https://github.com/package-url/purl-spec#purl.

func (Subpackage) ShouldRun added in v0.3.0

func (sp Subpackage) ShouldRun(pctx *PipelineContext) (bool, error)

type Update added in v0.3.0

type Update struct {
	Enabled          bool            `yaml:"enabled"`                     // toggle if updates should occur
	Shared           bool            `yaml:"shared,omitempty"`            // indicate that an update to this package requires an epoch bump of downstream dependencies, e.g. golang, java
	VersionSeparator string          `yaml:"version-separator,omitempty"` // override the version separator if it is nonstandard
	ReleaseMonitor   *ReleaseMonitor `yaml:"release-monitor,omitempty"`
	GitHubMonitor    *GitHubMonitor  `yaml:"github,omitempty"`
}

Update provides information used to describe how to keep the package up to date

type VarTransforms added in v0.3.0

type VarTransforms struct {
	From    string `yaml:"from"`
	Match   string `yaml:"match"`
	Replace string `yaml:"replace"`
	To      string `yaml:"to"`
}

Jump to

Keyboard shortcuts

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