blob: 6808339b900de18cdfbd874ba89745b68a4c8789 [file] [log] [blame]
Patrick Williams213cb262021-08-07 19:21:33 -05001FILES:${PN} += "${datadir}/icons/hicolor"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00003GTKIC_VERSION ??= '3'
4
5GTKPN = "${@ 'gtk4' if d.getVar('GTKIC_VERSION') == '4' else 'gtk+3' }"
6GTKIC_CMD = "${@ 'gtk-update-icon-cache-3.0.0' if d.getVar('GTKIC_VERSION') == '4' else 'gtk4-update-icon-cache' }"
7
8#gtk+3/gtk4 require GTK3DISTROFEATURES, DEPENDS on it make all the
Andrew Geissler635e0e42020-08-21 15:58:33 -05009#recipes inherit this class require GTK3DISTROFEATURES
10inherit features_check
11ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"
12
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000013DEPENDS +=" ${@ '' if d.getVar('BPN') == 'hicolor-icon-theme' else 'hicolor-icon-theme' } \
14 ${@ '' if d.getVar('BPN') == 'gdk-pixbuf' else 'gdk-pixbuf' } \
15 ${@ '' if d.getVar('BPN') == d.getVar('GTKPN') else d.getVar('GTKPN') } \
16 ${GTKPN}-native \
Andrew Geissler475cb722020-07-10 16:00:51 -050017"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000019PACKAGE_WRITE_DEPS += "${GTKPN}-native gdk-pixbuf-native"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021gtk_icon_cache_postinst() {
22if [ "x$D" != "x" ]; then
Brad Bishop96ff1982019-08-19 13:50:42 -040023 $INTERCEPT_DIR/postinst_intercept update_gtk_icon_cache ${PKG} \
Patrick Williamsf1e5d692016-03-30 15:21:19 -050024 mlprefix=${MLPREFIX} \
25 libdir_native=${libdir_native}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026else
27
28 # Update the pixbuf loaders in case they haven't been registered yet
Patrick Williamsf1e5d692016-03-30 15:21:19 -050029 ${libdir}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030
31 for icondir in /usr/share/icons/* ; do
32 if [ -d $icondir ] ; then
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000033 ${GTKIC_CMD} -fqt $icondir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 fi
35 done
36fi
37}
38
39gtk_icon_cache_postrm() {
40if [ "x$D" != "x" ]; then
Brad Bishop96ff1982019-08-19 13:50:42 -040041 $INTERCEPT_DIR/postinst_intercept update_gtk_icon_cache ${PKG} \
Patrick Williamsf1e5d692016-03-30 15:21:19 -050042 mlprefix=${MLPREFIX} \
43 libdir=${libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044else
45 for icondir in /usr/share/icons/* ; do
46 if [ -d $icondir ] ; then
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000047 ${GTKIC_CMD} -qt $icondir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 fi
49 done
50fi
51}
52
Patrick Williams213cb262021-08-07 19:21:33 -050053python populate_packages:append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 packages = d.getVar('PACKAGES').split()
55 pkgdest = d.getVar('PKGDEST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056
57 for pkg in packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 icon_dir = '%s/%s/%s/icons' % (pkgdest, pkg, d.getVar('datadir'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 if not os.path.exists(icon_dir):
60 continue
61
62 bb.note("adding hicolor-icon-theme dependency to %s" % pkg)
63 rdepends = ' ' + d.getVar('MLPREFIX', False) + "hicolor-icon-theme"
Patrick Williams213cb262021-08-07 19:21:33 -050064 d.appendVar('RDEPENDS:%s' % pkg, rdepends)
Andrew Geissler475cb722020-07-10 16:00:51 -050065
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000066 #gtk_icon_cache_postinst depend on gdk-pixbuf and gtk+3/gtk4
Andrew Geissler475cb722020-07-10 16:00:51 -050067 bb.note("adding gdk-pixbuf dependency to %s" % pkg)
68 rdepends = ' ' + d.getVar('MLPREFIX', False) + "gdk-pixbuf"
Patrick Williams213cb262021-08-07 19:21:33 -050069 d.appendVar('RDEPENDS:%s' % pkg, rdepends)
Andrew Geissler475cb722020-07-10 16:00:51 -050070
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000071 bb.note("adding %s dependency to %s" % (d.getVar('GTKPN'), pkg))
72 rdepends = ' ' + d.getVar('MLPREFIX', False) + d.getVar('GTKPN')
Patrick Williams213cb262021-08-07 19:21:33 -050073 d.appendVar('RDEPENDS:%s' % pkg, rdepends)
Andrew Geissler475cb722020-07-10 16:00:51 -050074
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 bb.note("adding gtk-icon-cache postinst and postrm scripts to %s" % pkg)
Andrew Geissler475cb722020-07-10 16:00:51 -050076
Patrick Williams213cb262021-08-07 19:21:33 -050077 postinst = d.getVar('pkg_postinst:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 if not postinst:
79 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 postinst += d.getVar('gtk_icon_cache_postinst')
Patrick Williams213cb262021-08-07 19:21:33 -050081 d.setVar('pkg_postinst:%s' % pkg, postinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082
Patrick Williams213cb262021-08-07 19:21:33 -050083 postrm = d.getVar('pkg_postrm:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 if not postrm:
85 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050086 postrm += d.getVar('gtk_icon_cache_postrm')
Patrick Williams213cb262021-08-07 19:21:33 -050087 d.setVar('pkg_postrm:%s' % pkg, postrm)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088}
89