The LSB package format, which is the RPM format, is described in Chapter 22 of the LSB specification.
One way to construct a conforming package is to use the rpmbuild command available on Linux distributions using rpm, and optionally available on certain other distributions as well. Here are some hints for helping construct packages in this way.
The file which controls the operation of rpmbuild is known as the "spec" file. This file contains instructions for the command. A well-known resource for understanding the behavior of rpmbuild as a build tool is the RPM Guide. See in particular Chapter 8, Creating RPMs.
LSB-conforming RPM packages are restricted in certain ways. An important restriction is in package dependencies. The LSB specification makes these two statements:
Packages shall have a dependency that indicates which LSB modules are required. LSB module descriptions are dash separated tuples containing the name 'lsb', the module name, and the architecture name.
Packages shall not depend on other system-provided dependencies. They shall not depend on non-system-provided dependencies unless those dependencies are fulfilled by packages which are part of the same application. A package may only provide a virtual package name which is registered to that application.
For LSB 3.1, the single dependency "lsb" serves as a meta-dependency, eliminating the need for individual module dependencies (these are legal, but deprecated - see the Desktop specification.
In order to meet this requirement, rpmbuild should not be allowed to auto-generate dependencies. The spec file directives to get the behavior we want would be:
AutoReqProv: no PreReq: lsb >= 3.1
You can also fine-tune the requirements to a subset of the full LSB, say "lsb-core-ia32" for example. To implement this type of dependency you can use something like this in the .spec file:
# LSB dependency section %ifarch i386 i486 i586 i686 athlon PreReq: lsb-core-ia32 >= 3.0 %endif %ifarch ia64 PreReq: lsb-core-ia64 >= 3.0 %endif %ifarch ppc PreReq: lsb-core-ppc32 >= 3.0 %endif %ifarch ppc64 PreReq: lsb-core-ppc64 >= 3.0 %endif %ifarch s390 PreReq: lsb-core-s390 >= 3.0 %endif %ifarch s390x PreReq: lsb-core-s390x >= 3.0 %endif %ifarch x86_64 PreReq: lsb-core-amd64 >= 3.0 %endif
LSB packages should be built with the lsbcc or lsbc++ tool. If the package to be built uses a GNU autoconf script, the script should be executed using this as the compiler as well, so that the configuration checks are performed using the same build environment that the package will be built with.
The package should be configured to install all the package files into the FHS approved path, using a LANANA approved package or provider name.. In short, this is
/opt/provider, with matching directories available under
Additional details on rules that apply to package construction, pathnames, and installation considerations are found in the LSB Core specification, Section VI, Execution Environment, Section VII, System Initialization, and Section VIII, Users and Groups. An example of the last two points using a configure script:
%build CC=lsbcc export CC ./configure --prefix=/opt/lsb-foo
To illustrate this process, three example package builds are available. See:
Refreshed builds for latest upstream (as of May 2007):