def add_fontcache_postinsts(d):
    for pkg in d.getVar('FONT_PACKAGES').split():
        bb.note("adding fonts postinst and postrm scripts to %s" % pkg)
        postinst = d.getVar('pkg_postinst:%s' % pkg) or d.getVar('pkg_postinst')
        if not postinst:
            postinst = '#!/bin/sh\n'
        postinst += d.getVar('fontcache_common')
        d.setVar('pkg_postinst:%s' % pkg, postinst)

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

add_fontcache_postinsts(d)

