Skip to content

feat(overlays): add spec-remove-subpackage overlay#132

Open
reubeno wants to merge 2 commits intomicrosoft:mainfrom
reubeno:remove-subpackage-overlay
Open

feat(overlays): add spec-remove-subpackage overlay#132
reubeno wants to merge 2 commits intomicrosoft:mainfrom
reubeno:remove-subpackage-overlay

Conversation

@reubeno
Copy link
Copy Markdown
Member

@reubeno reubeno commented Apr 29, 2026

Adds a new overlay type that removes every section in a spec belonging to a given sub-package (its %package preamble plus any %description, %files, %post, %postun, etc. sections targeting it). This avoids having to author one spec-remove-section overlay per section just to drop a single sub-package, and removes the risk of missing scriptlets that upstream may add later.

The overlay requires the 'package' field and fails if the spec contains no sections matching the indicated sub-package.

Example:

[[components.mypackage.overlays]]
type = "spec-remove-subpackage"
package = "gui"
description = "Drop the gui sub-package; not shipped in Azure Linux"

Resolves #22

Adds a new overlay type that removes every section in a spec belonging
to a given sub-package (its %package preamble plus any %description,
%files, %post, %postun, etc. sections targeting it). This avoids having
to author one spec-remove-section overlay per section just to drop a
single sub-package, and removes the risk of missing scriptlets that
upstream may add later.

The overlay requires the 'package' field and fails if the spec contains
no sections matching the indicated sub-package.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 19:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new spec-remove-subpackage overlay type to remove an entire RPM sub-package from a spec (its %package preamble plus any sub-package-scoped sections), along with docs, schema updates, and test coverage to validate the behavior.

Changes:

  • Extend overlay type enums in the JSON schema and generated schema snapshots to include spec-remove-subpackage.
  • Implement Spec.RemoveSubpackage() and refactor section-removal logic to use shared range-collection helpers.
  • Wire the new overlay into config validation and overlay application, and add unit tests + documentation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
schemas/azldev.schema.json Adds spec-remove-subpackage to the overlay type enum in the schema.
scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap Updates generated-schema snapshot to include the new overlay type.
scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap Updates container snapshot to include the new overlay type.
internal/rpm/spec/edit.go Refactors removal logic and adds RemoveSubpackage() + shared section range helpers.
internal/rpm/spec/edit_test.go Adds spec-level tests covering sub-package removal and error cases.
internal/projectconfig/overlay.go Adds new overlay type constant, schema enum, validation, and ModifiesSpec inclusion.
internal/projectconfig/overlay_test.go Adds validation tests and updates ModifiesSpec test list.
internal/app/azldev/core/sources/overlays.go Applies the new overlay type by calling RemoveSubpackage().
internal/app/azldev/core/sources/overlays_test.go Adds integration-style tests for applying the overlay to spec contents.
docs/user/reference/config/overlays.md Documents the new overlay type, usage, and its %if/%endif limitation.

Comment thread internal/rpm/spec/edit.go
Comment thread internal/rpm/spec/edit.go
- collectSectionRanges: add defensive EOF fallback so a section that
  runs to EOF without a trailing SectionEndTarget is still collected.
  Today this is unreachable (Visit always emits the trailing
  SectionEndTarget), but it restores parity with the prior
  RemoveSection implementation and decouples this helper from a
  Visit invariant.
- RemoveSection: clarify in the doc comment that all matching
  sections are removed, not just the first. In valid specs the
  identity pair is unique so this is invisible, but the explicit
  semantics matter for specs that lexically duplicate a section
  across mutually-exclusive %if/%else branches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@Tonisal-byte Tonisal-byte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

need a way to completely disable/remove entire subpackages

3 participants