gtk-icon-cache.bbclass 2.6 KB

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