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