Skip to content

RPM spec parser mis-attributes %trigger* -- <trigger> sections to a sub-package #143

@reubeno

Description

@reubeno

Drafted by GitHub Copilot CLI while reviewing PR #132.

In RPM trigger syntax, -- separates the trigger's owning sub-package (or no sub-package, meaning the main package) from the trigger condition (the package whose state change fires the scriptlet). For example:

  • %triggerin -- foo — owned by main package, fires when foo changes
  • %triggerin -n test-devel -- foo — owned by test-devel sub-package, fires when foo changes
  • %triggerin devel -- foo — owned by devel sub-package (suffix form), fires when foo changes

GetPackageNameFromSectionHeader (in internal/rpm/spec/spec.go) does not recognize --. It falls through default: index++, leaving the trigger condition to be picked up as the package name suffix.

Reproduction

GetPackageNameFromSectionHeader([]string{"%triggerin", "--", "devel"})
// returns: "devel"
// expected: ""  (main package; trigger condition "devel" is not the owner)

Impact

Affects spec-remove-section and spec-remove-subpackage. For a spec with %triggerin -- devel declared on the main package, RemoveSubpackage("devel") will incorrectly remove the main-package trigger.

This is not net-new behavior introduced by PR #132; it was latent and surfaced by the new overlay.

Proposed fix

Treat -- as a terminator in GetPackageNameFromSectionHeader: stop scanning for the package suffix once -- is encountered. Anything after -- is the trigger condition, not the owning sub-package.

Add fixture tests for %triggerin -- devel, %triggerin devel -- foo, and %triggerin -n test-devel -- foo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: overlaysOverlay system: spec and file modifications driven by TOML declarationsbugSomething isn't workinggoPull requests that update go code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions