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

Diff of /eclass/gdesklets.eclass

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

Revision 1.19 Revision 1.20
1# Copyright 2004-2006 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.19 2010/05/08 19:04:04 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# 25
11# DESKLET_NAME: The name of the desklet. 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.
31
32# @ECLASS_VARIABLE: CONTROL_NAME
33# @DESCRIPTION:
34# *Optional* The name of the Control, if the package is one.
35
36# @ECLASS_VARIABLE: DOCS
37# @DESCRIPTION:
12# DOCS: Anything (like a README) that should be dodoc'd. 38# Anything (like a README) that should be dodoc'd.
13# S: *Optional* The package's base directory. 39
14# Usually ${WORKDIR}/${DESKLET_NAME} if it was packaged 40# @ECLASS_VARIABLE: SLOT
15# correctly (hence, this is the default). 41# @DESCRIPTION:
16# RDEPEND: *Optional* Set if the desklet requires a minimum version 42# Set only if the package is a Control and it provides a different
17# of gDesklets greater than 0.34 or other packages. 43# interface (i.e. expands to a different install directory) than a
44# previous version.
18 45
19inherit eutils multilib python 46inherit eutils multilib python
20 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
21 61
22MY_PN="${DESKLET_NAME}"
23MY_P="${MY_PN}-${PV}" 62MY_P="${MY_PN}-${PV}"
24S="${WORKDIR}/${DESKLET_NAME}" 63S="${WORKDIR}/${MY_PN}"
25 64
26SRC_URI="http://gdesklets.de/files/desklets/${MY_PN}/${MY_P}.tar.gz"
27
28# Ebuild writer shouldn't need to touch these (except maybe $RDEPEND)
29SLOT="0" 65SLOT="0"
66# Ebuild writer shouldn't need to touch these (except maybe RDEPEND)
30IUSE="" 67IUSE=""
31RDEPEND=">=gnome-extra/gdesklets-core-0.34.3-r1" 68RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3"
32 69
33GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets" 70GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets"
34 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
35gdesklets_src_install() { 76gdesklets_src_install() {
36 77
37 debug-print-function $FUNCNAME $* 78 debug-print-function $FUNCNAME $*
38 79
39 # Disable compilation of included python modules (Controls) 80 # Disable compilation of included python modules (for Controls)
40 python_disable_pyc 81 python_disable_pyc
41 82
42 # Do not remove - see bugs 126890 and 128289 83 # Avoid sandbox violations caused by misbehaving packages (bug #128289)
43 addwrite "${ROOT}/root/.gnome2" 84 addwrite "${ROOT}/root/.gnome2"
44 85
45 has_version ">=gnome-extra/gdesklets-core-0.33.1" || \
46 GDESKLETS_INST_DIR="/usr/share/gdesklets"
47
48 # This should be done by the gdesklets-core ebuild
49 # It makes the Displays or Controls directory in the
50 # global installation directory if it doesn't exist
51 [[ -d "${GDESKLETS_INST_DIR}/Displays" ]] || \
52 dodir "${GDESKLETS_INST_DIR}/Displays"
53
54 # The displays only need to be readable 86 # Both Displays and Controls only need to be readable
55 insopts -m0744 87 insopts -m0744
56 88
57 debug-print-section sensor_install 89 debug-print-section docs_install
58 # First, install the Sensor (if there is one)
59 if [[ -n "${SENSOR_NAME}" ]]; then
60 for SENS in ${SENSOR_NAME[@]}; do
61 einfo "Installing Sensor ${SENS}"
62 /usr/bin/python "Install_${SENS}_Sensor.bin" \
63 --nomsg "${D}${GDESKLETS_INST_DIR}/Sensors" || \
64 die "Couldn't Install Sensor"
65 90
66 chown -R root:0 "${D}${GDESKLETS_INST_DIR}/Sensors/${SENSOR_NAME}" 91 # Install some docs if so requested (and then delete them so they
67 done # for in ${SENSOR_NAME} 92 # don't get copied into the installation directory)
68 fi # if -n "${SENSOR_NAME}" 93 [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
94 rm -f ${DOCS} \
95 debug-print "Installed and deleted ${DOCS}"
96 # LICENSE doesn't need to get installed if it exists
97 find . -name LICENSE -delete
69 98
70 debug-print-section display_install 99 if [[ -n "${DESKLET_NAME}" ]]; then
71 # This finds the Displays
72 DISPLAY_FILES=(`find . -iname "*.display"`)
73 100
74 DESKLET_INSDIR="" 101 debug-print-section display_install
75 102
76 # There is most likely only one display per package
77 if [[ -n "${DISPLAY_FILES[@]}" ]]; then
78 # Base installation directory for displays from this desklet 103 # Base installation directory for displays from this desklet
79 DESKLET_INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}" 104 INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
80 105
81 # This creates the subdirectory of ${DESKLET_NAME} 106 debug-print "Installing into ${INSDIR}"
82 # in the global Displays directory 107 debug-print "Exiting Display-specific installation code"
83 [[ -d "${DESKLET_INSDIR}" ]] || \
84 dodir "${DESKLET_INSDIR}"
85 108
86 # For each of the Display files, there may be 109 elif [[ -n "${CONTROL_NAME}" ]]; then
87 # scripts included inline which don't necessarily
88 # follow any naming scheme.
89 # So for each of them, determine what those scripts are
90 # and install them.
91 for DSP in ${DISPLAY_FILES[@]}; do
92 110
93 cd `dirname ${DSP}` 111 debug-print-section control_install
94 einfo "Installing Display `basename ${DSP} .display`"
95 debug-print "Installing ${DSP} into ${DESKLET_INSDIR}"
96 DSP=`basename ${DSP}`
97 insinto "${DESKLET_INSDIR}"
98 doins "${DSP}"
99 112
100 SCRIPTS=$(grep "script .*uri" ${DSP} | \ 113 # Unique name for this Control and its interface
101 sed -e "s:.*<script\b.*\buri=[\"']: :g" -e "s:[\"'].*/>.*: :g") 114 CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
115 einfo "Installing Control ${CTRL_DIRNAME}"
102 116
103 # For each one of the scripts, change to its 117 # Base installation directory for this Control
104 # base directory and change the install location 118 INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
105 # so it gets installed at the proper place 119 debug-print "Installing into ${INSDIR}"
106 # relative to the display.
107 for SCR in ${SCRIPTS[@]}; do
108 120
109 insinto "${DESKLET_INSDIR}/`dirname ${SCR}`" 121 # Mercilessly delete all existing compiled code
110 doins "${SCR}" 122 find . -iname '*.py[co]' -delete
111 debug-print "Installed ${SCR} into ${DESKLET_INSDIR}/`dirname ${SCR}`"
112 123
113 done # for in ${SCRIPTS} 124 debug-print "Exiting Control-specific installation code"
114 125
115 # Install the graphics for this display. 126 else
116 # If there are multiple displays in this 127 die "nothing to install, is the ebuild written correctly?"
117 # directory, this will be done more than 128 fi
118 # once. It's the only solution I can
119 # come up with for now...
120 GFX=(`find . \
121 -iname "*.png" -o -iname "*.svg" \
122 -o -iname "*.jpg" -o -iname "*.gif" \
123 -o -iname "*.xcf"`)
124 129
125 for G in ${GFX[@]}; do 130 debug-print-section common_install
126 131
127 insinto "${DESKLET_INSDIR}/`dirname ${G}`" 132 # Create the proper subdirectory in the global Controls or
128 doins "${G}" 133 # Displays directory
129 debug-print "Installed ${G} into ${DESKLET_INSDIR}/`dirname ${G}`" 134 dodir "${INSDIR}"
135 insinto "${INSDIR}"
136 doins -r *
130 137
131 done # for in ${GFX} 138}
132 139
133 cd "${S}" 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() {
134 146
135 done # for in ${DISPLAY_FILES} 147 # The only time compilation of python modules should occur is
148 # for Controls, since Displays are run from inside the sandbox
149 # (and therefore can't be compiled).
150 if [[ -n "${CONTROL_NAME}" ]]; then
151
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}"
155
156 else
157
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})."
136 161
137 fi 162 fi
138 163
139 debug-print-section control_install
140
141 CONTROL_INSDIR=""
142
143 # Make sure that it only finds Controls and not Sensors
144 # If it uses a Sensor, it shouldn't use a Control (since
145 # Sensors are deprecated).
146 if [[ -z "${SENSOR_NAME}" ]]; then
147
148 # Base installation directory for Controls
149 CONTROL_INSDIR="${GDESKLETS_INST_DIR}/Controls"
150
151 CONTROL_INITS=$(find . -iname "__init__.py")
152
153 # There are possibly multiple Controls packaged with the display.
154 # For each __init__.py found, there must be a Control associated with it.
155 for CTRL in ${CONTROL_INITS[@]}; do
156
157 cd `dirname ${CTRL}`
158 CTRL_NAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
159 einfo "Installing Control ${CTRL_NAME}"
160 # This creates the subdirectory of ${CTRL_NAME}
161 # in the global Controls directory
162 [[ -d "${CONTROL_INSDIR}/${CTRL_NAME}" ]] || \
163 dodir "${CONTROL_INSDIR}/${CTRL_NAME}"
164
165 insinto "${CONTROL_INSDIR}/${CTRL_NAME}"
166
167 doins -r *.py
168
169 cd "${S}"
170
171 done # for in ${CONTROL_INITS}
172
173 fi # if no Sensors
174
175 # Install any remaining graphics and other files
176 # that are sitting in ${S}.
177
178 GFX=$(find . -maxdepth 1 \
179 -iname "*.png" -o -iname "*.svg" \
180 -o -iname "*.jpg" -o -iname "*.gif" \
181 -o -iname "*.xcf")
182
183 if [[ -n "${GFX}" ]]; then
184
185 # Install to the Displays directory of the Desklet
186 insinto "${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
187 doins "${GFX}"
188 debug-print "Installed ${GFX} into ${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
189
190 fi # if -n "${GFX}"
191
192 # Install some docs if so requested
193 [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
194 debug-print "Installed ${DOCS}"
195
196} 164}
197 165
198
199EXPORT_FUNCTIONS src_install 166EXPORT_FUNCTIONS src_install pkg_postinst

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

  ViewVC Help
Powered by ViewVC 1.1.20