Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-dev@l.g.o
Cc: freedesktop-bugs@g.o
Subject: [gentoo-dev] [PATCH] xdg-utils.eclass: execute tools from PATH
Date: Wed, 03 Oct 2018 13:14:14
Message-Id: 20181003131404.3397-1-floppym@gentoo.org
1 Avoid calling binaries that may have been compiled against different
2 libraries or even cross-compiled for an incomatible arch.
3
4 Also drop the related eclass variables: these are currently unused by
5 any ebuild.
6
7 Signed-off-by: Mike Gilbert <floppym@g.o>
8 ---
9 eclass/xdg-utils.eclass | 28 ++++++----------------------
10 1 file changed, 6 insertions(+), 22 deletions(-)
11
12 diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass
13 index fe1eef213ea4..d46fe9b80759 100644
14 --- a/eclass/xdg-utils.eclass
15 +++ b/eclass/xdg-utils.eclass
16 @@ -20,24 +20,12 @@ case "${EAPI:-0}" in
17 *) die "EAPI=${EAPI} is not supported" ;;
18 esac
19
20 -# @ECLASS-VARIABLE: DESKTOP_DATABASE_UPDATE_BIN
21 -# @INTERNAL
22 -# @DESCRIPTION:
23 -# Path to update-desktop-database
24 -: ${DESKTOP_DATABASE_UPDATE_BIN:="/usr/bin/update-desktop-database"}
25 -
26 # @ECLASS-VARIABLE: DESKTOP_DATABASE_DIR
27 # @INTERNAL
28 # @DESCRIPTION:
29 # Directory where .desktop files database is stored
30 : ${DESKTOP_DATABASE_DIR="/usr/share/applications"}
31
32 -# @ECLASS-VARIABLE: MIMEINFO_DATABASE_UPDATE_BIN
33 -# @INTERNAL
34 -# @DESCRIPTION:
35 -# Path to update-mime-database
36 -: ${MIMEINFO_DATABASE_UPDATE_BIN:="/usr/bin/update-mime-database"}
37 -
38 # @ECLASS-VARIABLE: MIMEINFO_DATABASE_DIR
39 # @INTERNAL
40 # @DESCRIPTION:
41 @@ -67,19 +55,17 @@ xdg_environment_reset() {
42 # Updates the .desktop files database.
43 # Generates a list of mimetypes linked to applications that can handle them
44 xdg_desktop_database_update() {
45 - local updater="${EROOT%/}${DESKTOP_DATABASE_UPDATE_BIN}"
46 -
47 if [[ ${EBUILD_PHASE} != post* ]] ; then
48 die "xdg_desktop_database_update must be used in pkg_post* phases."
49 fi
50
51 - if [[ ! -x "${updater}" ]] ; then
52 - debug-print "${updater} is not executable"
53 + if ! type update-desktop-database &>/dev/null ; then
54 + debug-print "update-desktop-database is not found"
55 return
56 fi
57
58 ebegin "Updating .desktop files database"
59 - "${updater}" -q "${EROOT%/}${DESKTOP_DATABASE_DIR}"
60 + update-desktop-database -q "${EROOT%/}${DESKTOP_DATABASE_DIR}"
61 eend $?
62 }
63
64 @@ -88,18 +74,16 @@ xdg_desktop_database_update() {
65 # Update the mime database.
66 # Creates a general list of mime types from several sources
67 xdg_mimeinfo_database_update() {
68 - local updater="${EROOT%/}${MIMEINFO_DATABASE_UPDATE_BIN}"
69 -
70 if [[ ${EBUILD_PHASE} != post* ]] ; then
71 die "xdg_mimeinfo_database_update must be used in pkg_post* phases."
72 fi
73
74 - if [[ ! -x "${updater}" ]] ; then
75 - debug-print "${updater} is not executable"
76 + if ! type update-mime-database &>/dev/null ; then
77 + debug-print "update-mime-database is not found"
78 return
79 fi
80
81 ebegin "Updating shared mime info database"
82 - "${updater}" "${EROOT%/}${MIMEINFO_DATABASE_DIR}"
83 + update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}"
84 eend $?
85 }
86 --
87 2.19.0