| 1 |
# Copyright 2004-2010 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License, v2 or later |
| 3 |
# $Header: $ |
| 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) |
| 15 |
# |
| 16 |
# This eclass assumes a package following the instructions at |
| 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). |
| 22 |
# |
| 23 |
# Original authors: Joe Sapp <nixphoeni@gentoo.org> |
| 24 |
# Mike Gardiner <obz@gentoo.org> |
| 25 |
|
| 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: |
| 38 |
# Anything (like a README) that should be dodoc'd. |
| 39 |
|
| 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 |
|
| 46 |
inherit eutils multilib python |
| 47 |
|
| 48 |
if [[ -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 |
| 53 |
else # [[ -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" |
| 60 |
fi |
| 61 |
|
| 62 |
MY_P="${MY_PN}-${PV}" |
| 63 |
S="${WORKDIR}/${MY_PN}" |
| 64 |
|
| 65 |
SLOT="0" |
| 66 |
# Ebuild writer shouldn't need to touch these (except maybe RDEPEND) |
| 67 |
IUSE="" |
| 68 |
RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3" |
| 69 |
|
| 70 |
GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets" |
| 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 |
| 76 |
gdesklets_src_install() { |
| 77 |
|
| 78 |
debug-print-function $FUNCNAME $* |
| 79 |
|
| 80 |
# Disable compilation of included python modules (for Controls) |
| 81 |
python_disable_pyc |
| 82 |
|
| 83 |
# Avoid sandbox violations caused by misbehaving packages (bug #128289) |
| 84 |
addwrite "${ROOT}/root/.gnome2" |
| 85 |
|
| 86 |
# Both Displays and Controls only need to be readable |
| 87 |
insopts -m0744 |
| 88 |
|
| 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 |
|
| 99 |
if [[ -n "${DESKLET_NAME}" ]]; then |
| 100 |
|
| 101 |
debug-print-section display_install |
| 102 |
|
| 103 |
# Base installation directory for displays from this desklet |
| 104 |
INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}" |
| 105 |
|
| 106 |
debug-print "Installing into ${INSDIR}" |
| 107 |
debug-print "Exiting Display-specific installation code" |
| 108 |
|
| 109 |
elif [[ -n "${CONTROL_NAME}" ]]; then |
| 110 |
|
| 111 |
debug-print-section control_install |
| 112 |
|
| 113 |
# Unique name for this Control and its interface |
| 114 |
CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null ) |
| 115 |
einfo "Installing Control ${CTRL_DIRNAME}" |
| 116 |
|
| 117 |
# Base installation directory for this Control |
| 118 |
INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}" |
| 119 |
debug-print "Installing into ${INSDIR}" |
| 120 |
|
| 121 |
# Mercilessly delete all existing compiled code |
| 122 |
find . -iname '*.py[co]' -delete |
| 123 |
|
| 124 |
debug-print "Exiting Control-specific installation code" |
| 125 |
|
| 126 |
else |
| 127 |
die "nothing to install, is the ebuild written correctly?" |
| 128 |
fi |
| 129 |
|
| 130 |
debug-print-section common_install |
| 131 |
|
| 132 |
# Create the proper subdirectory in the global Controls or |
| 133 |
# Displays directory |
| 134 |
dodir "${INSDIR}" |
| 135 |
insinto "${INSDIR}" |
| 136 |
doins -r * |
| 137 |
|
| 138 |
} |
| 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. |
| 145 |
gdesklets_pkg_postinst() { |
| 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 |
|
| 166 |
EXPORT_FUNCTIONS src_install pkg_postinst |