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.
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 whenfoochanges%triggerin -n test-devel -- foo— owned bytest-develsub-package, fires whenfoochanges%triggerin devel -- foo— owned bydevelsub-package (suffix form), fires whenfoochangesGetPackageNameFromSectionHeader(ininternal/rpm/spec/spec.go) does not recognize--. It falls throughdefault: index++, leaving the trigger condition to be picked up as the package name suffix.Reproduction
Impact
Affects
spec-remove-sectionandspec-remove-subpackage. For a spec with%triggerin -- develdeclared 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 inGetPackageNameFromSectionHeader: 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.