gtk-icon-cache.bbclass 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. FILES:${PN} += "${datadir}/icons/hicolor"
  7. GTKIC_VERSION ??= '3'
  8. GTKPN = "${@ 'gtk4' if d.getVar('GTKIC_VERSION') == '4' else 'gtk+3' }"
  9. GTKIC_CMD = "${@ 'gtk4-update-icon-cache' if d.getVar('GTKIC_VERSION') == '4' else 'gtk-update-icon-cache-3.0' }"
  10. #gtk+3/gtk4 require GTK3DISTROFEATURES, DEPENDS on it make all the
  11. #recipes inherit this class require GTK3DISTROFEATURES
  12. inherit features_check
  13. ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"
  14. DEPENDS += "${@ '' if d.getVar('BPN') == 'hicolor-icon-theme' else 'hicolor-icon-theme' } \
  15. ${@ '' if d.getVar('BPN') == 'gdk-pixbuf' else 'gdk-pixbuf' } \
  16. ${@ '' if d.getVar('BPN') == d.getVar('GTKPN') else d.getVar('GTKPN') } \
  17. ${GTKPN}-native \
  18. "
  19. PACKAGE_WRITE_DEPS += "${GTKPN}-native gdk-pixbuf-native"
  20. gtk_icon_cache_postinst() {
  21. if [ "x$D" != "x" ]; then
  22. $INTERCEPT_DIR/postinst_intercept update_gtk_icon_cache ${PKG} \
  23. mlprefix=${MLPREFIX} \
  24. libdir_native=${libdir_native}
  25. else
  26. # Update the pixbuf loaders in case they haven't been registered yet
  27. ${libdir}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache
  28. for icondir in /usr/share/icons/* ; do
  29. if [ -d $icondir ] ; then
  30. ${GTKIC_CMD} -fqt $icondir
  31. fi
  32. done
  33. fi
  34. }
  35. gtk_icon_cache_postrm() {
  36. if [ "x$D" != "x" ]; then
  37. $INTERCEPT_DIR/postinst_intercept update_gtk_icon_cache ${PKG} \
  38. mlprefix=${MLPREFIX} \
  39. libdir=${libdir}
  40. else
  41. for icondir in /usr/share/icons/* ; do
  42. if [ -d $icondir ] ; then
  43. ${GTKIC_CMD} -qt $icondir
  44. fi
  45. done
  46. fi
  47. }
  48. python populate_packages:append () {
  49. packages = d.getVar('PACKAGES').split()
  50. pkgdest = d.getVar('PKGDEST')
  51. for pkg in packages:
  52. icon_dir = '%s/%s/%s/icons' % (pkgdest, pkg, d.getVar('datadir'))
  53. if not os.path.exists(icon_dir):
  54. continue
  55. bb.note("adding hicolor-icon-theme dependency to %s" % pkg)
  56. rdepends = ' ' + d.getVar('MLPREFIX', False) + "hicolor-icon-theme"
  57. d.appendVar('RDEPENDS:%s' % pkg, rdepends)
  58. #gtk_icon_cache_postinst depend on gdk-pixbuf and gtk+3/gtk4
  59. bb.note("adding gdk-pixbuf dependency to %s" % pkg)
  60. rdepends = ' ' + d.getVar('MLPREFIX', False) + "gdk-pixbuf"
  61. d.appendVar('RDEPENDS:%s' % pkg, rdepends)
  62. bb.note("adding %s dependency to %s" % (d.getVar('GTKPN'), pkg))
  63. rdepends = ' ' + d.getVar('MLPREFIX', False) + d.getVar('GTKPN')
  64. d.appendVar('RDEPENDS:%s' % pkg, rdepends)
  65. bb.note("adding gtk-icon-cache postinst and postrm scripts to %s" % pkg)
  66. postinst = d.getVar('pkg_postinst:%s' % pkg)
  67. if not postinst:
  68. postinst = '#!/bin/sh\n'
  69. postinst += d.getVar('gtk_icon_cache_postinst')
  70. d.setVar('pkg_postinst:%s' % pkg, postinst)
  71. postrm = d.getVar('pkg_postrm:%s' % pkg)
  72. if not postrm:
  73. postrm = '#!/bin/sh\n'
  74. postrm += d.getVar('gtk_icon_cache_postrm')
  75. d.setVar('pkg_postrm:%s' % pkg, postrm)
  76. }