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

Diff of /eclass/gdesklets.eclass

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20