feat(sources): add opt-in %fedora_upstream_* provenance macros (replaces #285)#290
Open
liunan-ms wants to merge 1 commit into
Open
feat(sources): add opt-in %fedora_upstream_* provenance macros (replaces #285)#290liunan-ms wants to merge 1 commit into
liunan-ms wants to merge 1 commit into
Conversation
Add a build.emit-upstream-provenance flag that, for Fedora upstream components, injects %fedora_upstream_version and %fedora_upstream_release macros into the component's generated macros file. Values are read from the pristine upstream Fedora spec on disk (before overlays) and the Release tag's %{?dist} is expanded to the resolved Fedora dist tag. Nothing is stored in the lock file; the macros are derived fresh at render/build time from the pinned upstream commit. Opt-in so only components that reference the macros (e.g. grub2 SBAT) get a macros file. User-defined macros of the same name win.
liunan-ms
force-pushed
the
liunan/fedora_upstream_macros
branch
from
July 15, 2026 22:37
032907a to
881674c
Compare
liunan-ms
marked this pull request as ready for review
July 16, 2026 00:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR supports azldev emits
%fedora_upstream_versionand%fedora_upstream_releasemacros for Fedora upstream components that opt in via a newbuild.emit-upstream-provenanceflag. Values are read from the pristine upstream Fedora spec on disk (before overlays are applied) and the Release tag's%{?dist}token is expanded to the resolved Fedora dist tag (e.g..fc43). The macros are surfaced through the component's existing generated macros file.This is a replacement for #285 ("capture upstream version/release provenance and expose
%azl_upstream_*macros"). That PR stored the version and release in the per-component lock file and derived the macros at build time from the lock. This PR takes a different, simpler approach.Closed #285.
Advantages over #285
component update→ store in lockfile → read at render/buildupstream-name,upstream-epoch,upstream-version,upstream-release)updatecommandhasLockedUpstreamVersionReleasegateSourceIdentityplumbingResolveIdentity/ResolveSourceIdentitysignature change threaded through Fedora, RPM, and local providersgit show <commit>:<name>.specper component during identity resolution.azl.macrosfileupdaterun%azl_upstream_*%fedora_upstream_*(explicit about the source)Design
sources.WithUpstreamProvenance(distTag string)onSourcePreparer.distTagis the resolved%{?dist}expansion (FedoraDistTag(distroName, releaseVer)returns.fc<N>for Fedora,""otherwise, disabling the feature).writeMacrosFile(in the pre-overlay window). The pristine spec exists on disk right afterFetchComponent, before overlays rewrite it.parseSpecVersionReleasereads Version/Release verbatim via the existingspec.VisitTagsPackagepath; only%{?dist}is substituted.build.emit-upstream-provenance = truein[components.<name>.build]. Fingerprintable — flipping it changes rendered output. Registered with thecomponent historycollector.build.defineswins (macros are layered viasetMacroIfAbsent)..azl.macros+%{load:%{_sourcedir}/...}+Source9999path. No second mechanism.spec.type = upstream. Local, SRPM, and non-Fedora upstream components are skipped, so the flag is a no-op for them.WARNis logged and the macros are skipped; render/build proceeds without them.Consumer example (grub2 SBAT)
An accompanying comp.toml change in the azurelinux repo enables the flag and adds a spec-search-replace overlay:
Result: the built
sbat.csv'sgrub.rhline carries the pristine upstream Fedora NEVR (e.g.grub.rh,2,Red Hat,grub2,2.12-45.fc43,...) instead of the AZL build V-R (…azl4).Testing
mage unit— passing (7 new tests cover happy path, opt-out, local skip, non-Fedora skip, user-define wins, missing spec best-effort, empty release, and dist-tag mapping).mage check all— passing (linting, static analysis, license, schema).mage docsregenerated the JSON schema for the new field.grub2build succeeded and the SBAT overlay is verified working using command:Both EFI binaries (x64 and ia32) carry identical SBAT data:
Fix AB#12798
Limitations (documented)
%{?dist}is expanded. A tag built from other macros (e.g.Version: %{majorver}.%{minorver}) is captured with those macros unexpanded.fedora_upstream_version/_releaseinbuild.undefinesdoes not suppress the injected macros. Useemit-upstream-provenance = false(or omit it) instead.