Projects/KDE on Solaris/FOSS specfiles example1

< Projects‎ | KDE on Solaris
Revision as of 12:06, 8 December 2009 by SunTzuTech (talk | contribs) (minor update)
Jump to: navigation, search

Writing conditional Spec files

In general, the reason for writing a conditional spec file is so that you don't have to rely on a CMS system to figure out which version of a module you want to check out. Like tke KDE4 on Solaris project, there are several hundred spec files and easily double that in support files (once all the DUDE tarfile conversions are completed) so trying to go back a rev can be rather painful. This wiki attempts to clearly document the ease in which this can be handled.

Philosophy

FOSS spec files care about src_ver or version
explicit plists are used to catch differences between package revisions
every decision should be based on a simple true/false decision.
we don't want to maintain too many revisions internally to the spec, just enough to go back easily if something breaks, so current, and last working (or 2) is really all we want to support. Otherwise, you have to be something of a mercurial guru to figure out how to get back the last working version.

Header, self explanatory

  1. SPEC file for expat library.
  2. Copyright 2009 Ben Taylor
  3. Copyright 2008 Lukas Oboril
  4. Copyright 2008 Adriaan de Groot
  5. Copyright 2008 Stefan Teleman
  6. This file is released under the terms of an MIT / 1-clause BSD
  7. license. See the file LICENSE.MIT for details.
  8. Expat is a GNU library for xml parsing

Package definition

src_ver is the variable that defines the package source version

  1. Support expat-2.0.0 and 2.0.1. 2.0.1 now default.

%define src_name expat

  1. %define src_ver 2.0.0

%define src_ver 2.0.1 Name:  %{src_name} Version:  %{src_ver} SUNW_Pkg: FOSS%{name} %define src_rev 2

Summary: XML parser library License: MIT Source:  %{site_sourceforge}/expat/%{src_name}-%{src_ver}.tar.gz Url: http://expat.sf.net/ Group: System/Libraries

%description Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags).

versioning conditional defines

%define is_ver_2_0_0  %( test %{src_ver} = "2.0.0" && echo 1 || echo 0) %define is_ver_2_0_1  %( test %{src_ver} = "2.0.1" && echo 1 || echo 0)

during development, it's possible that we could iterate through several versions. These versions will likely be important to the base-<module>.spec file, since the intention is to keep patches as history, and use the version test to manage them. Again, we really ought to keep no more than 1 working, and 2 previous versions, otherwise the clutter will become a bit difficult to deal with.

On a project like KDE4 on Solaris, there are so many working parts, being about to back rev a module quickly has really been useful.

In the case where we need to test a package minor rev greater than, equal to 1, we can do the following:

%define expat_minor_rev  %( echo %{src_ver} | cut -f3 -d\. ) %define expat_rev_ge_2_0_1  %( test ${expat_minor_rev} -ge 1 && echo 1 || echo 0)

collection of standard includes use for the KDE4 project

%include base-foss-header.inc %include foss-paths.inc

%include foss-common32.inc %use base32 = base-expat.spec %if %has64 %include foss-common64.inc %use base64 = base-expat.spec %endif

%include base-foss-common.inc

the base-expat.spec is used for both 32-bit and 64-bit building, and on occasion, you'll find that some package didn't honor the .../lib/{amd64|sparcv9} construct, and you'll use the %install area to manually clean that up.

Explicit plist %files %dir %attr (0755, root, sys) /opt %dir %attr (0755, root, sys) %{_prefix} %defattr (-, root, bin) %dir %attr (0755, root, bin) %{_bindir} %{_bindir}/xmlwf

%dir %attr (0755, root, bin) %{_libdir} %{_libdir}/libexpat.so %{_libdir}/libexpat.so.1

How to use versions with explicit plists

Why use an explicit plist? As another example,ncurses-5.6. For 18 months, the plist was in place, explicitly defined. During the change to full spec, a minor change occured, rather unintentionally, and another set of libraries built which would have never been identified had a global plist been used.

Here, even a minor revision of the package generated a new minor revision of the shared library. Here we would use an explicit version test.

For a file such as an include file, we might use a %if %{expat_minor_ge_2_0_1} construct instead.

This model works good for the FOSS packages, but for the KDE4 modules, we've agreed that the library versioning will cause probably more churn in the spec files than is gained by having explicit versioning for those.

%if %{is_ver_2_0_0} %{_libdir}/libexpat.so.1.5.0 %endif

%if %{is_ver_2_0_1} %{_libdir}/libexpat.so.1.5.2 %endif

Explicit plist continued....

%dir %attr (0755, root, bin) %{_includedir} %{_includedir}/expat.h %{_includedir}/expat_external.h

%dir %attr (0755, root, sys) %{_datadir} %dir %attr (0755, root, bin) %{_mandir} %{_mandir}/man1/xmlwf.1

%if %{has64} %dir %attr (0755, root, bin) %{_bindir}/%{_arch64} %{_bindir}/%{_arch64}/xmlwf

%dir %attr (0755, root, bin) %{_libdir}/%{_arch64} %{_libdir}/%{_arch64}/libexpat.so %{_libdir}/%{_arch64}/libexpat.so.1 %if %{is_ver_2_0_0} %{_libdir}/%{_arch64}/libexpat.so.1.5.0 %endif %if %{is_ver_2_0_1} %{_libdir}/%{_arch64}/libexpat.so.1.5.2 %endif

%endif

%changelog

  • Tue Dec 1 2009 - bentaylor.solx86@gmail.com

- convrt to spec, add explicit plist - add upgrade to version 2.0.1

  • Wed Oct 1 2008 - groot@kde.org

- Turned back into a spec file

  • Thu Jan 17 2008 - oboril.lukas@gmail.com

- Initial version


Content is available under Creative Commons License SA 4.0 unless otherwise noted.