[Rpm-maint] [draft] spec file unification: autotools based projects
Stanislav Brabec
sbrabec at suse.cz
Thu Jul 17 15:09:28 UTC 2008
Hallo.
Because the discussion on spec file unification de-facto not yet
started, I would like to start it with probably the least problematic
part: autotools based projects. Even there is a lot of things to
discuss.
Packaging autotools based projects - spec file template (draft 1)
These conventions should require modification of macro sets for all
distributions, to provide a standardized way to build packages.
Preamble
It is expected, that implicit BuildRequires already include all standard
autotools packages - automake, autoconf, libtool. It is preferred to use
the latest version of these tools to build packages.
Open topics:
Should be BuildRoot implicit?
Preparing
The standard %setup macro should unpack these packages in convenient
way:
%prep
%setup -q
Configuration and compilation
%build
Packagers are encouraged to call autoreconf whenever possible. It
guarantees correct build of packages on platforms, that was not
supported by autotools in the time of the source release.
autoreconf -f -i
Setting CFLAGS and CXXFLAGS is already included in the macro %configure,
so it is not mandatory here. Use it only if you want to diverge from
standard flags:
export CFLAGS="$RPM_OPT_FLAGS additional flags" # optional
The same is valid for other flags.
The main configuration should be done by a simple use of %configure
macro. it should include all standard arguments.
%configure
Only additional arguments and non standard defaults should be
specified:
%configure\
<-Tab-->--libdir=%{_libdir}/my_project_libs\
<-Tab-->--enable-static\
Notes and open discussion:
%{_lib}: This macro should be defined and should be equal to trailing
part of the %{_libdir} (e. g. "lib" or "lib64").
--libdir:
--libdir argument should use %{_libdir} or %{_lib} and it should never
include "/lib" explicitly. It is a requirement for bi-arch
distributions.
--libexecdir:
--libexecdir argument should be based on %{_prefix}. It should not
contain %{_libdir} nor %{_lib}. It is a requirement for distributions
providing supplementary bi-arch library packages.
Open topics:
Should /usr/libexec be allowed?
Which should be the default included into %configure? The best value is
probably:
--libexecdir=%{_prefix}/lib/%{name}
--docdir:
--docdir is a new directory defined only in the latest autotools. That
is why it is not possible to include it to %configure yet (or even
better do a check and make it optionally).
There is still a problem with the default, which is distro specific:
%{_docdir}/...part of path based on %{name}...
I would propose new path, which should define complete target:
%{_docpath}
Typical value of %_docpath should be %{_docdir}/%{name} or
%{_docdir}/%{name}-%{version}.
For compilation, I would propose to define new macro:
%make
In difference to %__make, it should include all default build flags,
including optional parallel build.
Open topics:
How to build non-parallel make? Should we usr %__make or define
%make_sequential, which include all possible default build flags except
flags for parallel build.
Installation
%install
Installation should not start by removing install-root, as it opens a
race condition security hole. RPM should handle it correctly.
%makeinstall
This mactro should perform standard "make install DESTIR=...".
Open topics:
This breaks backward compatibility. But nowadays, there is only a
minimal number of project, that still depend on using the old-style way,
which is broken by design.
So I would prefer defining of %makeinstall in above mentioned way and
introduce %makeinstall_old using the old-style way.
The number of affected packages should be low.
File lists
%files
File lists should use %{_libdir}, %{_docdir} wherever it is relevant
(i. e. if the path is based on value provided by %configure).
SUID and SGID binaries has to use correct attributes, so it could bw
built correctly as user, independently on fakeroot or similar technique.
Bonus:
Attached script changes all references to %{_libdir} form. It is far
from being perfect, but it helps a bit.
It ignores %{_prefix}/lib, because there is not clean, whether it is
%{_libexecdir} or whether it is non-portable instance of %{_libdir}.
----------- spec-paths.sh --------------
#! /bin/sh
sed -i '
# use /^%files/,/^%changelog/ for file list only
1,/^%changelog/ {
s:%_bindir:%{_bindir}:g
s:%prefix/bin:%{_bindir}:g
s:%{prefix}/bin:%{_bindir}:g
s:%_prefix/bin:%{_bindir}:g
s:%{_prefix}/bin:%{_bindir}:g
s:/usr/bin:%{_bindir}:g
s:%_sbindir:%{_sbindir}:g
s:%prefix/sbin:%{_sbindir}:g
s:%{prefix}/sbin:%{_sbindir}:g
s:%_prefix/sbin:%{_sbindir}:g
s:%{_prefix}/sbin:%{_sbindir}:g
s:/usr/sbin:%{_sbindir}:g
s:%_libdir:%{_libdir}:g
s:%prefix/%_lib:%{_libdir}:g
s:%{prefix}/%_lib:%{_libdir}:g
s:%_prefix/%_lib:%{_libdir}:g
s:%{_prefix}/%_lib:%{_libdir}:g
s:/usr/%_lib:%{_libdir}:g
s:%prefix/%{_lib}:%{_libdir}:g
s:%{prefix}/%{_lib}:%{_libdir}:g
s:%_prefix/%{_lib}:%{_libdir}:g
s:%{_prefix}/%{_lib}:%{_libdir}:g
s:/usr/%{_lib}:%{_libdir}:g
s:%_includedir:%{_includedir}:g
s:%prefix/include:%{_includedir}:g
s:%{prefix}/include:%{_includedir}:g
s:%_prefix/include:%{_includedir}:g
s:%{_prefix}/include:%{_includedir}:g
s:/usr/include:%{_includedir}:g
s:%_sysconfdir:%{_sysconfdir}:g
s:/etc:%{_sysconfdir}:g
s:%_localstatedir:%{_localstatedir}:g
s:/var:%{_localstatedir}:g
s:%_datadir:%{_datadir}:g
s:%prefix/share:%{_datadir}:g
s:%{prefix}/share:%{_datadir}:g
s:%_prefix/share:%{_datadir}:g
s:%{_prefix}/share:%{_datadir}:g
s:/usr/share:%{_datadir}:g
s:%_mandir:%{_mandir}:g
s:%prefix/share/man:%{_mandir}:g
s:%{prefix}/share/man:%{_mandir}:g
s:%_prefix/share/man:%{_mandir}:g
s:%{_prefix}/share/man:%{_mandir}:g
s:%datadir/man:%{_mandir}:g
s:%{datadir}/man:%{_mandir}:g
s:%_datadir/man:%{_mandir}:g
s:%{_datadir}/man:%{_mandir}:g
s:/usr/share/man:%{_mandir}:g
s:%_infodir:%{_infodir}:g
s:%prefix/share/info:%{_infodir}:g
s:%{prefix}/share/info:%{_infodir}:g
s:%_prefix/share/info:%{_infodir}:g
s:%{_prefix}/share/info:%{_infodir}:g
s:%datadir/info:%{_infodir}:g
s:%{datadir}/info:%{_infodir}:g
s:%_datadir/info:%{_infodir}:g
s:%{_datadir}/info:%{_infodir}:g
s:/usr/share/info:%{_infodir}:g
s:%_prefix:%{_prefix}:g
s:%prefix:%{_prefix}:g
s:%{prefix}:%{_prefix}:g
s:%_prefix:%{_prefix}:g
s:/usr:%{_prefix}:g
}
' *.spec
-----------------------------------------
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec at suse.cz
Lihovarská 1060/12 tel: +420 284 028 966, +49 911 740538747
190 00 Praha 9 fax: +420 284 028 951
Czech Republic http://www.suse.cz/
More information about the Rpm-maint
mailing list