/[gentoo-x86]/eclass/gdesklets.eclass
Gentoo

Diff of /eclass/gdesklets.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.11 Revision 1.20
1# Copyright 2004 Gentoo Foundation 1# Copyright 2004-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License, v2 or later
3# $Header: /var/cvsroot/gentoo-x86/eclass/gdesklets.eclass,v 1.11 2006/01/16 18:14:47 nixphoeni Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/gdesklets.eclass,v 1.20 2010/05/08 22:18:28 nixphoeni Exp $
4
5# @ECLASS: gdesklets.eclass
6# @MAINTAINER:
7# gdesklets@gentoo.org
8# @BLURB: Installation functions for Desklets and Controls supported
9# by gDesklets
10# @DESCRIPTION:
11# The gdesklets eclass provides a simple way to create ebuilds for
12# globally installing desktop applets ("Desklets") and supporting code
13# ("Controls") used in the gDesklets framework (provided by
14# gnome-extra/gdesklets-core)
4# 15#
5# Authors: Joe Sapp <nixphoeni@gentoo.org> 16# This eclass assumes a package following the instructions at
6# Mike Gardiner <obz@gentoo.org> 17# http://gdesklets.de/index.php?q=node/2 . Specifically, the package
18# should be a Desklet or Control ONLY (and *not* a Sensor). You
19# technically could have an ebuild that works around this limitation,
20# but no new packages should be added to the tree that do this (mainly
21# for ease of maintenance).
7# 22#
8# Usage: 23# Original authors: Joe Sapp <nixphoeni@gentoo.org>
9# As a writer for an ebuild for gDesklets, you should set a few things: 24# Mike Gardiner <obz@gentoo.org>
10#
11# DESKLET_NAME: The name of the desklet.
12# DOCS: Anything (like a README) that should be dodoc'd.
13# S: *Optional* The package's base directory.
14# Usually ${WORKDIR}/${DESKLET_NAME} if it was packaged
15# correctly (hence, this is the default).
16# RDEPEND: *Optional* Set if the desklet requires a minimum version
17# of gDesklets greater than 0.34 or other packages.
18 25
19inherit eutils multilib 26# @ECLASS_VARIABLE: DESKLET_NAME
27# @DESCRIPTION:
28# *Optional* The name of the Desklet, if the package is one. The
29# default is to assume a Desklet with the name being ${PN} without the
30# "desklet-" prefix.
20 31
32# @ECLASS_VARIABLE: CONTROL_NAME
33# @DESCRIPTION:
34# *Optional* The name of the Control, if the package is one.
21 35
22MY_P="${DESKLET_NAME}-${PV}" 36# @ECLASS_VARIABLE: DOCS
23S=${WORKDIR}/${DESKLET_NAME} 37# @DESCRIPTION:
38# Anything (like a README) that should be dodoc'd.
24 39
25SRC_URI="http://gdesklets.gnomedesktop.org/files/${MY_P}.tar.gz" 40# @ECLASS_VARIABLE: SLOT
41# @DESCRIPTION:
42# Set only if the package is a Control and it provides a different
43# interface (i.e. expands to a different install directory) than a
44# previous version.
26 45
27# Ebuild writer shouldn't need to touch these (except maybe $RDEPEND) 46inherit eutils multilib python
47
48if [[ -n "${CONTROL_NAME}" ]]; then
49 debug-print "Looking for a Control named \"${CONTROL_NAME}\""
50 MY_PN="${CONTROL_NAME}"
51 SRC_URI="http://gdesklets.de/files/controls/${MY_PN}/${MY_PN}-${PV}.tar.gz"
52 unset DESKLET_NAME
53else # [[ -n "${DESKLET_NAME}" ]]; then
54 # Assume an unset DESKLET_NAME means the name is ${PN} without
55 # the "desklet-" prefix
56 [[ -z "${DESKLET_NAME}" ]] && DESKLET_NAME="${PN#desklet-}"
57 debug-print "Looking for a Desklet named \"${DESKLET_NAME}\""
58 MY_PN="${DESKLET_NAME}"
59 SRC_URI="http://gdesklets.de/files/desklets/${MY_PN}/${MY_PN}-${PV}.tar.gz"
60fi
61
62MY_P="${MY_PN}-${PV}"
63S="${WORKDIR}/${MY_PN}"
64
28SLOT="0" 65SLOT="0"
66# Ebuild writer shouldn't need to touch these (except maybe RDEPEND)
29IUSE="" 67IUSE=""
30RDEPEND=">=gnome-extra/gdesklets-core-0.34.3-r1" 68RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3"
31 69
32GDESKLETS_INST_DIR="/usr/$(get_libdir)/gdesklets" 70GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets"
33 71
72# @FUNCTION: gdesklets_src_install
73# @DESCRIPTION:
74# Installs a Desklet or Control depending on which is set of
75# CONTROL_NAME or DESKLET_NAME
34gdesklets_src_install() { 76gdesklets_src_install() {
35 77
36 debug-print-function $FUNCNAME $* 78 debug-print-function $FUNCNAME $*
37 79
38 has_version ">=gnome-extra/gdesklets-core-0.33.1" || \ 80 # Disable compilation of included python modules (for Controls)
39 GDESKLETS_INST_DIR="/usr/share/gdesklets" 81 python_disable_pyc
40 82
41 # This should be done by the gdesklets-core ebuild 83 # Avoid sandbox violations caused by misbehaving packages (bug #128289)
42 # It makes the Displays or Controls directory in the 84 addwrite "${ROOT}/root/.gnome2"
43 # global installation directory if it doesn't exist
44 [[ -d ${GDESKLETS_INST_DIR}/Displays ]] || \
45 dodir ${GDESKLETS_INST_DIR}/Displays
46 85
47 # The displays only need to be readable 86 # Both Displays and Controls only need to be readable
48 insopts -m0744 87 insopts -m0744
49 88
50 # Check to see if DISPLAY is set for the 89 debug-print-section docs_install
51 # gdesklets-control-getid script to run without
52 # error
53 [ -z "${DISPLAY}" ] && DISPLAY=""
54 export DISPLAY
55 90
56 debug-print-section sensor_install 91 # Install some docs if so requested (and then delete them so they
57 # First, install the Sensor (if there is one) 92 # don't get copied into the installation directory)
58 if [[ -n "${SENSOR_NAME}" ]]; then 93 [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
59 for SENS in ${SENSOR_NAME[@]}; do 94 rm -f ${DOCS} \
60 einfo "Installing Sensor ${SENS}" 95 debug-print "Installed and deleted ${DOCS}"
61 /usr/bin/python "Install_${SENS}_Sensor.bin" \ 96 # LICENSE doesn't need to get installed if it exists
62 --nomsg ${D}${GDESKLETS_INST_DIR}/Sensors || \ 97 find . -name LICENSE -delete
63 die "Couldn't Install Sensor"
64 98
65 chown -R root:0 ${D}${GDESKLETS_INST_DIR}/Sensors/${SENSOR_NAME} 99 if [[ -n "${DESKLET_NAME}" ]]; then
66 done # for in ${SENSOR_NAME}
67 fi # if -n "${SENSOR_NAME}"
68 100
69 debug-print-section display_install 101 debug-print-section display_install
70 # This finds the Displays
71 DISPLAY_FILES=(`find . -iname "*.display"`)
72 102
73 DESKLET_INSDIR="" 103 # Base installation directory for displays from this desklet
104 INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
74 105
75 # There is most likely only one display per package 106 debug-print "Installing into ${INSDIR}"
76 if [[ -n "${DISPLAY_FILES[@]}" ]]; then 107 debug-print "Exiting Display-specific installation code"
77 # Base installation directory for displays from this desklet
78 DESKLET_INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
79 108
80 # This creates the subdirectory of ${DESKLET_NAME} 109 elif [[ -n "${CONTROL_NAME}" ]]; then
81 # in the global Displays directory
82 [[ -d ${DESKLET_INSDIR} ]] || \
83 dodir ${DESKLET_INSDIR}
84 110
85 # For each of the Display files, there may be 111 debug-print-section control_install
86 # scripts included inline which don't necessarily
87 # follow any naming scheme.
88 # So for each of them, determine what those scripts are
89 # and install them.
90 for DSP in ${DISPLAY_FILES[@]}; do
91 112
92 cd `dirname ${DSP}` 113 # Unique name for this Control and its interface
93 einfo "Installing Display `basename ${DSP} .display`" 114 CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
94 debug-print "Installing ${DSP} into ${DESKLET_INSDIR}" 115 einfo "Installing Control ${CTRL_DIRNAME}"
95 DSP=`basename ${DSP}`
96 insinto ${DESKLET_INSDIR}
97 doins ${DSP}
98 116
99 SCRIPTS=$(grep "script .*uri" ${DSP} | \ 117 # Base installation directory for this Control
100 sed -e 's:.*<script .*uri=": :g' -e 's:"/>.*: :g') 118 INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
119 debug-print "Installing into ${INSDIR}"
101 120
102 # For each one of the scripts, change to its 121 # Mercilessly delete all existing compiled code
103 # base directory and change the install location 122 find . -iname '*.py[co]' -delete
104 # so it gets installed at the proper place
105 # relative to the display.
106 for SCR in ${SCRIPTS[@]}; do
107 123
108 cd `dirname ${SCR}` 124 debug-print "Exiting Control-specific installation code"
109 125
110 insinto ${DESKLET_INSDIR}/`dirname ${SCR}` 126 else
111 doins `basename ${SCR}` 127 die "nothing to install, is the ebuild written correctly?"
112 debug-print "Installed `basename ${SCR}` into ${DESKLET_INSDIR}/`dirname ${SCR}`" 128 fi
113 129
114 cd ${S}/`dirname ${DSP}` 130 debug-print-section common_install
115 131
116 done # for in ${SCRIPTS} 132 # Create the proper subdirectory in the global Controls or
133 # Displays directory
134 dodir "${INSDIR}"
135 insinto "${INSDIR}"
136 doins -r *
117 137
118 # Install the graphics for this display. 138}
119 # If there are multiple displays in this
120 # directory, this will be done more than
121 # once. It's the only solution I can
122 # come up with for now...
123 GFX=(`find . \
124 -iname "*.png" -o -iname "*.svg" \
125 -o -iname "*.jpg" -o -iname "*.gif" \
126 -o -iname "*.xcf"`)
127 139
128 for G in ${GFX[@]}; do 140# @FUNCTION: gdesklets_pkg_postinst
141# @DESCRIPTION:
142# Marks the Control for rebuilding on Python version change and
143# compiles the Python code or display a useful message to the user,
144# depending on which of CONTROL_NAME or DESKLET_NAME is set.
145gdesklets_pkg_postinst() {
129 146
130 insinto ${DESKLET_INSDIR}/`dirname ${G}` 147 # The only time compilation of python modules should occur is
131 doins ${G} 148 # for Controls, since Displays are run from inside the sandbox
132 debug-print "Installed ${G} into ${DESKLET_INSDIR}/`dirname ${G}`" 149 # (and therefore can't be compiled).
150 if [[ -n "${CONTROL_NAME}" ]]; then
133 151
134 done # for in ${GFX} 152 CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
153 python_need_rebuild
154 python_mod_optimize "${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
135 155
136 cd ${S} 156 else
137 157
138 done # for in ${DISPLAY_FILES} 158 einfo "Each user can now add this desklet to their desktop through the"
159 einfo "gDesklets shell or the command line (.display files can be"
160 einfo "found in ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME})."
139 161
140 fi 162 fi
141 163
142 debug-print-section control_install
143
144 CONTROL_INSDIR=""
145
146 # Make sure that it only finds Controls and not Sensors
147 # If it uses a Sensor, it shouldn't use a Control (since
148 # Sensors are deprecated).
149 if [[ -z "${SENSOR_NAME}" ]]; then
150
151 # Base installation directory for Controls
152 CONTROL_INSDIR="${GDESKLETS_INST_DIR}/Controls"
153
154 CONTROL_INITS=$(find . -iname "__init__.py" | grep [Cc]ontrols)
155
156 # There are possibly multiple Controls packaged with the display.
157 # For each __init__.py found, there must be a Control associated with it.
158 for CTRL in ${CONTROL_INITS[@]}; do
159
160 cd `dirname ${CTRL}`
161 CTRL_NAME=$( PYTHON_DONTCOMPILE=1 ${GDESKLETS_INST_DIR}/gdesklets-control-getid `pwd` )
162 einfo "Installing Control ${CTRL_NAME}"
163 # This creates the subdirectory of ${CTRL_NAME}
164 # in the global Controls directory
165 [[ -d ${CONTROL_INSDIR}/${CTRL_NAME} ]] || \
166 dodir ${CONTROL_INSDIR}/${CTRL_NAME}
167
168 insinto ${CONTROL_INSDIR}/${CTRL_NAME}
169
170 doins -r *
171
172 cd ${S}
173
174 done # for in ${CONTROL_INITS}
175
176 fi # if no Sensors
177
178 # Install any remaining graphics and other files
179 # that are sitting in ${S}.
180
181 GFX=$(find . -maxdepth 1 \
182 -iname "*.png" -o -iname "*.svg" \
183 -o -iname "*.jpg" -o -iname "*.gif" \
184 -o -iname "*.xcf")
185
186 if [[ -n "${GFX}" ]]; then
187
188 # Install to the Displays directory of the Desklet
189 insinto ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}
190 doins ${GFX}
191 debug-print "Installed ${GFX} into ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
192
193 fi # if -n "${GFX}"
194
195 # Install some docs if so requested
196 [[ -n "${DOCS}" ]] && dodoc ${DOCS}
197 debug-print "Installed ${DOCS}"
198
199} 164}
200 165
201
202EXPORT_FUNCTIONS src_install 166EXPORT_FUNCTIONS src_install pkg_postinst

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20