mirror of
https://github.com/goreleaser/nfpm
synced 2026-08-22 06:44:17 +02:00
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>
8 lines
297 B
Bash
8 lines
297 B
Bash
#!/bin/bash
|
|
|
|
# The longest-suffix-strip idiom must survive `rpmbuild --rebuild` verbatim.
|
|
# Without %-escaping in the generated spec, ${host%%.*} is silently mangled to
|
|
# ${host%.*}, which strips the shortest suffix instead of the longest.
|
|
host="server.example.com"
|
|
echo "${host%%.*}" > /dev/null
|