Packaging/Licenses

From openSUSE

License collection as found in the packages of openSUSE

To avoid a huge overload of duplicated files, openSUSE has created the package "licenses". It contains a collection of license texts found in the packages of an openSUSE distribution. The files are installed at /usr/share/doc/licenses. Other packages are encouraged to symlink to this location, instead of having a fulltext copy of a license in the packages.

This can be done in the following way in the specfile of the other package (example):

[...]
BuildRequires:  licenses
Requires:       licenses
[...]
%install
for FILE in COPYING LICENCE LICENCE_JHEAD LICENCE_VIGRA ; do
    MD5SUM=$(md5sum $FILE | sed 's/ .*//')
    if test -f /usr/share/doc/licenses/md5/$MD5SUM ; then
        ln -sf /usr/share/doc/licenses/md5/$MD5SUM $FILE
    fi
done
[...]
%files
%defattr(-,root,root)
%doc COPYING LICENCE LICENCE_JHEAD LICENCE_VIGRA
[...]

With openSUSE 10.3 the package licenses comes with the base-system - so an explicit Requires can be skipped, but adding it to Requires is the clean way to go.