Gentoo Archives: gentoo-commits

From: "Joe Sapp (nixphoeni)" <nixphoeni@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: gdesklets.eclass
Date: Sat, 08 May 2010 22:18:32
Message-Id: 20100508221828.78C4F2C3FA@corvid.gentoo.org
1 nixphoeni 10/05/08 22:18:28
2
3 Modified: gdesklets.eclass
4 Log:
5 Simplified the eclass, since the rules for desklet and control submission have become much more standardized recently (http://gdesklets.de/index.php?q=node/2). This also means that we will no longer support sensors and sensor-based desklets. No more desklets that do not heed these rules will be put into portage.
6
7 Revision Changes Path
8 1.20 eclass/gdesklets.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gdesklets.eclass?rev=1.20&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gdesklets.eclass?rev=1.20&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gdesklets.eclass?r1=1.19&r2=1.20
13
14 Index: gdesklets.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/gdesklets.eclass,v
17 retrieving revision 1.19
18 retrieving revision 1.20
19 diff -u -r1.19 -r1.20
20 --- gdesklets.eclass 8 May 2010 19:04:04 -0000 1.19
21 +++ gdesklets.eclass 8 May 2010 22:18:28 -0000 1.20
22 @@ -1,199 +1,166 @@
23 -# Copyright 2004-2006 Gentoo Foundation
24 +# Copyright 2004-2010 Gentoo Foundation
25 # Distributed under the terms of the GNU General Public License, v2 or later
26 -# $Header: /var/cvsroot/gentoo-x86/eclass/gdesklets.eclass,v 1.19 2010/05/08 19:04:04 nixphoeni Exp $
27 -#
28 -# Authors: Joe Sapp <nixphoeni@g.o>
29 -# Mike Gardiner <obz@g.o>
30 +# $Header: /var/cvsroot/gentoo-x86/eclass/gdesklets.eclass,v 1.20 2010/05/08 22:18:28 nixphoeni Exp $
31 +
32 +# @ECLASS: gdesklets.eclass
33 +# @MAINTAINER:
34 +# gdesklets@g.o
35 +# @BLURB: Installation functions for Desklets and Controls supported
36 +# by gDesklets
37 +# @DESCRIPTION:
38 +# The gdesklets eclass provides a simple way to create ebuilds for
39 +# globally installing desktop applets ("Desklets") and supporting code
40 +# ("Controls") used in the gDesklets framework (provided by
41 +# gnome-extra/gdesklets-core)
42 #
43 -# Usage:
44 -# As a writer for an ebuild for gDesklets, you should set a few things:
45 +# This eclass assumes a package following the instructions at
46 +# http://gdesklets.de/index.php?q=node/2 . Specifically, the package
47 +# should be a Desklet or Control ONLY (and *not* a Sensor). You
48 +# technically could have an ebuild that works around this limitation,
49 +# but no new packages should be added to the tree that do this (mainly
50 +# for ease of maintenance).
51 #
52 -# DESKLET_NAME: The name of the desklet.
53 -# DOCS: Anything (like a README) that should be dodoc'd.
54 -# S: *Optional* The package's base directory.
55 -# Usually ${WORKDIR}/${DESKLET_NAME} if it was packaged
56 -# correctly (hence, this is the default).
57 -# RDEPEND: *Optional* Set if the desklet requires a minimum version
58 -# of gDesklets greater than 0.34 or other packages.
59 +# Original authors: Joe Sapp <nixphoeni@g.o>
60 +# Mike Gardiner <obz@g.o>
61 +
62 +# @ECLASS_VARIABLE: DESKLET_NAME
63 +# @DESCRIPTION:
64 +# *Optional* The name of the Desklet, if the package is one. The
65 +# default is to assume a Desklet with the name being ${PN} without the
66 +# "desklet-" prefix.
67 +
68 +# @ECLASS_VARIABLE: CONTROL_NAME
69 +# @DESCRIPTION:
70 +# *Optional* The name of the Control, if the package is one.
71 +
72 +# @ECLASS_VARIABLE: DOCS
73 +# @DESCRIPTION:
74 +# Anything (like a README) that should be dodoc'd.
75 +
76 +# @ECLASS_VARIABLE: SLOT
77 +# @DESCRIPTION:
78 +# Set only if the package is a Control and it provides a different
79 +# interface (i.e. expands to a different install directory) than a
80 +# previous version.
81
82 inherit eutils multilib python
83
84 +if [[ -n "${CONTROL_NAME}" ]]; then
85 + debug-print "Looking for a Control named \"${CONTROL_NAME}\""
86 + MY_PN="${CONTROL_NAME}"
87 + SRC_URI="http://gdesklets.de/files/controls/${MY_PN}/${MY_PN}-${PV}.tar.gz"
88 + unset DESKLET_NAME
89 +else # [[ -n "${DESKLET_NAME}" ]]; then
90 + # Assume an unset DESKLET_NAME means the name is ${PN} without
91 + # the "desklet-" prefix
92 + [[ -z "${DESKLET_NAME}" ]] && DESKLET_NAME="${PN#desklet-}"
93 + debug-print "Looking for a Desklet named \"${DESKLET_NAME}\""
94 + MY_PN="${DESKLET_NAME}"
95 + SRC_URI="http://gdesklets.de/files/desklets/${MY_PN}/${MY_PN}-${PV}.tar.gz"
96 +fi
97
98 -MY_PN="${DESKLET_NAME}"
99 MY_P="${MY_PN}-${PV}"
100 -S="${WORKDIR}/${DESKLET_NAME}"
101 +S="${WORKDIR}/${MY_PN}"
102
103 -SRC_URI="http://gdesklets.de/files/desklets/${MY_PN}/${MY_P}.tar.gz"
104 -
105 -# Ebuild writer shouldn't need to touch these (except maybe $RDEPEND)
106 SLOT="0"
107 +# Ebuild writer shouldn't need to touch these (except maybe RDEPEND)
108 IUSE=""
109 -RDEPEND=">=gnome-extra/gdesklets-core-0.34.3-r1"
110 +RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3"
111
112 GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets"
113
114 +# @FUNCTION: gdesklets_src_install
115 +# @DESCRIPTION:
116 +# Installs a Desklet or Control depending on which is set of
117 +# CONTROL_NAME or DESKLET_NAME
118 gdesklets_src_install() {
119
120 debug-print-function $FUNCNAME $*
121
122 - # Disable compilation of included python modules (Controls)
123 + # Disable compilation of included python modules (for Controls)
124 python_disable_pyc
125
126 - # Do not remove - see bugs 126890 and 128289
127 + # Avoid sandbox violations caused by misbehaving packages (bug #128289)
128 addwrite "${ROOT}/root/.gnome2"
129
130 - has_version ">=gnome-extra/gdesklets-core-0.33.1" || \
131 - GDESKLETS_INST_DIR="/usr/share/gdesklets"
132 -
133 - # This should be done by the gdesklets-core ebuild
134 - # It makes the Displays or Controls directory in the
135 - # global installation directory if it doesn't exist
136 - [[ -d "${GDESKLETS_INST_DIR}/Displays" ]] || \
137 - dodir "${GDESKLETS_INST_DIR}/Displays"
138 -
139 - # The displays only need to be readable
140 + # Both Displays and Controls only need to be readable
141 insopts -m0744
142
143 - debug-print-section sensor_install
144 - # First, install the Sensor (if there is one)
145 - if [[ -n "${SENSOR_NAME}" ]]; then
146 - for SENS in ${SENSOR_NAME[@]}; do
147 - einfo "Installing Sensor ${SENS}"
148 - /usr/bin/python "Install_${SENS}_Sensor.bin" \
149 - --nomsg "${D}${GDESKLETS_INST_DIR}/Sensors" || \
150 - die "Couldn't Install Sensor"
151 -
152 - chown -R root:0 "${D}${GDESKLETS_INST_DIR}/Sensors/${SENSOR_NAME}"
153 - done # for in ${SENSOR_NAME}
154 - fi # if -n "${SENSOR_NAME}"
155 -
156 - debug-print-section display_install
157 - # This finds the Displays
158 - DISPLAY_FILES=(`find . -iname "*.display"`)
159 -
160 - DESKLET_INSDIR=""
161 -
162 - # There is most likely only one display per package
163 - if [[ -n "${DISPLAY_FILES[@]}" ]]; then
164 - # Base installation directory for displays from this desklet
165 - DESKLET_INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
166 -
167 - # This creates the subdirectory of ${DESKLET_NAME}
168 - # in the global Displays directory
169 - [[ -d "${DESKLET_INSDIR}" ]] || \
170 - dodir "${DESKLET_INSDIR}"
171 -
172 - # For each of the Display files, there may be
173 - # scripts included inline which don't necessarily
174 - # follow any naming scheme.
175 - # So for each of them, determine what those scripts are
176 - # and install them.
177 - for DSP in ${DISPLAY_FILES[@]}; do
178 -
179 - cd `dirname ${DSP}`
180 - einfo "Installing Display `basename ${DSP} .display`"
181 - debug-print "Installing ${DSP} into ${DESKLET_INSDIR}"
182 - DSP=`basename ${DSP}`
183 - insinto "${DESKLET_INSDIR}"
184 - doins "${DSP}"
185 -
186 - SCRIPTS=$(grep "script .*uri" ${DSP} | \
187 - sed -e "s:.*<script\b.*\buri=[\"']: :g" -e "s:[\"'].*/>.*: :g")
188 -
189 - # For each one of the scripts, change to its
190 - # base directory and change the install location
191 - # so it gets installed at the proper place
192 - # relative to the display.
193 - for SCR in ${SCRIPTS[@]}; do
194 -
195 - insinto "${DESKLET_INSDIR}/`dirname ${SCR}`"
196 - doins "${SCR}"
197 - debug-print "Installed ${SCR} into ${DESKLET_INSDIR}/`dirname ${SCR}`"
198 -
199 - done # for in ${SCRIPTS}
200 -
201 - # Install the graphics for this display.
202 - # If there are multiple displays in this
203 - # directory, this will be done more than
204 - # once. It's the only solution I can
205 - # come up with for now...
206 - GFX=(`find . \
207 - -iname "*.png" -o -iname "*.svg" \
208 - -o -iname "*.jpg" -o -iname "*.gif" \
209 - -o -iname "*.xcf"`)
210 -
211 - for G in ${GFX[@]}; do
212 -
213 - insinto "${DESKLET_INSDIR}/`dirname ${G}`"
214 - doins "${G}"
215 - debug-print "Installed ${G} into ${DESKLET_INSDIR}/`dirname ${G}`"
216 -
217 - done # for in ${GFX}
218 -
219 - cd "${S}"
220 + debug-print-section docs_install
221
222 - done # for in ${DISPLAY_FILES}
223 -
224 - fi
225 -
226 - debug-print-section control_install
227 -
228 - CONTROL_INSDIR=""
229 + # Install some docs if so requested (and then delete them so they
230 + # don't get copied into the installation directory)
231 + [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
232 + rm -f ${DOCS} \
233 + debug-print "Installed and deleted ${DOCS}"
234 + # LICENSE doesn't need to get installed if it exists
235 + find . -name LICENSE -delete
236
237 - # Make sure that it only finds Controls and not Sensors
238 - # If it uses a Sensor, it shouldn't use a Control (since
239 - # Sensors are deprecated).
240 - if [[ -z "${SENSOR_NAME}" ]]; then
241 + if [[ -n "${DESKLET_NAME}" ]]; then
242
243 - # Base installation directory for Controls
244 - CONTROL_INSDIR="${GDESKLETS_INST_DIR}/Controls"
245 + debug-print-section display_install
246
247 - CONTROL_INITS=$(find . -iname "__init__.py")
248 + # Base installation directory for displays from this desklet
249 + INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
250
251 - # There are possibly multiple Controls packaged with the display.
252 - # For each __init__.py found, there must be a Control associated with it.
253 - for CTRL in ${CONTROL_INITS[@]}; do
254 + debug-print "Installing into ${INSDIR}"
255 + debug-print "Exiting Display-specific installation code"
256
257 - cd `dirname ${CTRL}`
258 - CTRL_NAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
259 - einfo "Installing Control ${CTRL_NAME}"
260 - # This creates the subdirectory of ${CTRL_NAME}
261 - # in the global Controls directory
262 - [[ -d "${CONTROL_INSDIR}/${CTRL_NAME}" ]] || \
263 - dodir "${CONTROL_INSDIR}/${CTRL_NAME}"
264 + elif [[ -n "${CONTROL_NAME}" ]]; then
265
266 - insinto "${CONTROL_INSDIR}/${CTRL_NAME}"
267 + debug-print-section control_install
268
269 - doins -r *.py
270 + # Unique name for this Control and its interface
271 + CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
272 + einfo "Installing Control ${CTRL_DIRNAME}"
273
274 - cd "${S}"
275 + # Base installation directory for this Control
276 + INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
277 + debug-print "Installing into ${INSDIR}"
278
279 - done # for in ${CONTROL_INITS}
280 + # Mercilessly delete all existing compiled code
281 + find . -iname '*.py[co]' -delete
282
283 - fi # if no Sensors
284 + debug-print "Exiting Control-specific installation code"
285
286 - # Install any remaining graphics and other files
287 - # that are sitting in ${S}.
288 + else
289 + die "nothing to install, is the ebuild written correctly?"
290 + fi
291
292 - GFX=$(find . -maxdepth 1 \
293 - -iname "*.png" -o -iname "*.svg" \
294 - -o -iname "*.jpg" -o -iname "*.gif" \
295 - -o -iname "*.xcf")
296 + debug-print-section common_install
297
298 - if [[ -n "${GFX}" ]]; then
299 + # Create the proper subdirectory in the global Controls or
300 + # Displays directory
301 + dodir "${INSDIR}"
302 + insinto "${INSDIR}"
303 + doins -r *
304
305 - # Install to the Displays directory of the Desklet
306 - insinto "${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
307 - doins "${GFX}"
308 - debug-print "Installed ${GFX} into ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
309 +}
310
311 - fi # if -n "${GFX}"
312 +# @FUNCTION: gdesklets_pkg_postinst
313 +# @DESCRIPTION:
314 +# Marks the Control for rebuilding on Python version change and
315 +# compiles the Python code or display a useful message to the user,
316 +# depending on which of CONTROL_NAME or DESKLET_NAME is set.
317 +gdesklets_pkg_postinst() {
318 +
319 + # The only time compilation of python modules should occur is
320 + # for Controls, since Displays are run from inside the sandbox
321 + # (and therefore can't be compiled).
322 + if [[ -n "${CONTROL_NAME}" ]]; then
323 +
324 + CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
325 + python_need_rebuild
326 + python_mod_optimize "${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
327 +
328 + else
329 +
330 + einfo "Each user can now add this desklet to their desktop through the"
331 + einfo "gDesklets shell or the command line (.display files can be"
332 + einfo "found in ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME})."
333
334 - # Install some docs if so requested
335 - [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
336 - debug-print "Installed ${DOCS}"
337 + fi
338
339 }
340
341 -
342 -EXPORT_FUNCTIONS src_install
343 +EXPORT_FUNCTIONS src_install pkg_postinst