Updated diffs + gdk-pixbuf handling.

Tested with success locally.

-- 
Gilles Dartiguelongue <e...@gentoo.org>
Gentoo
Index: gnome2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/gnome2.eclass,v
retrieving revision 1.122
diff -u -B -r1.122 gnome2.eclass
--- gnome2.eclass	26 May 2013 14:08:21 -0000	1.122
+++ gnome2.eclass	1 Sep 2013 15:04:58 -0000
@@ -258,6 +258,7 @@
 	gnome2_icon_savelist
 	gnome2_schemas_savelist
 	gnome2_scrollkeeper_savelist
+	gnome2_gdk_pixbuf_savelist
 }
 
 # @FUNCTION: gnome2_pkg_postinst
@@ -271,6 +272,7 @@
 	gnome2_icon_cache_update
 	gnome2_schemas_update
 	gnome2_scrollkeeper_update
+	gnome2_gdk_pixbuf_update
 }
 
 # # FIXME Handle GConf schemas removal
Index: gnome2-utils.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v
retrieving revision 1.31
diff -u -B -r1.31 gnome2-utils.eclass
--- gnome2-utils.eclass	27 Oct 2012 22:24:10 -0000	1.31
+++ gnome2-utils.eclass	1 Sep 2013 15:04:58 -0000
@@ -15,6 +15,8 @@
 #  * GConf schemas management
 #  * scrollkeeper (old Gnome help system) management
 
+inherit multilib
+
 case "${EAPI:-0}" in
 	0|1|2|3|4|5) ;;
 	*) die "EAPI=${EAPI} is not supported" ;;
@@ -50,6 +52,12 @@
 # Path to glib-compile-schemas
 : ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
 
+# @ECLASS-VARIABLE: GDK_PIXBUF_UPDATE_BIN
+# @INTERNAL
+# @DESCRIPTION:
+# Path to gdk-pixbuf-query-loaders
+: ${GDK_PIXBUF_UPDATE_BIN:="/usr/bin/gdk-pixbuf-query-loaders"}
+
 # @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
 # @INTERNAL
 # @DEFAULT_UNSET
@@ -74,6 +82,12 @@
 # @DESCRIPTION:
 # List of GSettings schemas provided by the package
 
+# @ECLASS-VARIABLE: GNOME2_ECLASS_GDK_PIXBUF_LOADERS
+# @INTERNAL
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# List of gdk-pixbuf loaders provided by the package
+
 DEPEND=">=sys-apps/sed-4"
 
 
@@ -387,6 +401,46 @@
 	eend $?
 }
 
+# @FUNCTION: gnome2_gdk_pixbuf_savelist
+# @DESCRIPTION:
+# Find if there is any gdk-pixbuf loader to install and save the list in
+# GNOME2_ECLASS_GDK_PIXBUF_LOADERS variable.
+# This function should be called from pkg_preinst.
+gnome2_gdk_pixbuf_savelist() {
+	has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
+	pushd "${ED}" 1>/dev/null
+	export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find "usr/$(get_libdir)/gdk-pixbuf-2.0" -type f 2>/dev/null)
+	popd 1>/dev/null
+}
+
+# @FUNCTION: gnome2_gdk_pixbuf_update
+# @USAGE: gnome2_gdk_pixbuf_update
+# @DESCRIPTION:
+# Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some.
+# This function should be called from pkg_postinst and pkg_postrm.
+gnome2_gdk_pixbuf_update() {
+	has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
+	local updater="${EROOT}${GDK_PIXBUF_UPDATE_BIN}"
+
+	if [[ ! -x ${updater} ]]; then
+		debug-print "${updater} is not executable"
+		return
+	fi
+
+	if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
+		debug-print "gdk-pixbuf loader cache does not need an update"
+		return
+	fi
+
+	ebegin "Updating gdk-pixbuf loader cache"
+	local tmp_file=$(mktemp -t tmp.XXXXXXXXXX_gdkpixbuf)
+	${updater} 1> "${tmp_file}" &&
+	chmod 0644 "${tmp_file}" &&
+	mv -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache"
+	eend $?
+}
+
+
 # @FUNCTION: gnome2_query_immodules_gtk2
 # @USAGE: gnome2_query_immodules_gtk2
 # @DESCRIPTION:
Index: gdk-pixbuf-2.28.2.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/x11-libs/gdk-pixbuf/gdk-pixbuf-2.28.2.ebuild,v
retrieving revision 1.2
diff -u -B -r1.2 gdk-pixbuf-2.28.2.ebuild
--- gdk-pixbuf-2.28.2.ebuild	5 Aug 2013 09:48:12 -0000	1.2
+++ gdk-pixbuf-2.28.2.ebuild	1 Sep 2013 15:09:12 -0000
@@ -3,7 +3,8 @@
 # $Header: /var/cvsroot/gentoo-x86/x11-libs/gdk-pixbuf/gdk-pixbuf-2.28.2.ebuild,v 1.2 2013/08/05 09:48:12 ssuominen Exp $
 
 EAPI="5"
-inherit gnome.org multilib libtool
+
+inherit gnome.org gnome2-utils multilib libtool
 
 DESCRIPTION="Image loading library for GTK+"
 HOMEPAGE="http://www.gtk.org/";
@@ -64,19 +65,15 @@
 	prune_libtool_files --modules
 }
 
+pkg_preinst() {
+	gnome2_gdk_pixbuf_savelist
+}
+
 pkg_postinst() {
 	# causes segfault if set, see bug 375615
 	unset __GL_NO_DSO_FINALIZER
 
-	tmp_file=$(mktemp -t tmp_gdk_pixbuf_ebuild.XXXXXXXXXX)
-	# be atomic!
-	gdk-pixbuf-query-loaders > "${tmp_file}"
-	if [ "${?}" = "0" ]; then
-		cat "${tmp_file}" > "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache"
-	else
-		ewarn "Cannot update loaders.cache, gdk-pixbuf-query-loaders failed to run"
-	fi
-	rm "${tmp_file}"
+	gnome2_gdk_pixbuf_update
 
 	# FIXME: use subslots to get rebuilds when really needed
 	# Every major version bump???
@@ -86,3 +83,9 @@
 		elog "emerge -va1 \$(qfile -qC ${EPREFIX}/usr/lib/gtk-2.0/2.*/loaders)"
 	fi
 }
+
+pkg_postrm() {
+	if [[ -z ${REPLACED_BY_VERSIONS} ]]; then
+		rm -f "${EROOT}"usr/$(get_libdir)/${PN}-2.0/2.10.0/loaders.cache
+	fi
+}

Reply via email to