hicolor-icon-theme/macros.hicolor

64 lines
3.8 KiB
Plaintext

# RPM macros for packages installing icons or a whole icon theme
#
###
#
# When a package installs icons (or a whole icon theme), it should use
# both macros:
#
# - %icon_theme_cache_post in %post
# - %icon_theme_cache_postun in %postun
#
# Additionally, if a package installs a whole icon theme, it should use
# this macro:
#
# - %icon_theme_cache_create_ghost in %install
#
# This macro takes the name of an icon theme as argument. The
# icon-theme.cache created this way should be added with %ghost in the
# file list.
#
# Note that %icon_theme_cache_post and %icon_theme_cache_postun can
# optionally take the name of the icon theme where icons are installed.
# This is useful for packages containing a whole icon theme. If no
# argument is passed, the hicolor icon theme is assumed (which is where
# applications usually install their icons).
#
###
%icon_theme_cache_create_ghost() \
if test "x%1" == "x%%1"; then \
echo "Missing argument in call to %%icon_theme_cache_create_ghost." \
false \
fi \
mkdir -p "%{buildroot}%{_datadir}/icons/%1" \
touch "%{buildroot}%{_datadir}/icons/%1/icon-theme.cache"
# On install, update the icon cache
%icon_theme_cache_post() \
%if "x%1" != "x%%1" \
ICON_THEME="%1" \
%else \
ICON_THEME="hicolor" \
%endif \
if test -x %{_bindir}/gtk-update-icon-cache; then \
%{_bindir}/gtk-update-icon-cache --quiet --force "%{_datadir}/icons/${ICON_THEME}" || true \
elif test -x %{_bindir}/gtk-update-icon-cache-3.0; then \
%{_bindir}/gtk-update-icon-cache-3.0 --quiet --force "%{_datadir}/icons/${ICON_THEME}" || true \
fi
# On uninstall, update the icon cache. Note: we ignore upgrades (already
# handled in %post of the new package).
%icon_theme_cache_postun() \
if [ $1 -eq 0 ]; then \
%if "x%1" != "x%%1" \
ICON_THEME="%1" \
%else \
ICON_THEME="hicolor" \
%endif \
if test -x %{_bindir}/gtk-update-icon-cache; then \
%{_bindir}/gtk-update-icon-cache --quiet --force "%{_datadir}/icons/${ICON_THEME}" || true \
elif test -x %{_bindir}/gtk-update-icon-cache-3.0; then \
%{_bindir}/gtk-update-icon-cache-3.0 --quiet --force "%{_datadir}/icons/${ICON_THEME}" || true \
fi \
fi