summaryrefslogtreecommitdiff
path: root/packaging/macros.glib2
blob: f68299530791a276c1e33b248cfe1e31cff811f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# RPM macros for packages installing a GSettings schema or GIO module
#
###
#
# When a package installs a GSettings schemas, it should use all
# three macros:
#
#  - %glib2_gsettings_schema_requires in the preamble
#  - %glib2_gsettings_schema_post in %post
#  - %glib2_gsettings_schema_postun in %postun
#
###
#
# When a package installs a GIO module, it should use all
# three macros:
#
#  - %glib2_gio_module_requires in the preamble
#  - %glib2_gio_module_post in %post
#  - %glib2_gio_module_postun in %postun
#
# Note that %glib2_gio_module_post and %glib2_gio_module_postun can
# optionally take the path to the directory where modules live. This
# is useful for applications using the GIO module system on their own,
# since they will install modules in their own directory. If no
# argument is passed, the path for the modules for GIO itself is used.
#
###

%glib2_gsettings_schema_requires                                \
Requires(post): glib2-tools                                     \
Requires(postun): glib2-tools

%glib2_gsettings_schema_post                                    \
%{_bindir}/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :

# Note: we ignore upgrades (already handled in %post of the new package).
%glib2_gsettings_schema_postun                                  \
if [ $1 -eq 0 ]; then                                           \
  %{_bindir}/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : \
fi

%glib2_gio_module_requires                                      \
Requires(post): glib2-tools                                     \
Requires(postun): glib2-tools

# On install, update the cache
%glib2_gio_module_post()                                        \
%if "x%1" != "x%%1"                                             \
  GIO_MODULES_DIR="%1"                                          \
%else                                                           \
  GIO_MODULES_DIR="%{_libdir}/gio/modules"                      \
%endif                                                          \
%if "%{_lib}" == "lib64"                                        \
  %{_bindir}/gio-querymodules-64 "${GIO_MODULES_DIR}"           \
%else                                                           \
  %{_bindir}/gio-querymodules "${GIO_MODULES_DIR}"              \
%endif

# On uninstall, update the cache. Note: we ignore upgrades (already
# handled in %post of the new package).
%glib2_gio_module_postun()                                      \
if [ $1 -eq 0 ]; then                                           \
  %if "x%1" != "x%%1"                                           \
    GIO_MODULES_DIR="%1"                                        \
  %else                                                         \
    GIO_MODULES_DIR="%{_libdir}/gio/modules"                    \
  %endif                                                        \
  %if "%_lib" == "lib64"                                        \
    %{_bindir}/gio-querymodules-64 "${GIO_MODULES_DIR}"         \
  %else                                                         \
    %{_bindir}/gio-querymodules "${GIO_MODULES_DIR}"            \
  %endif                                                        \
fi