Changes between Version 23 and Version 24 of RpmHowToPackagers


Ignore:
Timestamp:
Oct 1, 2011, 7:56:36 PM (13 years ago)
Author:
dmik
Comment:

Added WPS object creation section

Legend:

Unmodified
Added
Removed
Modified
  • RpmHowToPackagers

    v23 v24  
    157157Note that it doesn't make much sense to use cp -dp in packages which you build from sources, since the original timestamp in this case is the build time which won't differ too much from the install time (as the %install stage happens right after the %build stage).
    158158
     159=== WPS object creation ===
     160
     161RPM provides a number of macros to create WPS objects for your package from %post and %postun scriplets. These macros start with {{{%wps_object_}}}. All WPS objects created using these macros are associated with the package and recorded in a special database. Each object also has a reference count (which is increased when the object is created and decreased when it is deleted). The physical object deletion only happens when the reference count drops to zero. This is useful for objects (e.g. application folders) shared between several packages since it allows to keep them alive as long as there is one or more packages referencing them installed and automatically remove these shared objects once all of the referencing packages are removed.
     162
     163Here is an example:
     164{{{
     165%post
     166if [ "$1" -ge 1 ]; then # (upon update)
     167    %wps_object_delete_all
     168fi
     169%wps_object_create_begin
     170MYAPP_EXE:WPProgram|My App|<WP_DESKTOP>|EXENAME=((%{_bindir}/myapp.exe))
     171%wps_object_create_end
     172
     173%postun
     174if [ "$1" -e 0 ]; then # (upon removal)
     175    %wps_object_delete_all
     176fi
     177}}}
     178
     179For a sub-package named "extras", the scriptlets will look as follows:
     180{{{
     181%post extras
     182if [ "$1" -ge 1 ]; then # (upon update)
     183    %wps_object_delete_all -n %{name}-extras
     184fi
     185%wps_object_create_begin -n %{name}-extras
     186MYAPP_EXTRAS_FOLDER:WPFolder|My App Extras|<WP_DESKTOP>
     187MYAPP_FOOBAR_EXE:WPProgram|My App FooBar|<MYAPP_EXTRAS_FOLDER>|EXENAME=((%{_bindir}/myapp-foobar.exe))
     188%wps_object_create_end
     189
     190%postun
     191if [ "$1" -e 0 ]; then # (upon removal)
     192    %wps_object_delete_all -n %{name}-extras
     193fi
     194}}}
     195
    159196=== CONFIG.SYS changes ===
    160197It is sometimes necessary to modify the CONFIG.SYS file during installation, even when using RPM. One of the examples is when your package installs a device driver that needs to be loaded at boot time or when a global environment variable needs to be set. This can be done from the {{{%post}}} section using the special macro {{{%cube}}} which is based on the CUBE tool.