def populate_packages(d):
    oe.package.populate_packages(d)
    packages = d.getVar('PACKAGES').split()
    pkgdest =  d.getVar('PKGDEST')

    for pkg in packages:
        icon_dir = '%s/%s/%s/icons' % (pkgdest, pkg, d.getVar('datadir'))
        if not os.path.exists(icon_dir):
            continue

        bb.note("adding hicolor-icon-theme dependency to %s" % pkg)
        rdepends = ' ' + d.getVar('MLPREFIX', False) + "hicolor-icon-theme"
        d.appendVar('RDEPENDS:%s' % pkg, rdepends)

        #gtk_icon_cache_postinst depend on gdk-pixbuf and gtk+3/gtk4
        bb.note("adding gdk-pixbuf dependency to %s" % pkg)
        rdepends = ' ' + d.getVar('MLPREFIX', False) + "gdk-pixbuf"
        d.appendVar('RDEPENDS:%s' % pkg, rdepends)

        bb.note("adding %s dependency to %s" % (d.getVar('GTKPN'), pkg))
        rdepends = ' ' + d.getVar('MLPREFIX', False) + d.getVar('GTKPN')
        d.appendVar('RDEPENDS:%s' % pkg, rdepends)

        bb.note("adding gtk-icon-cache postinst and postrm scripts to %s" % pkg)

        postinst = d.getVar('pkg_postinst:%s' % pkg)
        if not postinst:
            postinst = '#!/bin/sh\n'
        postinst += d.getVar('gtk_icon_cache_postinst')
        d.setVar('pkg_postinst:%s' % pkg, postinst)

        postrm = d.getVar('pkg_postrm:%s' % pkg)
        if not postrm:
            postrm = '#!/bin/sh\n'
        postrm += d.getVar('gtk_icon_cache_postrm')
        d.setVar('pkg_postrm:%s' % pkg, postrm)

populate_packages(d)

