gconf.txt revision 9021
10139N/AHow to package gconf schemas
10139N/A----------------------------
10139N/A
12158N/ABackground
10139N/A
10139N/A(Skip this if you are familiar with gconf, schemas, %gconf.xml files.)
10139N/ASomewhere between GNOME 2.12 and 2.14 GConf changed the file format of
15894N/Aits xml backend. Previously, if you had a key called
10139N/A/desktop/gnome/interface/foo, the corresponding value was stored in
10139N/A/etc/gconf/gconf.xml.defaults/desktop/gnome/interface/%gconf.xml
10139N/AThese files were created using gconftool-2 by installing schemas files,
10139N/Astored in /etc/gconf/schemas.
10139N/ASo we had 100s of small xml files, each containing just a few keys/values
17110N/Aand translations of the key descriptions in all languages.
10139N/AThis became a performance issue, as it took several seconds to load
10139N/Athese files when gconfd-2 started. The new approach is using
10139N/Aone "merged" xml file that includes all key - value pairs.
10139N/ALocalisations were split into separate xml files, one for each locale.
10139N/AThe new files are /etc/gconf/gconf.xml.defaults/%gconf-tree.xml and
16920N/A/etc/gconf/gconf.xml.defaults/%gconf-tree-<locale>.xml
10142N/AFirst a program called gconf-merge-tree was used to generate the
12132N/Amerged xml files from the directory structure. Once the merged xml
12132N/Afiles were created, gconfd-2 only read those and ignored the directory
10142N/Astructure. So we ended up with 2 gconf data bases which could become
12773N/Ainconsistent. Fortunately, gconftool-2 can now install the schemas
14434N/Astraight into the merged xml files. So the preferred way to install
12773N/Aschemas is doing just that.
14434N/A
15440N/A
15440N/AIntroduction
15740N/A
10139N/AIn JDS3, we installed the schemas into $RPM_BUILD_ROOT during 'make install'
12107N/Aand included the generated %gconf.xml files in the -root packages.
10139N/AThis was kinda broken as it wasn't possible for multiple packages to
10139N/Ainstall gconf keys in the same directory as they would have had to
10139N/Adeliver the same %gconf.xml file with different contents.
12796N/AHowever, the format of the xml database changed to merged xml files
10139N/A(see the Background above), so we were forced to change the way we
10139N/Adeliver gconf data.
10139N/AThe basic idea is similar to what Linux distributions do: we package the
10139N/Aschemas files and install/uninstall them using postinstall/preremove
10139N/Ascripts. The only difference is that we can't use gconftool-2 directly
10139N/Ain procedural package scripts because of problems with Live Upgrade and
10139N/AAlternate Root installations (see postrun.txt for more details).
12107N/ASo what we do is, use postrun to run gconftool-2 "as soon as possible".
13969N/AThe gconftool-2 command will install the schemas into the merged gconf
12107N/Afiles in /etc/gconf/gconf.xml.defaults/%gconf-tree*.xml.
14181N/A
14181N/A
14181N/AStep by step instructions
14181N/A
14181N/A1) Make sure that each -root sub package that delivers gconf schemas
14181N/A depends on SUNWgnome-config (gconf) and SUNWpostrun. Add these
15440N/A 2 lines to the end of the %package definition:
14181N/A
10139N/A Requires: SUNWpostrun-root
14181N/A Requires: SUNWgnome-config
16852N/A
16852N/A Example:
17108N/A
17108N/A ...
15864N/A %package root
10139N/A Summary: %{summary} - / filesystem
10139N/A SUNW_BaseDir: /
10139N/A %include default-depend.inc
10139N/A Requires: SUNWpostrun-root
10139N/A Requires: SUNWgnome-config
10139N/A ...
10139N/A
10139N/A2) Make sure that %install does not include the directory based %gconf.xml
10139N/A files. Note, if you use separate Linux and Solaris spec files and %use,
10139N/A these commands should go in the Linux spec file:
10139N/A
10139N/A export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1
10139N/A make DESTDIR=$RPM_BUILD_ROOT install
10139N/A
10139N/A If you do this, the only gconf-related files in $RPM_BUILD_ROOT/etc
10139N/A should be schemas.
10139N/A
10139N/A Some more explanations and historical details follow, skip to 3) if you
10139N/A don't care.
10139N/A
10139N/A In JDS3 and early JDS4 builds, we installed the schemas explicitely
10139N/A in the Solaris spec files' %install section like this:
10139N/A
10139N/A export GCONF_CONFIG_SOURCE=xml::$RPM_BUILD_ROOT%{_sysconfdir}/gconf/gconf.xml.defaults
10139N/A for S in $RPM_BUILD_ROOT/%{_sysconfdir}/gconf/schemas/*.schemas; do
10139N/A %{_bindir}/gconftool-2 --makefile-install-rule $S >/dev/null
10139N/A done
10139N/A
10139N/A Then we had to remove the zero-lenght %gconf.xml nodes (for example
10139N/A /etc/gconf/gconf.xml.defaults/apps/%gconf.xml) as they would
10139N/A have otherwise appeared in multiple -root pkgs, which is a violation
10139N/A of the packaging rules:
10139N/A
10139N/A chmod -R a+rX $RPM_BUILD_ROOT/%{_sysconfdir}
10139N/A for f in apps/?gconf.xml \
10139N/A schemas/?gconf.xml \
10139N/A schemas/apps/?gconf.xml \
10139N/A ; do
10139N/A test ! -s $RPM_BUILD_ROOT%{_sysconfdir}/gconf/gconf.xml.defaults/$f && \
10139N/A rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/gconf/gconf.xml.defaults/$f
10139N/A done
10139N/A
10139N/A This was really broken, because if the package that includes the removed
10139N/A %gconf.xml files is not installed then the files included in this pkg
10139N/A will not be found by gconfd-2. Worse, if, by mistake, no package
10139N/A includes some empty %gconf.xml nodes, the leaves won't be found at all.
10139N/A
10139N/A3) Add a %post and a %preun script that installs/uninstalls the schemas.
10139N/A Note, you need to list the schemas files in the %preun script.
10139N/A In the %post script we always install all schemas available on
10139N/A the system for performance reasons.
10139N/A
10139N/A %post root
10139N/A ( echo 'test -x /usr/bin/gconftool-2 || {';
10139N/A echo ' echo "ERROR: gconftool-2 not found"';
10139N/A echo ' exit 1';
10139N/A echo '}';
10139N/A echo 'umask 0022';
10139N/A echo 'GCONF_CONFIG_SOURCE=xml:merged:/etc/gconf/gconf.xml.defaults';
10139N/A echo 'export GCONF_CONFIG_SOURCE';
10139N/A echo '/usr/bin/gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/*.schemas'
10139N/A ) | $BASEDIR/var/lib/postrun/postrun -u -c JDS_wait
10139N/A
10139N/A %preun root
10139N/A test -x $BASEDIR/var/lib/postrun/postrun || exit 0
10139N/A ( echo 'test -x $PKG_INSTALL_ROOT/usr/bin/gconftool-2 || {';
10139N/A echo ' echo "WARNING: gconftool-2 not found; not uninstalling gconf schemas"';
10139N/A echo ' exit 0';
10139N/A echo '}';
10139N/A echo 'umask 0022';
10139N/A echo 'GCONF_CONFIG_SOURCE=xml:merged:$BASEDIR/etc/gconf/gconf.xml.defaults';
10142N/A echo 'GCONF_BACKEND_DIR=$PKG_INSTALL_ROOT/usr/lib/GConf/2';
10139N/A echo 'LD_LIBRARY_PATH=$PKG_INSTALL_ROOT/usr/lib';
10139N/A echo 'export GCONF_CONFIG_SOURCE GCONF_BACKEND_DIR LD_LIBRARY_PATH';
12176N/A echo 'SDIR=$BASEDIR%{_sysconfdir}/gconf/schemas';
10139N/A echo 'schemas="$SDIR/###FILE1###.schemas';
12796N/A echo ' $SDIR/###FILE2###.schemas';
12125N/A echo ' $SDIR/###FILE3###.schemas';
10139N/A (...)
10139N/A echo ' $SDIR/###FILEn###.schemas"';
12886N/A echo '$PKG_INSTALL_ROOT/usr/bin/gconftool-2 --makefile-uninstall-rule $schemas'
12886N/A ) | $BASEDIR/var/lib/postrun/postrun -i -c JDS -a
12886N/A
13367N/A4) update %files root (or %files -n SUNWfoo-bar-root), it should look
12127N/A something like this:
15740N/A
14181N/A %files root
16852N/A %defattr (0755, root, sys)
17108N/A %attr (0755, root, sys) %dir %{_sysconfdir}
10139N/A %{_sysconfdir}/gconf/schemas/###FILE1###.schemas
14434N/A %{_sysconfdir}/gconf/schemas/###FILE2###.schemas
15440N/A %{_sysconfdir}/gconf/schemas/###FILE3###.schemas
15440N/A (...)
15740N/A %{_sysconfdir}/gconf/schemas/###FILEn###.schemas
14434N/A
10139N/A Note: ###FILE1### ... ###FILEn### must match the list of lines in
10139N/A %preun. Please don't use *.schemas but list each schemas
10139N/A file so that when a new schemas file is added to the source tarball
10139N/A the build will break and we will notice that %post %preun and %files
10142N/A need to be updated.
10139N/A
10139N/AThat's it. If something is not clear, have questions or need a review,
10139N/Afeel free to email me at laca@sun.com.
10139N/A
10139N/ALast updated: 2006-06-02
10139N/A