Home Wiki > openSUSE:Packaging Multiple Version guidelines
Sign up | Login

openSUSE:Packaging Multiple Version guidelines

tagline: From openSUSE

Even if the standard behavior of RPM is to update a single package always to the highest version, it is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time.

For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference. Therefor, some standards can and should be defined, so programs can fall back to these standards.

Maintain default commands and libraries

Update-Alternatives

The update-alternatives package creates, removes, maintains and displays information about the symbolic links comprising the alternatives system. A packager can use this package to define default applications in a running system without getting in conflict with other packages.

Name:                vim
BuildRequires:  update-alternatives
PreReq:              update-alternatives
%install
# create a dummy target for /etc/alternatives/vim
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -s -f %{_sysconfdir}/alternatives/vim %{buildroot}/bin/vim
%post
"%_sbindir/update-alternatives" --install \
   /bin/vim        vim  /bin/vim-normal          15
%post enhanced
"%_sbindir/update-alternatives" --install \
   /bin/vim        vim  "%_bindir/vim-enhanced"  20
%preun
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove vim /bin/vim-normal
fi
%preun enhanced
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove vim "%_bindir/vim-enhanced"
fi
%files
%defattr(-,root,root)
%_bindir/vim
%ghost %_sysconfdir/alternatives/vim
%files enhanced
%defattr(-,root,root)
%_bindir/vim-enhanced