6e9cc4
#
6e9cc4
# RPM macros for gconf applications.
6e9cc4
#
6e9cc4
# (c) 2006-2007 SUSE LINUX
6e9cc4
# Author: Stanislav Brabec <sbrabec@suse.cz>
6e9cc4
# (c) 2009 Red Hat, Inc
6e9cc4
# Author: Toshio Kuratomi <toshio@fedoraproject.org>
6e9cc4
#
6e9cc4
# License: LGPLv2+
6e9cc4
#
6e9cc4
# Usage:
6e9cc4
#
6e9cc4
# Preamble:
6e9cc4
# Requires(pre): GConf2
6e9cc4
# Requires(preun): GConf2
6e9cc4
# Requires(post): GConf2
6e9cc4
#
6e9cc4
# schemas names are without path and suffix
6e9cc4
#
6e9cc4
#
6e9cc4
# %pre
6e9cc4
# %gconf_schema_obsolete schema1
6e9cc4
# %gconf_schema_prepare schema2 schema3
6e9cc4
#
6e9cc4
# %preun
6e9cc4
# %gconf_schema_remove schema2 schema3
6e9cc4
#
6e9cc4
# %post
6e9cc4
# %gconf_schema_upgrade schema2 schema3
6e9cc4
#
6e9cc4
# %files
6e9cc4
# %{_sysconfdir}/gconf/schemas/schema2.schemas
6e9cc4
# %{_sysconfdir}/gconf/schemas/schema3.schemas
6e9cc4
6e9cc4
# Copy schemas from old package for later uninstall on upgrade
6e9cc4
%gconf_schema_prepare() \
6e9cc4
if [ "$1" -gt 1 ] ; then \
6e9cc4
    rm -rf %{_localstatedir}/lib/rpm-state/gconf/* \
6e9cc4
    for schema in %{*} ; do \
6e9cc4
        if test -f %{_sysconfdir}/gconf/schemas/"$schema".schemas ; then \
6e9cc4
            cp -p %{_sysconfdir}/gconf/schemas/"$schema".schemas %{_localstatedir}/lib/rpm-state/gconf/ || : \
6e9cc4
        fi \
6e9cc4
    done \
6e9cc4
fi \
6e9cc4
%{nil}
6e9cc4
6e9cc4
# Macro to remove schemas.  Not meant to be used publically
6e9cc4
%_do_gconf_schema_remove() \
6e9cc4
        if test -f %{_sysconfdir}/gconf/schemas/"$schema".schemas ; then \
6e9cc4
            export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
6e9cc4
            gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/"$schema".schemas > /dev/null || : \
6e9cc4
        fi \
6e9cc4
%{nil}
6e9cc4
6e9cc4
# Remove schemas unconditionally
6e9cc4
%gconf_schema_obsolete() \
6e9cc4
for schema in %{*} ; do \
6e9cc4
    %_do_gconf_schema_remove \
6e9cc4
done \
6e9cc4
%{nil}
6e9cc4
6e9cc4
# Remove schemas on package removal (not upgrade)
6e9cc4
%gconf_schema_remove() \
6e9cc4
if [ "$1" -eq 0 ] ; then \
6e9cc4
    for schema in %{*} ; do \
6e9cc4
        %_do_gconf_schema_remove \
6e9cc4
    done \
6e9cc4
fi \
6e9cc4
%{nil}
6e9cc4
6e9cc4
%gconf_schema_upgrade() \
6e9cc4
for schema in %{*} ; do \
6e9cc4
    if test -f %{_localstatedir}/lib/rpm-state/gconf/"$schema".schemas ; then \
6e9cc4
        cmp --quiet %{_sysconfdir}/gconf/schemas/"$schema".schemas %{_localstatedir}/lib/rpm-state/gconf/"$schema".schemas \
6e9cc4
        if test $? != 0; then\
6e9cc4
            export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
6e9cc4
            gconftool-2 --makefile-uninstall-rule %{_localstatedir}/lib/rpm-state/gconf/"$schema".schemas > /dev/null || : \
6e9cc4
            gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/"$schema".schemas > /dev/null || : \
6e9cc4
        fi \
6e9cc4
        rm -f %{_localstatedir}/lib/rpm-state/gconf/"$schema".schemas \
6e9cc4
    else \
6e9cc4
        export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
6e9cc4
        gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/"$schema".schemas > /dev/null || : \
6e9cc4
    fi \
6e9cc4
done \
6e9cc4
%{nil}