Skip to content

patch-add overlay appends PatchN: tag at end of preamble instead of grouping with existing Patch tags #284

Description

@liunan-ms

Summary
When the patch-add overlay adds a patch to a spec that has no %patchlist section, the new PatchN: tag is appended at the very end of the preamble (just before %description) rather than being placed alongside the existing Patch/PatchN tags. This produces valid but awkwardly-placed output.

Example
For libsolv.spec, which has an upstream Patch: tag near the top of the preamble, running the patch-add overlay:

[[components.libsolv.overlays]]
description = "Make file time available for dnf plugins, a prerequisite for virtual snapshots"
type = "patch-add"
source = "0002-Make-file-time-available-for-dnf-plugins.patch"

inserts Patch1: at ~L92 (after the %if %{with zchunk}...%endif BuildRequires block, immediately before %description), instead of next to the existing Patch: tag at ~L70.

Root cause

  • The patch-add overlay calls Spec.AddPatchEntry (edit.go:653).
  • When there is no %patchlist section, it falls back to AddTag(...) (edit.go:172).
  • AddTag calls AppendLinesToSection, which always inserts at the end of the section (edit.go:473).

Acceptance criteria

  • New patches added via patch-add are placed next to existing Patch/PatchN tags. (cosmetic change)
  • Specs with a %patchlist section continue to append there.
  • Specs with no existing patch tags behave as today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions