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 pixbuf |
| 9 | # packages. |
| 10 | # |
| 11 | |
| 12 | DEPENDS:append:class-target = " qemu-native" |
| 13 | inherit qemu |
| 14 | |
| 15 | PIXBUF_PACKAGES ??= "${PN}" |
| 16 | |
| 17 | PACKAGE_WRITE_DEPS += "qemu-native gdk-pixbuf-native" |
| 18 | |
| 19 | pixbufcache_common() { |
| 20 | if [ "x$D" != "x" ]; then |
| 21 | $INTERCEPT_DIR/postinst_intercept update_pixbuf_cache ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} libdir=${libdir} \ |
| 22 | bindir=${bindir} base_libdir=${base_libdir} |
| 23 | else |
| 24 | |
| 25 | # Update the pixbuf loaders in case they haven't been registered yet |
| 26 | ${libdir}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache |
| 27 | |
| 28 | if [ -x ${bindir}/gtk-update-icon-cache ] && [ -d ${datadir}/icons ]; then |
| 29 | for icondir in /usr/share/icons/*; do |
| 30 | if [ -d ${icondir} ]; then |
| 31 | gtk-update-icon-cache -t -q ${icondir} |
| 32 | fi |
| 33 | done |
| 34 | fi |
| 35 | fi |
| 36 | } |
| 37 | |
| 38 | python populate_packages:append() { |
| 39 | pixbuf_pkgs = d.getVar('PIXBUF_PACKAGES').split() |
| 40 | |
| 41 | for pkg in pixbuf_pkgs: |
| 42 | bb.note("adding pixbuf postinst and postrm scripts to %s" % pkg) |
| 43 | postinst = d.getVar('pkg_postinst:%s' % pkg) or d.getVar('pkg_postinst') |
| 44 | if not postinst: |
| 45 | postinst = '#!/bin/sh\n' |
| 46 | postinst += d.getVar('pixbufcache_common') |
| 47 | d.setVar('pkg_postinst:%s' % pkg, postinst) |
| 48 | |
| 49 | postrm = d.getVar('pkg_postrm:%s' % pkg) or d.getVar('pkg_postrm') |
| 50 | if not postrm: |
| 51 | postrm = '#!/bin/sh\n' |
| 52 | postrm += d.getVar('pixbufcache_common') |
| 53 | d.setVar('pkg_postrm:%s' % pkg, postrm) |
| 54 | } |
| 55 | |
| 56 | gdkpixbuf_complete() { |
| 57 | GDK_PIXBUF_FATAL_LOADER=1 ${STAGING_LIBDIR_NATIVE}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache || exit 1 |
| 58 | } |
| 59 | |
| 60 | DEPENDS:append:class-native = " gdk-pixbuf-native" |
| 61 | SYSROOT_PREPROCESS_FUNCS:append:class-native = " pixbufcache_sstate_postinst" |
| 62 | |
| 63 | pixbufcache_sstate_postinst() { |
| 64 | mkdir -p ${SYSROOT_DESTDIR}${bindir} |
| 65 | dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN} |
| 66 | echo '#!/bin/sh' > $dest |
| 67 | echo "${gdkpixbuf_complete}" >> $dest |
| 68 | chmod 0755 $dest |
| 69 | } |