From Fedora Project Wiki
(More complete draft now)
Line 84: Line 84:
The following macros are available:
The following macros are available:


<code>gconf_schemas_prereq</code> This macro just looks for some pre-requirements
<code>gconf_schemas_prereq</code> - This macro just looks for some pre-requirements<BR>
<code>find_gconf_schemas</code> Searches the package during build time in $RPM_BUILD_ROOT/etc/gconf/schemas and builds a list of them and creates rpm-scriptlets in the process for each schema file found.
<code>find_gconf_schemas</code> - Searches the package during build time in $RPM_BUILD_ROOT/etc/gconf/schemas and builds a list of them and creates rpm-scriptlets in the process for each schema file found.<BR>
<code>def_gconf_schemas</code>  Define a schema, set file permissions for use with %file section, create %pre, %preun, %posttrans rpm-scriptlets  
<code>def_gconf_schemas</code>  - Define a schema, set file permissions for use with %file section, create %pre, %preun, %posttrans rpm-scriptlets<BR>
<code>add_gconf_schemas</code> Creates %pre section setup up comparing existing schema with new one, creates uninstall scriptlet for %preun section to remove schema from registry.
<code>add_gconf_schemas</code> - Creates %pre section setup up comparing existing schema with new one, creates uninstall scriptlet for %preun section to remove schema from registry<BR>
<code>end_gconf_schemas></code> You must call this macro if you do not use the <code>find_gconf_schemas</code> macro. This macro does a compare list against schemas that need to be registered in a %posttrans scriptlet and which ones need to be uninstalled in a %preun scriptlet.
<code>end_gconf_schemas></code> - You must call this macro if you do not use the <code>find_gconf_schemas</code> macro. This macro does a compare list against schemas that need to be registered in a %posttrans scriptlet and which ones need to be uninstalled in a %preun scriptlet.<BR>


[[Category:Archived packaging guideline drafts]]
[[Category:Archived packaging guideline drafts]]

Revision as of 05:07, 15 April 2009

This page is a draft only
It is still under construction and content may change. Do not rely on the information on this page.

Changelog

0.1: First go at this

Existing Guideline

GConf XML schema registration

Currently, when a package requires an XML schema it is installed in %{_sysconfdir}/gconf/schemas/ (such as gcalctool in the following example), gconftool-2 should be run after the package is installed/uninstalled in FC4 or later. If the package is upgraded, the existing schema is deleted and removed from the XML schema tree (registry) and then the package provided schema is installed and registered. This is required so that the program(s) have a default configuration and for any custom options a user may wish to edit with using gconf-editor.

Note that this is required for any package that uses GConf for its configuration that must register its configurations into the registry.


%find_lang gcalctool --with-gnome

%post
scrollkeeper-update -q
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas >  /dev/null || :

%pre
if [ "$1" -gt 1 ]; then
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas > /dev/null || :
fi

%preun
if [ "$1" -eq 0 ]; then
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas > /dev/null || :
fi

Proposal

Motivations for changing the existing guideline:

  • Speed up package install/upgrade. Right now it is painful when preforming Anaconda installs and yum updates for new packages, it takes a long time for the XML schemas to register and this is done for each GConf related package and each sub-package as well.
  • gconftool-2 currently runs on every package install/upgrade, which is very inefficient. When preforming an upgrade of a package using the existing guidelines, there is no comparing of the existing schema and this needlessly removes and re-registers with an unchanged schema, slowing down Anaconda installs and yum updates.

New GConf registration

Using OpenSuSE's existing macros.gconf2 with minor modifications (as needed) we can dramatically improve install and upgrade times for our users. Upgrading existing RPMs will have their schemas compared and if they are the same, no changes are done to the user's system configuration registry. If there are changes, then the schema is registered as normal within %posttrans section.

Since schema registrations are usually not dependant on other packages being installed (and probably should not be) we are able to push these registrations to a %posttrans section.

Typical example of how the new macros work:

Name: gcalctool
...
...
...
Requires(post): GConf2
...
%gconf_schemas_prereq  [This basically is just Requires(pre): GConf2 coreutils diffutils ]

%install 
...
# Find GConf XML Schemas
%find_gconf_schemas

%find_lang gcalctool --with-gnome
cat %{name}.schemas_list %{name}.lang >%{name}.lst

%pre -f %{name}.schemas_pre

%preun -f %{name}.schemas_preun

%posttrans -f %{name}.schemas_posttrans

#%files -f gcalctool.lang
%files -f %{names}.lst
#%{_sysconfdir}/gconf/schemas/gcalctool.schemas
  • rpm-scriptlets are generated by the macros in %pre, %preun, %posttrans
  • We do not need to explicitly include the schema files in the %file section.

Description of new GConf macros

The following macros are available:

gconf_schemas_prereq - This macro just looks for some pre-requirements
find_gconf_schemas - Searches the package during build time in $RPM_BUILD_ROOT/etc/gconf/schemas and builds a list of them and creates rpm-scriptlets in the process for each schema file found.
def_gconf_schemas - Define a schema, set file permissions for use with %file section, create %pre, %preun, %posttrans rpm-scriptlets
add_gconf_schemas - Creates %pre section setup up comparing existing schema with new one, creates uninstall scriptlet for %preun section to remove schema from registry
end_gconf_schemas> - You must call this macro if you do not use the find_gconf_schemas macro. This macro does a compare list against schemas that need to be registered in a %posttrans scriptlet and which ones need to be uninstalled in a %preun scriptlet.