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 | # |
| 8 | # This class will generate the proper postinst/postrm scriptlets for font |
| 9 | # packages. |
| 10 | # |
| 11 | |
| 12 | PACKAGE_WRITE_DEPS += "qemu-native" |
| 13 | inherit qemu |
| 14 | |
| 15 | FONT_PACKAGES ??= "${PN}" |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 16 | FONT_PACKAGES:class-native = "" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 17 | FONT_EXTRA_RDEPENDS ?= "${MLPREFIX}fontconfig-utils" |
| 18 | FONTCONFIG_CACHE_DIR ?= "${localstatedir}/cache/fontconfig" |
| 19 | FONTCONFIG_CACHE_PARAMS ?= "-v" |
| 20 | # You can change this to e.g. FC_DEBUG=16 to debug fc-cache issues, |
| 21 | # something has to be set, because qemuwrapper is using this variable after -E |
| 22 | # multiple variables aren't allowed because for qemu they are separated |
| 23 | # by comma and in -n "$D" case they should be separated by space |
| 24 | FONTCONFIG_CACHE_ENV ?= "FC_DEBUG=1" |
| 25 | fontcache_common() { |
| 26 | if [ -n "$D" ] ; then |
| 27 | $INTERCEPT_DIR/postinst_intercept update_font_cache ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} \ |
| 28 | 'bindir="${bindir}"' \ |
| 29 | 'libdir="${libdir}"' \ |
| 30 | 'libexecdir="${libexecdir}"' \ |
| 31 | 'base_libdir="${base_libdir}"' \ |
| 32 | 'fontconfigcachedir="${FONTCONFIG_CACHE_DIR}"' \ |
| 33 | 'fontconfigcacheparams="${FONTCONFIG_CACHE_PARAMS}"' \ |
| 34 | 'fontconfigcacheenv="${FONTCONFIG_CACHE_ENV}"' |
| 35 | else |
| 36 | ${FONTCONFIG_CACHE_ENV} fc-cache ${FONTCONFIG_CACHE_PARAMS} |
| 37 | fi |
| 38 | } |
| 39 | |
| 40 | python () { |
| 41 | font_pkgs = d.getVar('FONT_PACKAGES').split() |
| 42 | deps = d.getVar("FONT_EXTRA_RDEPENDS") |
| 43 | |
| 44 | for pkg in font_pkgs: |
| 45 | if deps: d.appendVar('RDEPENDS:' + pkg, ' '+deps) |
| 46 | } |
| 47 | |
| 48 | python add_fontcache_postinsts() { |
| 49 | for pkg in d.getVar('FONT_PACKAGES').split(): |
| 50 | bb.note("adding fonts postinst and postrm scripts to %s" % pkg) |
| 51 | postinst = d.getVar('pkg_postinst:%s' % pkg) or d.getVar('pkg_postinst') |
| 52 | if not postinst: |
| 53 | postinst = '#!/bin/sh\n' |
| 54 | postinst += d.getVar('fontcache_common') |
| 55 | d.setVar('pkg_postinst:%s' % pkg, postinst) |
| 56 | |
| 57 | postrm = d.getVar('pkg_postrm:%s' % pkg) or d.getVar('pkg_postrm') |
| 58 | if not postrm: |
| 59 | postrm = '#!/bin/sh\n' |
| 60 | postrm += d.getVar('fontcache_common') |
| 61 | d.setVar('pkg_postrm:%s' % pkg, postrm) |
| 62 | } |
| 63 | |
| 64 | PACKAGEFUNCS =+ "add_fontcache_postinsts" |