1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 # freedesktop-bugs@gentoo.org
9 # Original author: Gilles Dartiguelongue <eva@gentoo.org>
10 # @BLURB: Provides phases for XDG compliant packages.
12 # Utility eclass to update the desktop and shared mime info as laid
13 # out in the freedesktop specs & implementations
19 EXPORT_FUNCTIONS src_prepare pkg_preinst pkg_postinst pkg_postrm
21 *) die "EAPI=${EAPI} is not supported" ;;
24 # Avoid dependency loop as both depend on glib-2
25 if [[ ${CATEGORY}/${P} != dev-libs/glib-2.* ]] ; then
27 dev-util/desktop-file-utils
28 x11-misc/shared-mime-info
32 # @FUNCTION: xdg_src_prepare
34 # Prepare sources to work with XDG standards.
38 has ${EAPI:-0} 6 && default
41 # @FUNCTION: xdg_pkg_preinst
43 # Finds .desktop and mime info files for later handling in pkg_postinst.
44 # Locations are stored in XDG_ECLASS_DESKTOPFILES and XDG_ECLASS_MIMEINFOFILES
49 XDG_ECLASS_DESKTOPFILES=()
50 while IFS= read -r -d '' f; do
51 XDG_ECLASS_DESKTOPFILES+=( ${f} )
52 done < <(cd "${D}" && find 'usr/share/applications' -type f -print0 2>/dev/null)
54 XDG_ECLASS_MIMEINFOFILES=()
55 while IFS= read -r -d '' f; do
56 XDG_ECLASS_MIMEINFOFILES+=( ${f} )
57 done < <(cd "${D}" && find 'usr/share/mime' -type f -print0 2>/dev/null)
59 export XDG_ECLASS_DESKTOPFILES XDG_ECLASS_MIMEINFOFILES
62 # @FUNCTION: xdg_pkg_postinst
64 # Handle desktop and mime info database updates.
66 if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
67 xdg_desktop_database_update
69 debug-print "No .desktop files to add to database"
72 if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
73 xdg_mimeinfo_database_update
75 debug-print "No mime info files to add to database"
79 # @FUNCTION: xdg_pkg_postrm
81 # Handle desktop and mime info database updates.
83 if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
84 xdg_desktop_database_update
86 debug-print "No .desktop files to add to database"
89 if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
90 xdg_mimeinfo_database_update
92 debug-print "No mime info files to add to database"