Gentoo Archives: gentoo-dev

From: "Marty E. Plummer" <hanetzer@×××××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 3/4] gnome2-utils: move icon functions into xdg-utils
Date: Wed, 20 Jun 2018 09:04:41
Message-Id: 20180620090332.kghnuxdygvz72nhm@proprietary-killer
In Reply to: Re: [gentoo-dev] [PATCH 3/4] gnome2-utils: move icon functions into xdg-utils by "Michał Górny"
1 On Wed, Jun 20, 2018 at 09:27:01AM +0200, Michał Górny wrote:
2 > W dniu śro, 20.06.2018 o godzinie 02∶10 -0500, użytkownik Marty E.
3 > Plummer napisał:
4 > > Kept some dummy stub functions in place in order to maintain
5 > > functionality of existing ebuilds, along with a QA warning to migrate
6 > > from one eclass to the other.
7 > > ---
8 > > eclass/gnome2-utils.eclass | 73 ++++++----------------------------
9 > > eclass/xdg-utils.eclass | 80 ++++++++++++++++++++++++++++++++++++++
10 > > 2 files changed, 91 insertions(+), 62 deletions(-)
11 > >
12 > > diff --git a/eclass/gnome2-utils.eclass b/eclass/gnome2-utils.eclass
13 > > index 14fb9e7420c..a355f0f4f13 100644
14 > > --- a/eclass/gnome2-utils.eclass
15 > > +++ b/eclass/gnome2-utils.eclass
16 > > @@ -40,12 +40,6 @@ esac
17 > > # Path to scrollkeeper-update
18 > > : ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
19 > >
20 > > -# @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
21 > > -# @INTERNAL
22 > > -# @DESCRIPTION:
23 > > -# Path to gtk-update-icon-cache
24 > > -: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
25 > > -
26 > > # @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
27 > > # @INTERNAL
28 > > # @DESCRIPTION:
29 > > @@ -203,68 +197,23 @@ gnome2_gconf_uninstall() {
30 > >
31 > > # @FUNCTION: gnome2_icon_savelist
32 > > # @DESCRIPTION:
33 > > -# Find the icons that are about to be installed and save their location
34 > > -# in the GNOME2_ECLASS_ICONS environment variable. This is only
35 > > -# necessary for eclass implementations that call
36 > > -# gnome2_icon_cache_update conditionally.
37 > > -# This function should be called from pkg_preinst.
38 > > +# Deprecated. Use xdg_icon_savelist from xdg-utils.eclass instead.
39 > > gnome2_icon_savelist() {
40 > > - has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
41 > > - pushd "${ED}" > /dev/null || die
42 > > - export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
43 > > - popd > /dev/null || die
44 > > + eqawarn "QA warning: gnome2_icon_savelist has been moved to xdg-utils.eclass"
45 > > + eqawarn "and is now called xdg_icon_savelist. Please migrate your ebuild and"
46 > > + eqawarn "eclasses to use it"
47 > > + xdg_icon_savelist
48 > > + GNOME2_ECLASS_ICONS="${XDG_ECLASS_ICONS}"
49 > > }
50 > >
51 > > # @FUNCTION: gnome2_icon_cache_update
52 > > # @DESCRIPTION:
53 > > -# Updates Gtk+ icon cache files under /usr/share/icons.
54 > > -# This function should be called from pkg_postinst and pkg_postrm.
55 > > +# Deprecated. Use xdg_icon_cache_update from xdg-utils.eclass instead.
56 > > gnome2_icon_cache_update() {
57 > > - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
58 > > - local updater="${EROOT%/}${GTK_UPDATE_ICON_CACHE}"
59 > > -
60 > > - if [[ ! -x "${updater}" ]] ; then
61 > > - debug-print "${updater} is not executable"
62 > > - return
63 > > - fi
64 > > -
65 > > - ebegin "Updating icons cache"
66 > > -
67 > > - local retval=0
68 > > - local fails=( )
69 > > -
70 > > - for dir in "${EROOT%/}"/usr/share/icons/*
71 > > - do
72 > > - if [[ -f "${dir}/index.theme" ]] ; then
73 > > - local rv=0
74 > > -
75 > > - "${updater}" -qf "${dir}"
76 > > - rv=$?
77 > > -
78 > > - if [[ ! $rv -eq 0 ]] ; then
79 > > - debug-print "Updating cache failed on ${dir}"
80 > > -
81 > > - # Add to the list of failures
82 > > - fails+=( "${dir}" )
83 > > -
84 > > - retval=2
85 > > - fi
86 > > - elif [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
87 > > - # Clear stale cache files after theme uninstallation
88 > > - rm "${dir}/icon-theme.cache"
89 > > - fi
90 > > -
91 > > - if [[ -z $(ls "${dir}") ]]; then
92 > > - # Clear empty theme directories after theme uninstallation
93 > > - rmdir "${dir}"
94 > > - fi
95 > > - done
96 > > -
97 > > - eend ${retval}
98 > > -
99 > > - for f in "${fails[@]}" ; do
100 > > - eerror "Failed to update cache with icon $f"
101 > > - done
102 > > + eqawarn "QA warning: gnome2_icon_cache_update has been moved to xdg-utils.eclass"
103 > > + eqawarn "and is now called xdg_icon_cache_update. Please migrate your ebuild and"
104 > > + eqawarn "eclasses to use it"
105 > > + xdg_icon_cache_update
106 > > }
107 > >
108 > > # @FUNCTION: gnome2_omf_fix
109 >
110 > 1. Why not make those two fatal in EAPI 7?
111 >
112 Sounds ok. There can currently be no EAPI 7 ebuilds for this, so any
113 ebuild which updates their eapi can do the migration then.
114 > 2. I don't think suddenly having a lot of ebuilds eqawarn about this
115 > in existing EAPIs is going to be productive.
116 >
117 Reasonable. I wasn't thinking in terms of that, since I wasn't making it
118 fatal in EAPI 7. Is there a non-ugly way to do multiline die statements?
119 > > diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass
120 > > index 8dba5ed6861..37e1893a701 100644
121 > > --- a/eclass/xdg-utils.eclass
122 > > +++ b/eclass/xdg-utils.eclass
123 > > @@ -31,6 +31,12 @@ esac
124 > > # Directory where .desktop files database is stored
125 > > : ${DESKTOP_DATABASE_DIR="/usr/share/applications"}
126 > >
127 > > +# @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
128 > > +# @INTERNAL
129 > > +# @DESCRIPTION:
130 > > +# Path to gtk-update-icon-cache
131 > > +: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
132 > > +
133 > > # @ECLASS-VARIABLE: MIMEINFO_DATABASE_UPDATE_BIN
134 > > # @INTERNAL
135 > > # @DESCRIPTION:
136 > > @@ -43,6 +49,12 @@ esac
137 > > # Directory where .desktop files database is stored
138 > > : ${MIMEINFO_DATABASE_DIR:="/usr/share/mime"}
139 > >
140 > > +# @ECLASS-VARIABLE: XDG_ECLASS_ICONS
141 > > +# @INTERNAL
142 > > +# @DEFAULT_UNSET
143 > > +# @DESCRIPTION:
144 > > +# List of icons provided by the package
145 > > +
146 > > # @FUNCTION: xdg_environment_reset
147 > > # @DESCRIPTION:
148 > > # Clean up environment for clean builds.
149 > > @@ -82,6 +94,74 @@ xdg_desktop_database_update() {
150 > > eend $?
151 > > }
152 > >
153 > > +# @FUNCTION: xdg_icon_savelist
154 > > +# @DESCRIPTION:
155 > > +# Find the icons that are about to be installed and save their location
156 > > +# in the XDG_ECLASS_ICONS environment variable. This is only
157 > > +# necessary for eclass implementations that call
158 > > +# xdg_icon_cache_update conditionally.
159 > > +# This function should be called from pkg_preinst.
160 > > +xdg_icon_savelist() {
161 > > + XDG_ECLASS_ICONS=()
162 > > + while IFS= read -r -d '' f; do
163 > > + XDG_ECLASS_ICONS+=( ${f} )
164 > > + done < <(cd "${D}" && find 'usr/share/icons' -type f -print0 2>/dev/null)
165 > > +
166 > > + export XDG_ECLASS_ICONS
167 > > +}
168 > > +
169 > > +# @FUNCTION: xdg_icon_cache_update
170 > > +# @DESCRIPTION:
171 > > +# Updates Gtk+ icon cache files under /usr/share/icons.
172 > > +# This function should be called from pkg_postinst and pkg_postrm.
173 > > +xdg_icon_cache_update() {
174 > > + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
175 > > + local updater="${EROOT%/}${GTK_UPDATE_ICON_CACHE}"
176 > > +
177 > > + if [[ ! -x "${updater}" ]] ; then
178 > > + debug-print "${updater} is not executable"
179 > > + return
180 > > + fi
181 > > +
182 > > + ebegin "Updating icons cache"
183 > > +
184 > > + local retval=0
185 > > + local fails=( )
186 > > +
187 > > + for dir in "${EROOT%/}"/usr/share/icons/*
188 > > + do
189 > > + if [[ -f "${dir}/index.theme" ]] ; then
190 > > + local rv=0
191 > > +
192 > > + "${updater}" -qf "${dir}"
193 > > + rv=$?
194 > > +
195 > > + if [[ ! $rv -eq 0 ]] ; then
196 > > + debug-print "Updating cache failed on ${dir}"
197 > > +
198 > > + # Add to the list of failures
199 > > + fails+=( "${dir}" )
200 > > +
201 > > + retval=2
202 > > + fi
203 > > + elif [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
204 > > + # Clear stale cache files after theme uninstallation
205 > > + rm "${dir}/icon-theme.cache"
206 > > + fi
207 > > +
208 > > + if [[ -z $(ls "${dir}") ]]; then
209 > > + # Clear empty theme directories after theme uninstallation
210 > > + rmdir "${dir}"
211 > > + fi
212 > > + done
213 > > +
214 > > + eend ${retval}
215 > > +
216 > > + for f in "${fails[@]}" ; do
217 > > + eerror "Failed to update cache with icon $f"
218 > > + done
219 > > +}
220 > > +
221 > > # @FUNCTION: xdg_mimeinfo_database_update
222 > > # @DESCRIPTION:
223 > > # Update the mime database.
224 >
225 > --
226 > Best regards,
227 > Michał Górny

Replies