Specs
From Rpm5 info
Please don't take this as gospel until we get a reasonable level of consensus.
Sample m4 spec and some random post-spec commentary:
# This shows how to augment an existing RPM macro
%{expand:%%define optflags %optflags -Wall}
# Make it so that one can conditionally run "make pdf"
%bcond_with pdfdoc
Name: m4
Version: 1.4.10
Release: 2
Summary: An implementation of the traditional UNIX macro processor
Group: Applications/Text
License: GPLv3+
URL: http://www.gnu.org/software/%{name}/
Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2
Source1: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2.sig
Source2: http://home.comcast.net/~ericblake/eblake.gpg
# Ordinarily one might expect to see the following:
# BuildRoot: %{_tmppath}/%{name}-root
# However this is now automatically defined by RPM
# See the buildroot definition in %{_usrlibrpm}/macros for further details
# If --define with_pdfdoc was passed to rpmbuild we need to add a build
# requirement on the tetex package, which is demonstrated here
%{?with_pdfdoc:BuildRequires: tetex}
# Here we verify the tarball (SOURCE0) using the signature (SOURCE1),
# public key (SOURCE2), and a sha1 sum of the public key
BuildRequires: signature(%{SOURCE0}:%{SOURCE1}) = %{SOURCE2}:33cebc0b72cc17cc40b1c1feb3788fd7e6749cff
Requires(post): info-install
Requires(preun): info-install
%description
GNU %{name} is an implementation of the traditional UNIX macro processor.
It is mostly SVR4 compatible, although it has some extensions (for
example, handling more than 9 positional parameters to macros).
%{name} also has builtin functions for including files, running shell
commands, doing arithmetic, etc.
# With the track stanza "rpmbuild -bt m4.spec" will tell you if the version
# in this file is the most current version of the GNU m4 program
# The vcheck program can be found at: %{_usrlibrpm}/vcheck
%track
prog %{name} = {
version = %{version}
url = ftp://ftp.gnu.org/gnu/%{name}/
regex = %{name}-(__VER__)\.tar\.bz2
}
%prep
%setup -q
%build
%configure
%make # Simple macro for: %{__make} %{?_smp_flags}
%install
# Ordinarily one might expect to see a "rm -rf $RPM_BUILD_ROOT" here,
# however this is now automatically done by RPM in the install stanza
# See the __spec_install_pre definition in %{_usrlibrpm}/macros for
# further details
%makeinstall_std # Simple macro for:
# %make DESTDIR="$RPM_BUILD_ROOT" install
# Here we test to see if --define with_pdfdoc was used with rpmbuild
%{?with_pdfdoc:%make_std pdf}
%check
%make check
%post
%_install_info %{name}.info # Simple macro for:
# %{__install_info} \
# %{_infodir}/%{name}.info \
# %{_infodir}/dir || :
%preun
%_remove_install_info %{name}.info
%clean
# Ordinarily one might expect to see a "rm -rf $RPM_BUILD_ROOT" here
# however this is now automatically done in the clean stanza
# See the __spec_clean_body definition in %{_usrlibrpm}/macros for details
%files
%doc AUTHORS BACKLOG ChangeLog NEWS README THANKS TODO
# Here we conditionally include the generated PDF as a doc file based on whether
# --define with_pdfdoc was used with rpmbuild
%{?with_pdfdoc:%doc doc/%{name}.pdf}
%{_bindir}/%{name}
%{_infodir}/%{name}.info%{_extension}
%changelog
* Sat Feb 2 2008 Per Øyvind Karlsen <pkarlsen@rpm5.org> 1.4.10-2
- Add back changelog, even if better changelog is wished for, keeping
a changelog and pretending for it to be a real package will make
it easier to keep track of things in stead of unorganized discussions at bottom
- Drop %{_exeext} for now, unless we want to do a win32 port, this isn't of much use
and adds extra confusion and obscurity to most.
- Drop COPYING from package as we'd rather move all licenses which allows it to a common-licenses
package to avoid redundancy of a gazillion copies of same licenses
- change require to small 'info-install' subpackage rather than 'info' to avoid dependency on larger texinfo package
* Sun Jan 20 2008 Per Øyvind Karlsen <pkarlsen@rpm5.org> 1.4.10-1
- Added some personal/Mandriva derived touch:
o indentation
o macroization
o add changelog
- add %check stage
- comment out some stuff that's not needed or can be done in better ways
- various comments and potentially biasism, improve what's not perfect! :)
The indentation I adopted from OpenPKG's style as it is a stone's throw from YAML.
- Might be interesting to compare with the "original" m4.spec : http://cvs.openpkg.org/fileview?f=openpkg-src/m4/m4.spec (note that OpenPKG doesn't use %files nor %changelog, the first is autogenerated to a file and the second is kept in CVS instead...)
What's important to note is not only what is new but also what isn't present. This spec is likely to be more comments than macros... Remember that this is a showcase of sorts, and thus we also need to explain why we've done (or not done) something.
Lots more stuff needed, auto-source-fetching, %sanitytest, etc.
For macros derived from Mandriva it's probably a good idea to keep them the same as they already exist and makes it easier to share efforts. Otherwise I think that the Mandriva packaging policies can be a good thing to base ourself on, not blindly though, improve and/or drop what isn't optimal.
Macro issues currently:
- %make evaluates to %{__make} in rpm5, not %{__make} %{?_smp_flags}
- apparently this is a good thing, since the conservative approach is having make -j "opt-in"
- %makeinstall already exists, perhaps better to fiddle it than create %makeinstall_std
- %{_install_info}, %{_remove_install_info}, %makeinstall_std, and %{_extension} do not exist in rpm5 macros
- %{_extension} seems like it should be %{__infoext} to be more consistent with %{__exeext}
- %{__exeext} and %{__shlibext} were named after the autoconf variables with the same names
