1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 # freedesktop-bugs@gentoo.org
8 # Original author: Gilles Dartiguelongue <eva@gentoo.org>
9 # @BLURB: Provides phases for XDG compliant packages.
11 # Utility eclass to update the desktop and shared mime info as laid
12 # out in the freedesktop specs & implementations
18 EXPORT_FUNCTIONS src_prepare pkg_preinst pkg_postinst pkg_postrm
20 *) die "EAPI=${EAPI} is not supported" ;;
23 # Avoid dependency loop as both depend on glib-2
24 if [[ ${CATEGORY}/${P} != dev-libs/glib-2.* ]] ; then
26 dev-util/desktop-file-utils
27 x11-misc/shared-mime-info
31 # @FUNCTION: xdg_src_prepare
33 # Prepare sources to work with XDG standards.
37 has ${EAPI:-0} 6 && default
40 # @FUNCTION: xdg_pkg_preinst
42 # Finds .desktop and mime info files for later handling in pkg_postinst.
43 # Locations are stored in XDG_ECLASS_DESKTOPFILES and XDG_ECLASS_MIMEINFOFILES
48 XDG_ECLASS_DESKTOPFILES=()
49 while IFS= read -r -d '' f; do
50 XDG_ECLASS_DESKTOPFILES+=( ${f} )
51 done < <(cd "${D}" && find 'usr/share/applications' -type f -print0 2>/dev/null)
53 XDG_ECLASS_MIMEINFOFILES=()
54 while IFS= read -r -d '' f; do
55 XDG_ECLASS_MIMEINFOFILES+=( ${f} )
56 done < <(cd "${D}" && find 'usr/share/mime' -type f -print0 2>/dev/null)
58 export XDG_ECLASS_DESKTOPFILES XDG_ECLASS_MIMEINFOFILES
61 # @FUNCTION: xdg_pkg_postinst
63 # Handle desktop and mime info database updates.
65 if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
66 xdg_desktop_database_update
68 debug-print "No .desktop files to add to database"
71 if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
72 xdg_mimeinfo_database_update
74 debug-print "No mime info files to add to database"
78 # @FUNCTION: xdg_pkg_postrm
80 # Handle desktop and mime info database updates.
82 if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
83 xdg_desktop_database_update
85 debug-print "No .desktop files to add to database"
88 if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
89 xdg_mimeinfo_database_update
91 debug-print "No mime info files to add to database"