Product SiteDocumentation Site

10.4.2. Defining scripts for subpackages

Much as you define separate %files and %description section for subpackages, you can also define install and uninstall scripts for subpackages. The syntax is similar to that for the %files and %description section:
%pre subpackage
For example, Listing 11-2 shows the scripts from the VNC package.
Listing 11-2: VNC package install and uninstall scripts.
%post server
if [ "$1" = 1 ]; then
/sbin/chkconfig --add vncserver
fi
%preun server
if [ "$1" = 0 ]; then
/sbin/service vncserver stop >/dev/null 2>&1
/sbin/chkconfig --del vncserver
fi
%postun server
if [ "$1" -ge "1" ]; then
/sbin/service vncserver condrestart >/dev/null 2>&1
fi