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