blob: 19146878a6a7718c2a5bd642536bdc9db887590d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# @ECLASS: xdg.eclass
# @MAINTAINER:
# freedesktop-bugs@gentoo.org
# @AUTHOR:
# Original author: Gilles Dartiguelongue <eva@gentoo.org>
# @BLURB: Provides phases for XDG compliant packages.
# @DESCRIPTION:
# Utility eclass to update the desktop and shared mime info as laid
# out in the freedesktop specs & implementations
inherit xdg-utils
case "${EAPI:-0}" in
0|1|2|3|4|5|6)
EXPORT_FUNCTIONS src_prepare pkg_preinst pkg_postinst pkg_postrm
;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
DEPEND="
dev-util/desktop-file-utils
x11-misc/shared-mime-info
"
# @FUNCTION: xdg_src_prepare
# @DESCRIPTION:
# Prepare sources to work with XDG standards.
xdg_src_prepare() {
xdg_environment_reset
has ${EAPI:-0} 6 && default
}
# @FUNCTION: xdg_pkg_preinst
# @DESCRIPTION:
# Finds .desktop and mime info files for later handling in pkg_postinst.
# Locations are stored in XDG_ECLASS_DESKTOPFILES and XDG_ECLASS_MIMEINFOFILES
# respectively.
xdg_pkg_preinst() {
has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
pushd "${ED}" > /dev/null || die
export XDG_ECLASS_DESKTOPFILES=( $(find 'usr/share/applications' -type f -print0 2> /dev/null) )
export XDG_ECLASS_MIMEINFOFILES=( $(find 'usr/share/mime' -type f -print0 2> /dev/null) )
popd > /dev/null || die
}
# @FUNCTION: xdg_pkg_postinst
# @DESCRIPTION:
# Handle desktop and mime info database updates.
xdg_pkg_postinst() {
if [[ -n "${XDG_ECLASS_DESKTOPFILES}" ]]; then
xdg_desktop_database_update
else
debug-print "No .desktop files to add to database"
fi
if [[ -n "${XDG_ECLASS_MIMEINFOFILES}" ]]; then
xdg_mimeinfo_database_update
else
debug-print "No mime info files to add to database"
fi
}
# @FUNCTION: xdg_pkg_postrm
# @DESCRIPTION:
# Handle desktop and mime info database updates.
xdg_pkg_postrm() {
if [[ -n "${XDG_ECLASS_DESKTOPFILES}" ]]; then
xdg_desktop_database_update
else
debug-print "No .desktop files to add to database"
fi
if [[ -n "${XDG_ECLASS_MIMEINFOFILES}" ]]; then
xdg_mimeinfo_database_update
else
debug-print "No mime info files to add to database"
fi
}
|