From Fedora Project Wiki

(Disallow unexpanded macros in SRPMs)
 
m (Explain the issue)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
All macros in <code>Summary:</code> and <code>%description</code> need to be expandable at srpm buildtime.  Because SRPMs are built without the package's BuildRequires installed, depending on macros defined outside of the spec file can easily lead to this issue.  One way to check is to create a minimal chroot and build the srpm:
All macros in <code>Summary:</code> and <code>%description</code> need to be expandable at srpm buildtime.  Because SRPMs are built without the package's BuildRequires installed, depending on macros defined outside of the spec file can easily lead to the unexpanded macros showing up in the built SRPM.  One way to check is to create a minimal chroot and build the srpm:


<pre>
<pre>
Line 5: Line 5:
mock --copyin [SRPM] /
mock --copyin [SRPM] /
mock --shell bash
mock --shell bash
rpm -ivh [SRPM]
cd /builddir/build/SPECS
rpmbuild -bs --nodeps [SRPM]
rpmbuild -bs --nodeps [SRPM]
rpm -qpiv [SRPM]
rpm -qpiv /builddir/build/SRPMS/[SRPM]
</pre>
</pre>
Check the <code>rpm</code> output for unexpanded macros (<code>%{foo}</code>) or missing information (when<code>%{?foo}</code> is expanded to the empty string).  Even easier is to simply avoid macros in <code>Summary:</code> and <code>%description</code> unless they are defined in the current spec file.
Check the <code>rpm</code> output for unexpanded macros (<code>%{foo}</code>) or missing information (when<code>%{?foo}</code> is expanded to the empty string).  Even easier is to simply avoid macros in <code>Summary:</code> and <code>%description</code> unless they are defined in the current spec file.
[[Category:Packaging guidelines drafts]]

Latest revision as of 15:15, 4 February 2010

All macros in Summary: and %description need to be expandable at srpm buildtime. Because SRPMs are built without the package's BuildRequires installed, depending on macros defined outside of the spec file can easily lead to the unexpanded macros showing up in the built SRPM. One way to check is to create a minimal chroot and build the srpm:

mock --init
mock --copyin [SRPM] /
mock --shell bash
rpm -ivh [SRPM]
cd /builddir/build/SPECS
rpmbuild -bs --nodeps [SRPM]
rpm -qpiv /builddir/build/SRPMS/[SRPM]

Check the rpm output for unexpanded macros (%{foo}) or missing information (when%{?foo} is expanded to the empty string). Even easier is to simply avoid macros in Summary: and %description unless they are defined in the current spec file.