Skip to content

RPM spec parser mis-attributes %description -l <lang> <pkg> sections #142

@reubeno

Description

@reubeno

Drafted by GitHub Copilot CLI while reviewing PR #132.

internal/rpm/spec/spec.go::GetPackageNameFromSectionHeader does not handle the -l (language) flag pair. It falls through the default: index++ arm in the option switch, which consumes -l but not its argument. The argument is then incorrectly picked up as the package name suffix.

Reproduction

GetPackageNameFromSectionHeader([]string{"%description", "-l", "fr", "devel"})
// returns: "fr"
// expected: "devel"

Impact

Affects every overlay that relies on the parser's package classification, including the existing spec-remove-section overlay and the new spec-remove-subpackage overlay (PR #132). For a sub-package with a localized description, RemoveSubpackage("devel") will remove the main %package devel and English %description devel but leave behind %description -l fr devel, producing a spec that references a sub-package whose preamble is gone — an invalid build.

This is not net-new behavior introduced by PR #132; it was latent in GetPackageNameFromSectionHeader and surfaced by the new overlay's whole-sub-package semantics.

Proposed fix

Add -l to the option-pair switch in GetPackageNameFromSectionHeader so it consumes both the flag and its language argument:

case "-l":
    index += 2

Add fixture tests for %description -l fr devel and %description -l fr -n test-devel.

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