1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: gdesklets.eclass
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
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)
18 # This eclass assumes a package following the instructions at
19 # http://gdesklets.de/index.php?q=node/2 . Specifically, the package
20 # should be a Desklet or Control ONLY (and *not* a Sensor). You
21 # technically could have an ebuild that works around this limitation,
22 # but no new packages should be added to the tree that do this (mainly
23 # for ease of maintenance).
25 # @ECLASS-VARIABLE: DESKLET_NAME
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
31 # @ECLASS-VARIABLE: CONTROL_NAME
33 # *Optional* The name of the Control, if the package is one.
35 # @ECLASS-VARIABLE: DOCS
37 # Anything (like a README) that should be dodoc'd.
39 # @ECLASS-VARIABLE: SLOT
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
45 inherit eutils multilib python
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"
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"
62 S="${WORKDIR}/${MY_PN}"
65 # Ebuild writer shouldn't need to touch these (except maybe RDEPEND)
67 RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3"
69 GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets"
71 # @FUNCTION: gdesklets_src_install
73 # Installs a Desklet or Control depending on which is set of
74 # CONTROL_NAME or DESKLET_NAME
75 gdesklets_src_install() {
77 debug-print-function $FUNCNAME $*
79 # Disable compilation of included python modules (for Controls)
82 # Avoid sandbox violations caused by misbehaving packages (bug #128289)
83 addwrite "${ROOT}/root/.gnome2"
85 # Both Displays and Controls only need to be readable
88 debug-print-section docs_install
90 # Install some docs if so requested (and then delete them so they
91 # don't get copied into the installation directory)
92 [[ -n "${DOCS}" ]] && dodoc ${DOCS} && \
94 debug-print "Installed and deleted ${DOCS}"
95 # LICENSE doesn't need to get installed if it exists
96 find . -name LICENSE -delete
98 if [[ -n "${DESKLET_NAME}" ]]; then
100 debug-print-section display_install
102 # Base installation directory for displays from this desklet
103 INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
105 debug-print "Installing into ${INSDIR}"
106 debug-print "Exiting Display-specific installation code"
108 elif [[ -n "${CONTROL_NAME}" ]]; then
110 debug-print-section control_install
112 # Unique name for this Control and its interface
113 CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
114 einfo "Installing Control ${CTRL_DIRNAME}"
116 # Base installation directory for this Control
117 INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
118 debug-print "Installing into ${INSDIR}"
120 # Mercilessly delete all existing compiled code
121 find . -iname '*.py[co]' -delete
123 debug-print "Exiting Control-specific installation code"
126 die "nothing to install, is the ebuild written correctly?"
129 debug-print-section common_install
131 # Create the proper subdirectory in the global Controls or
139 # @FUNCTION: gdesklets_pkg_postinst
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() {
146 # The only time compilation of python modules should occur is
147 # for Controls, since Displays are run from inside the sandbox
148 # (and therefore can't be compiled).
149 if [[ -n "${CONTROL_NAME}" ]]; then
151 CTRL_DIRNAME=$( "${GDESKLETS_INST_DIR}/gdesklets-control-getid" `pwd` 2> /dev/null )
153 python_mod_optimize "${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
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})."
165 EXPORT_FUNCTIONS src_install pkg_postinst