1 |
commit: edc192145c1a5247af18b38e89ba863a51f935ed |
2 |
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Nov 21 10:28:54 2015 +0000 |
4 |
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Nov 24 21:56:04 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=edc19214 |
7 |
|
8 |
xdg-utils.eclass: initial commit |
9 |
|
10 |
Utility eclass providing basically the same features as fdo-mime, |
11 |
targetting to replace it with its companion xdg.eclass. |
12 |
|
13 |
https://bugs.gentoo.org/show_bug.cgi?id=444568 |
14 |
https://bugs.gentoo.org/show_bug.cgi?id=499288 |
15 |
|
16 |
eclass/xdg-utils.eclass | 127 ++++++++++++++++++++++++++++++++++++++++++++++++ |
17 |
1 file changed, 127 insertions(+) |
18 |
|
19 |
diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass |
20 |
new file mode 100644 |
21 |
index 0000000..523f985 |
22 |
--- /dev/null |
23 |
+++ b/eclass/xdg-utils.eclass |
24 |
@@ -0,0 +1,127 @@ |
25 |
+# Copyright 1999-2015 Gentoo Foundation |
26 |
+# Distributed under the terms of the GNU General Public License v2 |
27 |
+# $Id$ |
28 |
+ |
29 |
+# @ECLASS: xdg-utils.eclass |
30 |
+# @MAINTAINER: |
31 |
+# gnome@g.o |
32 |
+# @AUTHOR: |
33 |
+# Original author: Gilles Dartiguelongue <eva@g.o> |
34 |
+# @BLURB: Auxiliary functions commonly used by XDG compliant packages. |
35 |
+# @DESCRIPTION: |
36 |
+# This eclass provides a set of auxiliary functions needed by most XDG |
37 |
+# compliant packages. |
38 |
+# It provides XDG stack related functions such as: |
39 |
+# * XDG .desktop files cache management |
40 |
+# * XDG mime information database management |
41 |
+ |
42 |
+case "${EAPI:-0}" in |
43 |
+ 4|5|6) ;; |
44 |
+ *) die "EAPI=${EAPI} is not supported" ;; |
45 |
+esac |
46 |
+ |
47 |
+# @ECLASS-VARIABLE: DESKTOP_DATABASE_UPDATE_BIN |
48 |
+# @INTERNAL |
49 |
+# @DESCRIPTION: |
50 |
+# Path to update-desktop-database |
51 |
+: ${DESKTOP_DATABASE_UPDATE_BIN:="/usr/bin/update-desktop-database"} |
52 |
+ |
53 |
+# @ECLASS-VARIABLE: DESKTOP_DATABASE_DIR |
54 |
+# @INTERNAL |
55 |
+# @DESCRIPTION: |
56 |
+# Directory where .desktop files database is stored |
57 |
+: ${DESKTOP_DATABASE_DIR="/usr/share/applications"} |
58 |
+ |
59 |
+# @ECLASS-VARIABLE: MIMEINFO_DATABASE_UPDATE_BIN |
60 |
+# @INTERNAL |
61 |
+# @DESCRIPTION: |
62 |
+# Path to update-desktop-database |
63 |
+: ${MIMEINFO_DATABASE_UPDATE_BIN:="/usr/bin/update-mime-database"} |
64 |
+ |
65 |
+# @ECLASS-VARIABLE: MIMEINFO_DATABASE_DIR |
66 |
+# @INTERNAL |
67 |
+# @DESCRIPTION: |
68 |
+# Directory where .desktop files database is stored |
69 |
+: ${MIMEINFO_DATABASE_DIR:="/usr/share/mime"} |
70 |
+ |
71 |
+# @FUNCTION: xdg_environment_reset |
72 |
+# @DESCRIPTION: |
73 |
+# Clean up environment for clean builds. |
74 |
+xdg_environment_reset() { |
75 |
+ # Prepare XDG base directories |
76 |
+ export XDG_DATA_HOME="${T}/.local/share" |
77 |
+ export XDG_CONFIG_HOME="${T}/.config" |
78 |
+ export XDG_CACHE_HOME="${T}/.cache" |
79 |
+ export XDG_RUNTIME_DIR="${T}/run" |
80 |
+ mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \ |
81 |
+ "${XDG_RUNTIME_DIR}" |
82 |
+ # This directory needs to be owned by the user, and chmod 0700 |
83 |
+ # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html |
84 |
+ chmod 0700 "${XDG_RUNTIME_DIR}" |
85 |
+} |
86 |
+ |
87 |
+# @FUNCTION: xdg_desktopfiles_savelist |
88 |
+# @DESCRIPTION: |
89 |
+# Find the .desktop files about to be installed and save their location |
90 |
+# in the XDG_ECLASS_DESKTOPFILES environment variable. |
91 |
+# This function should be called from pkg_preinst. |
92 |
+xdg_desktopfiles_savelist() { |
93 |
+ pushd "${D}" > /dev/null || die |
94 |
+ export XDG_ECLASS_DESKTOPFILES=$(find 'usr/share/applications' -type f 2> /dev/null) |
95 |
+ popd > /dev/null || die |
96 |
+} |
97 |
+ |
98 |
+# @FUNCTION: fdo-xdg_desktop_database_update |
99 |
+# @DESCRIPTION: |
100 |
+# Updates the .desktop files database. |
101 |
+# Generates a list of mimetypes linked to applications that can handle them |
102 |
+xdg_desktop_database_update() { |
103 |
+ local updater="${EROOT}${DESKTOP_DATABASE_UPDATE_BIN}" |
104 |
+ |
105 |
+ if [[ ! -x "${updater}" ]] ; then |
106 |
+ debug-print "${updater} is not executable" |
107 |
+ return |
108 |
+ fi |
109 |
+ |
110 |
+ if [[ -z "${XDG_ECLASS_DESKTOPFILES}" ]]; then |
111 |
+ debug-print "No .desktop files to add to database" |
112 |
+ return |
113 |
+ fi |
114 |
+ |
115 |
+ ebegin "Updating .desktop files database" |
116 |
+ "${updater}" -q "${EROOT}${DESKTOP_DATABASE_DIR}" |
117 |
+ eend $? |
118 |
+} |
119 |
+ |
120 |
+# @FUNCTION: xdg_mimeinfo_savelist |
121 |
+# @DESCRIPTION: |
122 |
+# Find the mime information files about to be installed and save their location |
123 |
+# in the XDG_ECLASS_MIMEINFOFILES environment variable. |
124 |
+# This function should be called from pkg_preinst. |
125 |
+xdg_mimeinfo_savelist() { |
126 |
+ pushd "${D}" > /dev/null || die |
127 |
+ export XDG_ECLASS_MIMEINFOFILES=$(find 'usr/share/mime' -type f 2> /dev/null) |
128 |
+ popd > /dev/null || die |
129 |
+} |
130 |
+ |
131 |
+# @FUNCTION: xdg_mimeinfo_database_update |
132 |
+# @DESCRIPTION: |
133 |
+# Update the mime database. |
134 |
+# Creates a general list of mime types from several sources |
135 |
+xdg_mimeinfo_database_update() { |
136 |
+ local updater="${EROOT}${MIMEINFO_DATABASE_UPDATE_BIN}" |
137 |
+ |
138 |
+ if [[ ! -x "${updater}" ]] ; then |
139 |
+ debug-print "${updater} is not executable" |
140 |
+ return |
141 |
+ fi |
142 |
+ |
143 |
+ if [[ -z "${XDG_ECLASS_MIMEINFOFILES}" ]]; then |
144 |
+ debug-print "No mime info files to add to database" |
145 |
+ return |
146 |
+ fi |
147 |
+ |
148 |
+ ebegin "Updating shared mime info database" |
149 |
+ "${updater}" "${EROOT}${MIMEINFO_DATABASE_DIR}" |
150 |
+ eend $? |
151 |
+} |