Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Thu, 07 Feb 2019 13:01:10
Message-Id: 1549544397.f281d20f8a4e9a458f196143f4a1099369b1b47a.asturm@gentoo
1 commit: f281d20f8a4e9a458f196143f4a1099369b1b47a
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 5 18:33:50 2019 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 7 12:59:57 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f281d20f
7
8 kde5.eclass: Fork needed xdg.eclass functions pending EAPI-7 porting
9
10 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
11
12 eclass/kde5.eclass | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++---
13 1 file changed, 123 insertions(+), 5 deletions(-)
14
15 diff --git a/eclass/kde5.eclass b/eclass/kde5.eclass
16 index e3c4bc9c923..82655acabcc 100644
17 --- a/eclass/kde5.eclass
18 +++ b/eclass/kde5.eclass
19 @@ -31,10 +31,11 @@ _KDE5_ECLASS=1
20 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
21 : ${VIRTUALX_REQUIRED:=manual}
22
23 -inherit cmake-utils flag-o-matic kde5-functions virtualx xdg
24 +inherit cmake-utils flag-o-matic kde5-functions virtualx
25
26 case ${EAPI} in
27 - 6) inherit eapi7-ver eutils gnome2-utils ;;
28 + 6) inherit eapi7-ver eutils gnome2-utils xdg ;;
29 + 7) inherit xdg-utils ;;
30 esac
31
32 if [[ ${KDE_BUILD_TYPE} = live ]]; then
33 @@ -716,6 +717,120 @@ kde5_src_install() {
34 fi
35 }
36
37 +# @FUNCTION: _xdg_icon_cache_update
38 +# @DESCRIPTION: Forked from future xdg-utils.eclass. REMOVEME!
39 +# Updates Gtk+ icon cache files under /usr/share/icons.
40 +# This function should be called from pkg_postinst and pkg_postrm.
41 +_xdg_icon_cache_update() {
42 + if [[ ${EBUILD_PHASE} != post* ]] ; then
43 + die "xdg_icon_cache_update must be used in pkg_post* phases."
44 + fi
45 +
46 + if ! type gtk-update-icon-cache &>/dev/null; then
47 + debug-print "gtk-update-icon-cache is not found"
48 + return
49 + fi
50 +
51 + ebegin "Updating icons cache"
52 + local retval=0
53 + local fails=( )
54 + for dir in "${EROOT%/}"/usr/share/icons/*
55 + do
56 + if [[ -f "${dir}/index.theme" ]] ; then
57 + local rv=0
58 + gtk-update-icon-cache -qf "${dir}"
59 + rv=$?
60 + if [[ ! $rv -eq 0 ]] ; then
61 + debug-print "Updating cache failed on ${dir}"
62 + # Add to the list of failures
63 + fails+=( "${dir}" )
64 + retval=2
65 + fi
66 + elif [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
67 + # Clear stale cache files after theme uninstallation
68 + rm "${dir}/icon-theme.cache"
69 + fi
70 + if [[ -z $(ls "${dir}") ]]; then
71 + # Clear empty theme directories after theme uninstallation
72 + rmdir "${dir}"
73 + fi
74 + done
75 + eend ${retval}
76 + for f in "${fails[@]}" ; do
77 + eerror "Failed to update cache with icon $f"
78 + done
79 +}
80 +
81 +# @FUNCTION: _xdg_pkg_preinst
82 +# @DESCRIPTION: Forked from future xdg.eclass. REMOVEME!
83 +# Finds .desktop, icon and mime info files for later handling in pkg_postinst.
84 +# Locations are stored in XDG_ECLASS_DESKTOPFILES, XDG_ECLASS_ICONFILES
85 +# and XDG_ECLASS_MIMEINFOFILES respectively.
86 +_xdg_pkg_preinst() {
87 + local f
88 +
89 + XDG_ECLASS_DESKTOPFILES=()
90 + while IFS= read -r -d '' f; do
91 + XDG_ECLASS_DESKTOPFILES+=( ${f} )
92 + done < <(cd "${ED}" && find 'usr/share/applications' -type f -print0 2>/dev/null)
93 +
94 + XDG_ECLASS_ICONFILES=()
95 + while IFS= read -r -d '' f; do
96 + XDG_ECLASS_ICONFILES+=( ${f} )
97 + done < <(cd "${ED}" && find 'usr/share/icons' -type f -print0 2>/dev/null)
98 +
99 + XDG_ECLASS_MIMEINFOFILES=()
100 + while IFS= read -r -d '' f; do
101 + XDG_ECLASS_MIMEINFOFILES+=( ${f} )
102 + done < <(cd "${ED}" && find 'usr/share/mime' -type f -print0 2>/dev/null)
103 +}
104 +
105 +# @FUNCTION: _xdg_pkg_postinst
106 +# @DESCRIPTION: Forked from future xdg.eclass. REMOVEME!
107 +# Handle desktop, icon and mime info database updates.
108 +_xdg_pkg_postinst() {
109 + if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
110 + xdg_desktop_database_update
111 + else
112 + debug-print "No .desktop files to add to database"
113 + fi
114 +
115 + if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
116 + _xdg_icon_cache_update
117 + else
118 + debug-print "No icon files to add to cache"
119 + fi
120 +
121 + if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
122 + xdg_mimeinfo_database_update
123 + else
124 + debug-print "No mime info files to add to database"
125 + fi
126 +}
127 +
128 +# @FUNCTION: _xdg_pkg_postrm
129 +# @DESCRIPTION: Forked from future xdg.eclass. REMOVEME!
130 +# Handle desktop, icon and mime info database updates.
131 +_xdg_pkg_postrm() {
132 + if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
133 + xdg_desktop_database_update
134 + else
135 + debug-print "No .desktop files to add to database"
136 + fi
137 +
138 + if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
139 + _xdg_icon_cache_update
140 + else
141 + debug-print "No icon files to add to cache"
142 + fi
143 +
144 + if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
145 + xdg_mimeinfo_database_update
146 + else
147 + debug-print "No mime info files to add to database"
148 + fi
149 +}
150 +
151 # @FUNCTION: kde5_pkg_preinst
152 # @DESCRIPTION:
153 # Sets up environment variables required in kde5_pkg_postinst.
154 @@ -723,7 +838,8 @@ kde5_pkg_preinst() {
155 debug-print-function ${FUNCNAME} "$@"
156
157 [[ ${EAPI} == 6 ]] && gnome2_icon_savelist
158 - xdg_pkg_preinst
159 + [[ ${EAPI} == 6 ]] && xdg_pkg_preinst
160 + [[ ${EAPI} == 7 ]] && _xdg_pkg_preinst
161 }
162
163 # @FUNCTION: kde5_pkg_postinst
164 @@ -735,7 +851,8 @@ kde5_pkg_postinst() {
165 if [[ ${EAPI} == 6 && -n ${GNOME2_ECLASS_ICONS} ]]; then
166 gnome2_icon_cache_update
167 fi
168 - xdg_pkg_postinst
169 + [[ ${EAPI} == 6 ]] && xdg_pkg_postinst
170 + [[ ${EAPI} == 7 ]] && _xdg_pkg_postinst
171
172 if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
173 if [[ ${KDE_BUILD_TYPE} = live ]]; then
174 @@ -756,7 +873,8 @@ kde5_pkg_postrm() {
175 if [[ ${EAPI} == 6 && -n ${GNOME2_ECLASS_ICONS} ]]; then
176 gnome2_icon_cache_update
177 fi
178 - xdg_pkg_postrm
179 + [[ ${EAPI} == 6 ]] && xdg_pkg_postrm
180 + [[ ${EAPI} == 7 ]] && _xdg_pkg_postrm
181 }
182
183 fi