Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyOverlayToSources(dryRunnable opctx.DryRunnable, fs opctx.FS, ...) error
- func ApplySpecOverlay(overlay projectconfig.ComponentOverlay, openedSpec *spec.Spec) error
- func ApplySpecOverlayToFileInPlace(fs opctx.FS, overlay projectconfig.ComponentOverlay, specPath string) error
- func GenerateMacrosFileContents(buildConfig projectconfig.ComponentBuildConfig) string
- type SourcePreparer
Constants ¶
const MacrosFileExtension = ".azl.macros"
MacrosFileExtension is the file extension used for azldev-generated macros files.
const MacrosFileHeader = `# Macros file automatically generated by azldev.
# Do not edit manually; changes will be overwritten.`
MacrosFileHeader is the comment header included at the top of generated macros files.
Variables ¶
var ErrOverlayDidNotApply = errors.New("overlay did not apply to target")
Error to return when an overlay did not apply to its target (e.g., a search-and-replace overlay that found no matches).
Functions ¶
func ApplyOverlayToSources ¶
func ApplyOverlayToSources( dryRunnable opctx.DryRunnable, fs opctx.FS, overlay projectconfig.ComponentOverlay, sourcesDirPath, specPath string, ) error
ApplyOverlayToSources applies the provided overlay to the specified spec and related sources. Files are mutated in-place. If an error occurs mid-way through applying multiple overlays, previously applied changes will remain. Callers should consider working on copies of source files if atomicity is required.
func ApplySpecOverlay ¶
func ApplySpecOverlay(overlay projectconfig.ComponentOverlay, openedSpec *spec.Spec) error
ApplySpecOverlay applies a spec-based overlay to an opened spec. An error is returned if a non-spec overlay is provided.
func ApplySpecOverlayToFileInPlace ¶
func ApplySpecOverlayToFileInPlace(fs opctx.FS, overlay projectconfig.ComponentOverlay, specPath string) error
ApplySpecOverlayToFileInPlace applies the given overlay to the specified spec file. Changes are made in-place.
func GenerateMacrosFileContents ¶
func GenerateMacrosFileContents(buildConfig projectconfig.ComponentBuildConfig) string
GenerateMacrosFileContents generates the contents of an RPM macros file from the given build configuration. The output uses standard RPM macro file format (%name value) and includes a header comment identifying the file as auto-generated.
With flags are converted to %_with_FLAG 1 macros. Without flags are converted to %_without_FLAG 1 macros. Defines are emitted as %name value macros.
All macros are collected into a single map and sorted alphabetically by name for deterministic output. If the same macro is defined multiple times (e.g., via both a with flag and an explicit define), the later definition wins. The order of processing is: with flags, then without flags, then explicit defines, then undefines.
Undefines remove entries from the generated macros map. This only affects macros that originate from the merged TOML configuration (with, without, and defines fields); it does not undefine arbitrary system-level RPM macros. The primary use case is allowing a component-level TOML file to override a distro-level or project-level default by removing a macro that would otherwise be emitted into the macros file.
Note: RPM macro values can contain spaces without special escaping; everything after the macro name (and separating whitespace) is treated as the macro body.
If no macros remain after processing (empty config, or all macros removed via undefines), an empty string is returned to signal that no macros file is needed.
Types ¶
type SourcePreparer ¶
type SourcePreparer interface {
// PrepareSources prepares the input sources for the given component, writing them to the given output directory.
// After this function completes successfully, the output directory should contain all files required to build
// the component, with any post-processing applied as necessary. The only remaining dependencies not contained
// within the output directory will be build-time dependencies on external packages (RPMs), including those
// relied on to be present implicitly within the build root, or expressed via BuildRequires or DynamicBuildRequires
// in the component's spec file and any defaults from the macros used to interpret the spec file.
PrepareSources(ctx context.Context, component components.Component, outputDir string, applyOverlays bool) error
// DiffSources computes a unified diff showing the changes that overlays apply to a component's sources.
// The component's sources are fetched once into a subdirectory of baseDir, then copied to a second
// subdirectory where overlays are applied in-place. The diff between the two subdirectories is returned.
DiffSources(ctx context.Context, component components.Component, baseDir string) (*dirdiff.DiffResult, error)
}
SourcePreparer is a utility for acquiring and preparing all input files required to build a component. This may include the component's spec file, any loose files that must accompany it, any payload source archives and patches required by the spec, etc. Preparation may also include any post-processing of these inputs to match the component's configuration within the containing project.
func NewPreparer ¶
func NewPreparer( sourceManager sourceproviders.SourceManager, fs opctx.FS, eventListener opctx.EventListener, dryRunnable opctx.DryRunnable, ) (SourcePreparer, error)
NewPreparer creates a new SourcePreparer instance. All arguments are required.