From Fedora Project Wiki
(Initial draft of GConf scriptlet temp save incase i lose it :))
 
(More complete draft now)
Line 3: Line 3:
== Changelog ==
== Changelog ==


0.1: first go at this<BR>
0.1: First go at this<BR>


= Existing Guideline =
= Existing Guideline =


== GConf Schema registration ==
== GConf XML schema registration ==


Currently, when a package requires an XML schema it is installed in <code>%{_sysconfdir}/gconf/schemas/<code> (such as <code>gcalctool</code> in the following example), <code>gconftool-2</code> 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).  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 <code>gconf-editor</code>.
Currently, when a package requires an XML schema it is installed in <code>%{_sysconfdir}/gconf/schemas/<code> (such as <code>gcalctool</code> in the following example), <code>gconftool-2</code> 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 <code>gconf-editor</code>.
 
Note that this is required for any package that uses GConf for its configuration that must register its configurations into the registry.
 
<pre>
 
%find_lang gcalctool --with-gnome


Note that this is required for any package that has a schema that must register its configurations into the registry.
<code>
%post
%post
scrollkeeper-update -q
scrollkeeper-update -q
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas > /dev/null || :
gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas &gt;  /dev/null || :


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


Line 29: Line 33:
   gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas > /dev/null || :
   gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/gcalctool.schemas > /dev/null || :
fi
fi
</code>
</pre>


= Proposal =
= Proposal =


Motivations for changing the existing guideline:
Motivations for changing the existing guideline:
* include footnote/reference to fdo icon-theme-spec.
* 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.
* simplify guideline by removing toolkit-specific optimization details.
* 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.
* gtk-update-icon-cache currently runs on every pkg install (that includes icons), which is potentially very inefficient. (see %posttrans). Informal benchmarks show 0.2-0.5 (user) seconds for every invocation. This appears to have been addressed in a recent update to guic to include a --delay option.
 
== 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.


== icon cache ==
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.


If an application installs icons into one of the subdirectories in <code>%{_datadir}/icons/</code> (such as <code>hicolor</code> in the following examples), care must be taken to ensure the installed icons appear properly after package installation[[FootNote([http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html] )  .
Typical example of how the new macros work:


Use the following scriptlets:
<pre>
<pre>
%post
Name: gcalctool
%{_bindir}/xdg-icon-resource forceupdate --theme hicolor 2> /dev/null || :
...
...
...
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


%postun
#%files -f gcalctool.lang
%{_bindir}/xdg-icon-resource forceupdate --theme hicolor 2> /dev/null || :
%files -f %{names}.lst
#%{_sysconfdir}/gconf/schemas/gcalctool.schemas
</pre>
</pre>


== gtk icon cache coherency brainstorm (not part of packaging guidelines) ==
* 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:


Brainstorming methods to keep gtk icon cache fresh.  See also bugzilla bug tracking this:<BR>
<code>gconf_schemas_prereq</code> This macro just looks for some pre-requirements
[http://bugzilla.redhat.com/170335] gtk2: create/maintain iconcache<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.
Ideas include:
<code>def_gconf_schemas</code> Define a schema, set file permissions for use with %file section, create %pre, %preun, %posttrans rpm-scriptlets
* cron job (like prelink)
<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.
* on boot (init) + file-system monitoring daemon (e.g. incron)
<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.
* rpm %posttrans scriptlet hook. No, %posttransun doesn't work (rpm bug?)


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

Revision as of 05:06, 15 April 2009

Warning.png
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.