Patchwork [4/5] gdk-pixbuf: generate the pixbuf loader's cache ar rootfs time

login
register
mail settings
Submitter Laurentiu Palcu
Date Dec. 4, 2012, 1:59 p.m.
Message ID <e5441f19f27ed7063c8bda010ea21bcf7af5a43a.1354626535.git.laurentiu.palcu@intel.com>
Download mbox | patch
Permalink /patch/40275/
State Accepted
Commit 97648976164e0efaf67c9928f85db5e7cea4378e
Headers show

Comments

Laurentiu Palcu - Dec. 4, 2012, 1:59 p.m.
This will generate the loaders.cache file for pixbuf, at rootfs time.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.24.1.bb |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
Ross Burton - Dec. 4, 2012, 2:34 p.m.
Hi,

On 4 December 2012 13:59, Laurentiu Palcu <laurentiu.palcu@intel.com> wrote:
> +# Update the target's pixbuf loader's cache. Since the native binary will
> +# throw an error if the shared objects do not belong to the same ELF class,
> +# we trick the gdk-pixbuf-query-loaders into scanning the native shared
> +# objects and then we remove the NATIVE_ROOT prefix from the paths in
> +# loaders.cache.

It's probably worth explaining why it's fine that only the loaders
from gdk-pixbuf-native are used and for example librsvg-native doesn't
need to be built.

Ross
Laurentiu Palcu - Dec. 5, 2012, 9:28 a.m.
On 12/04/2012 04:34 PM, Burton, Ross wrote:
> It's probably worth explaining why it's fine that only the loaders
> from gdk-pixbuf-native are used and for example librsvg-native doesn't
> need to be built.
First off, the librsvg postinstall scriptlet is still postponed to run
on target, at first boot. I didn't touch that one, yet. We will deal
with this one (and others) in subsequent patches. Secondly, the
gdk-pixbuf postinstall scriptlet will exit 1 if the command fails. So,
if one has librsvg built and the native one is not present, the
gdk-pixbuf scriptlet will fail on host because it will not find the
native SVG pixbuf loader and it will be postponed to run on target at
first boot. No harm done, this is the current behavior anyway.

However, if we want to be able to run all postinstall scriptlets on host
in order to support read-only rootfs, we might need to have
librsvg-native built too so that we generate the pixbuf loader cache on
host at rootfs install time.

Let's take it step-by-step though and see how the current changes
behave. What do you think?

Thanks,
Laurentiu
Ross Burton - Dec. 14, 2012, 2:24 p.m.
On 5 December 2012 09:28, Laurentiu Palcu <laurentiu.palcu@intel.com> wrote:
> However, if we want to be able to run all postinstall scriptlets on host
> in order to support read-only rootfs, we might need to have
> librsvg-native built too so that we generate the pixbuf loader cache on
> host at rootfs install time.

Not true - the icon cache explicitly only loads .png and .xpm, so my
point was that it's entirely safe to run gtk-update-icon-cache at
rootfs time as those loaders are part of gdk-pixbuf, which must be
available natively if we're running gtk-update-icon-cache.

Ross

Patch

diff --git a/meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.24.1.bb b/meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.24.1.bb
index 65a2d68..2377d0e 100644
--- a/meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.24.1.bb
+++ b/meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.24.1.bb
@@ -58,9 +58,21 @@  FILES_${PN}-dbg += " \
 
 postinst_pixbufloader () {
 if [ "x$D" != "x" ]; then
-    exit 1
+# Update the target's pixbuf loader's cache. Since the native binary will
+# throw an error if the shared objects do not belong to the same ELF class,
+# we trick the gdk-pixbuf-query-loaders into scanning the native shared
+# objects and then we remove the NATIVE_ROOT prefix from the paths in
+# loaders.cache.
+gdk-pixbuf-query-loaders $(find $D/${libdir}/gdk-pixbuf-2.0/${LIBV}/loaders \
+        -name *.so | sed -e "s:$D:$NATIVE_ROOT:g") > \
+        $D/${libdir}/gdk-pixbuf-2.0/${LIBV}/loaders.cache || exit 1
+
+sed -i -e "s:$NATIVE_ROOT:/:g" $D/${libdir}/gdk-pixbuf-2.0/${LIBV}/loaders.cache
+
+exit 0
 fi
 
+# Update the pixbuf loaders in case they haven't been registered yet
 GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/${LIBV}/loaders gdk-pixbuf-query-loaders --update-cache
 
 if [ -x ${bindir}/gtk-update-icon-cache ] && [ -d ${datadir}/icons ]; then
@@ -93,6 +105,7 @@  do_install_append_class-native() {
 		GDK_PIXBUF_MODULE_FILE=${STAGING_LIBDIR_NATIVE}/gdk-pixbuf-2.0/${LIBV}/loaders.cache
 
 	create_wrapper ${D}/${bindir}/gdk-pixbuf-query-loaders \
-		GDK_PIXBUF_MODULE_FILE=${STAGING_LIBDIR_NATIVE}/gdk-pixbuf-2.0/${LIBV}/loaders.cache
+		GDK_PIXBUF_MODULE_FILE=${STAGING_LIBDIR_NATIVE}/gdk-pixbuf-2.0/${LIBV}/loaders.cache \
+		GDK_PIXBUF_MODULEDIR=${STAGING_LIBDIR_NATIVE}/gdk-pixbuf-2.0/${LIBV}/loaders
 }
 BBCLASSEXTEND = "native"