net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / gdesklets.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
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)
17 #
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).
24
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.
30
31 # @ECLASS-VARIABLE: CONTROL_NAME
32 # @DESCRIPTION:
33 # *Optional*  The name of the Control, if the package is one.
34
35 # @ECLASS-VARIABLE: DOCS
36 # @DESCRIPTION:
37 # Anything (like a README) that should be dodoc'd.
38
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.
44
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
64 SLOT="0"
65 # Ebuild writer shouldn't need to touch these (except maybe RDEPEND)
66 IUSE=""
67 RDEPEND=">=gnome-extra/gdesklets-core-0.36.1-r3"
68
69 GDESKLETS_INST_DIR="${ROOT}usr/$(get_libdir)/gdesklets"
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
75 gdesklets_src_install() {
76
77         debug-print-function $FUNCNAME $*
78
79         # Disable compilation of included python modules (for Controls)
80         python_disable_pyc
81
82         # Avoid sandbox violations caused by misbehaving packages (bug #128289)
83         addwrite "${ROOT}/root/.gnome2"
84
85         # Both Displays and Controls only need to be readable
86         insopts -m0744
87
88         debug-print-section docs_install
89
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} && \
93                 rm -f ${DOCS} \
94                 debug-print "Installed and deleted ${DOCS}"
95         # LICENSE doesn't need to get installed if it exists
96         find . -name LICENSE -delete
97
98         if [[ -n "${DESKLET_NAME}" ]]; then
99
100                 debug-print-section display_install
101
102                 # Base installation directory for displays from this desklet
103                 INSDIR="${GDESKLETS_INST_DIR}/Displays/${DESKLET_NAME}"
104
105                 debug-print "Installing into ${INSDIR}"
106                 debug-print "Exiting Display-specific installation code"
107
108         elif [[ -n "${CONTROL_NAME}" ]]; then
109
110                 debug-print-section control_install
111
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}"
115
116                 # Base installation directory for this Control
117                 INSDIR="${GDESKLETS_INST_DIR}/Controls/${CTRL_DIRNAME}"
118                 debug-print "Installing into ${INSDIR}"
119
120                 # Mercilessly delete all existing compiled code
121                 find . -iname '*.py[co]' -delete
122
123                 debug-print "Exiting Control-specific installation code"
124
125         else
126                 die "nothing to install, is the ebuild written correctly?"
127         fi
128
129         debug-print-section common_install
130
131         # Create the proper subdirectory in the global Controls or
132         # Displays directory
133         dodir "${INSDIR}"
134         insinto "${INSDIR}"
135         doins -r *
136
137 }
138
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() {
145
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
150
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}"
154
155         else
156
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})."
160
161         fi
162
163 }
164
165 EXPORT_FUNCTIONS src_install pkg_postinst