Files
d20c0c9937 fix(rpm): escape % in generated SRPM spec so scriptlets survive rebuild (#1109)
User content (scriptlets, %description, summary, file paths and changelog)
was inlined verbatim into the generated .spec file. rpmbuild reinterprets %
when the SRPM is rebuilt: %% collapses to a single %, %{macro} expands, and
%(command) executes at build time. The common longest-suffix-strip idiom
${VAR%%.*} silently became ${VAR%.*} (shortest suffix) in install scriptlets,
with no warning.

Double every % in user-controlled spec text via escapeSpecText so rpmbuild
restores it literally on rebuild. Binary RPMs are unaffected -- their
scriptlets go straight into header tags with no spec parsing -- so this is
scoped to the SRPM path.

Add a unit test asserting the escaped output, and extend the srpm rebuild
acceptance test with a ${host%%.*} scriptlet that must survive the real
rpmbuild --rebuild.

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:48:34 -03:00

39 lines
786 B
YAML

name: "foo"
arch: "${BUILD_ARCH}"
platform: "linux"
version: "v1.2.3"
maintainer: "Foo Bar <foo@bar.com>"
release: "4"
epoch: "1"
description: |
Foo bar
Multiple lines
vendor: "foobar"
homepage: "https://foobar.org"
license: "MIT"
depends:
- bash
provides:
- foo-tool
contents:
- src: ./testdata/fake
dst: /usr/bin/fake
- src: ./testdata/whatever.conf
dst: /etc/foo/whatever.conf
type: config|noreplace
- src: ./testdata/fake
dst: /usr/share/doc/foo/README
type: doc
- dst: /var/log/whatever
type: dir
- src: /usr/bin/fake
dst: /usr/bin/fake-link
type: symlink
- dst: /var/lib/foo/state
type: ghost
scripts:
postinstall: ./testdata/scripts/srpm-rebuild-postinstall.sh
rpm:
group: "Application/Misc"
summary: "foo summary"