Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions docs/user/reference/cli/azldev_component_query.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions internal/app/azldev/cmds/component/mockproc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package component

// Required-package presets for the shared MockProcessor.
//
// Render needs rpmautospec (macro expansion), rpmdevtools (spectool), and git
// (required for rpmautospec to read commit history). python3-click is required
// by rpmautospec but not declared as an RPM dependency. Ecosystem macro
// packages (go-srpm-macros, etc.) are already present via @buildsys-build →
// azurelinux-rpm-config.
//
// Query needs rpm-build for the `rpmspec` binary. It's typically already
// pulled in via @buildsys-build, but we install it explicitly so we don't
// depend on a particular buildgroup composition.
func mockPackagesForRender() []string {
return []string{"rpmautospec", "rpmdevtools", "git", "python3-click"}
}

func mockPackagesForQuery() []string {
// rpm-build provides rpmspec; python3 is needed to run query_process.py.
// (The render path gets python3 transitively via python3-click, but the
// query path doesn't install rpmautospec/python3-click.)
//
// Additional macro packages are installed so that build-time macros
// affecting %files / %package expansion (and therefore --builtrpms
// output) resolve during rpmspec parsing. Without these, --builtrpms
// under-reports subpackages for specs that generate their %files
// sections via macros, or that use macros like %pyproject_extras_subpkg
// to emit whole subpackage stanzas at parse time.
//
// Curated list of common macro packages that emit %package / %files in
// the Azure Linux spec corpus:
// * fonts-rpm-macros — %fontfiles, %fontfamily_subpkg, etc.
// * pyproject-rpm-macros — %pyproject_extras_subpkg
// * java-srpm-macros, javapackages-tools, javapackages-common —
// %mvn_package, %mvn_install,
// %javadoc_package (auto
// -javadoc subpackages, from
// macros.fjava in
// javapackages-common),
// jp_minimal bcond default.
// javapackages-common is
// normally pulled in via
// javapackages-tools, but we
// install it explicitly so
// %javadoc_package never
// silently disappears.
// * ghc-rpm-macros — %ghc_lib_subpackage and ghc_prof/haddock
// bcond defaults. Requires
// query_process.py to prime
// _ghc_version_cache so the macros don't
// shell out to a `ghc` binary that isn't
// installed in the chroot.
//
// We install `java-srpm-macros` (the actual binary RPM) rather than
// `java-rpm-macros`, which is the SRPM name; the latter has no
// `%files` section for the main package and is not a buildable binary.
//
// Macros that only affect %prep/%build/%install (e.g. %cargo_install,
// %py3_build) don't need to be added — they don't change which binary
// RPMs would be built.
return []string{
"rpm-build",
"python3",
"fonts-rpm-macros",
"pyproject-rpm-macros",
"java-srpm-macros",
"javapackages-tools",
"javapackages-common",
"ghc-rpm-macros",
}
}
17 changes: 13 additions & 4 deletions internal/app/azldev/cmds/component/mockprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const mockProcessorCleanupTimeout = 5 * time.Minute
// different per-component upstream distro, which must not select the build
// chroot. Returns nil when the project mock config is unavailable.
func createMockProcessor(env *azldev.Env) *sources.MockProcessor {
return newMockProcessor(env, "")
return newMockProcessor(env, "", mockPackagesForRender())
}

// createQueryMockProcessor creates a [sources.MockProcessor] with the packages
// needed for querying specs.
func createQueryMockProcessor(env *azldev.Env) *sources.MockProcessor {
return newMockProcessor(env, "", mockPackagesForQuery())
}

// createBuildMockProcessor creates a [sources.MockProcessor] for the build
Expand All @@ -42,14 +48,16 @@ func createBuildMockProcessor(env *azldev.Env) *sources.MockProcessor {
isolatedBaseDir = filepath.Join(workDir, buildProvenanceMockSubdir)
}

return newMockProcessor(env, isolatedBaseDir)
return newMockProcessor(env, isolatedBaseDir, mockPackagesForRender())
}

// newMockProcessor resolves the project/build distro mock config and builds a
// [sources.MockProcessor]. When isolatedBaseDir is non-empty, the processor's
// mock root lives under it instead of mock's shared default location. Returns
// nil when the project mock config is unavailable.
func newMockProcessor(env *azldev.Env, isolatedBaseDir string) *sources.MockProcessor {
func newMockProcessor(
env *azldev.Env, isolatedBaseDir string, requiredPackages []string,
) *sources.MockProcessor {
_, distroVerDef, err := env.Distro()
if err != nil {
slog.Info("Mock processor unavailable; could not resolve project distro", "error", err)
Expand All @@ -67,7 +75,8 @@ func newMockProcessor(env *azldev.Env, isolatedBaseDir string) *sources.MockProc
"mockConfig", distroVerDef.MockConfigPath, "isolatedBaseDir", isolatedBaseDir)

return sources.NewMockProcessor(env, distroVerDef.MockConfigPath,
sources.WithIsolatedMockBaseDir(isolatedBaseDir))
sources.WithIsolatedMockBaseDir(isolatedBaseDir),
sources.WithRequiredPackages(requiredPackages...))
}

// destroyMockProcessor scrubs the mock chroot at a command boundary. It detaches
Expand Down
Loading
Loading