/[gentoo-x86]/eclass/vdr-plugin.eclass
Gentoo

Contents of /eclass/vdr-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Sat Mar 4 17:43:51 2006 UTC (8 years, 4 months ago) by zzam
Branch: MAIN
Changes since 1.12: +7 -1 lines
display a notice about the config-file if the plugin has one

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.12 2006/02/03 21:18:52 zzam Exp $
4 #
5 # Author:
6 # Matthias Schwarzott <zzam@gentoo.org>
7
8 # vdr-plugin.eclass
9 #
10 # eclass to create ebuilds for vdr plugins
11 #
12
13 # Example ebuild (vdr-femon):
14 #
15 # inherit vdr-plugin
16 # IUSE=""
17 # SLOT="0"
18 # DESCRIPTION="vdr Plugin: DVB Frontend Status Monitor (signal strengt/noise)"
19 # HOMEPAGE="http://www.saunalahti.fi/~rahrenbe/vdr/femon/"
20 # SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz"
21 # LICENSE="GPL-2"
22 # KEYWORDS="~x86"
23 # DEPEND=">=media-video/vdr-1.3.27"
24 #
25 #
26
27 # There are some special files in ${FILESDIR} which get installed when
28 # they exist:
29
30 # ${FILESDIR}/confd-${PV} or ${FILESDIR}/confd:
31 # The first matching is installed under /etc/conf.d/vdr.${VDRPLUGIN}
32 # (in example vdr-femon this would be /etc/conf.d/vdr.femon)
33 #
34 # Everything put in variable _EXTRAOPTS is appended to the command line of
35 # the plugin.
36
37
38 # ${FILESDIR}/rc-addon-${PV}.sh or ${FILESDIR}/rc-addon.sh:
39 # The first matching is installed under /usr/lib/vdr/rcscript/plugin-${VDRPLUGIN}.sh
40 # (in example vdr-femon this would be /usr/lib/vdr/rcscript/plugin-femon.sh)
41 #
42 # This file is sourced by the startscript when plugin is activated in /etc/conf.d/vdr
43 # It could be used for special startup actions for this plugins, or to create the
44 # plugin command line options from a nicer version of a conf.d file.
45
46 inherit base eutils flag-o-matic
47
48 # Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
49 VDRPLUGIN="${PN/#vdrplugin-/}"
50 VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
51 VDRPLUGIN="${VDRPLUGIN/%-cvs/}"
52
53 DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin.eclass)"
54
55 # works in most cases
56 S="${WORKDIR}/${VDRPLUGIN}-${PV}"
57
58 # depend on headers for DVB-driver
59 RDEPEND=""
60 DEPEND="media-tv/linuxtv-dvb-headers"
61
62 # Where should the plugins live in the filesystem
63 VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"
64
65 VDR_RC_DIR="/usr/lib/vdr/rcscript"
66
67 # Pathes to includes
68 VDR_INCLUDE_DIR="/usr/include"
69 DVB_INCLUDE_DIR="/usr/include"
70
71
72 # this code is from linux-mod.eclass
73 update_vdrplugindb() {
74 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
75
76 if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then
77 [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR}
78 touch ${VDRPLUGINDB_DIR}/vdrplugindb
79 fi
80 if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
81 einfo "Adding plugin to vdrplugindb."
82 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb
83 fi
84 }
85
86 remove_vdrplugindb() {
87 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
88
89 if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
90 einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb."
91 sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb
92 fi
93 }
94
95 vdr-plugin_pkg_setup() {
96 # -fPIC is needed for shared objects on some platforms (amd64 and others)
97 append-flags -fPIC
98
99 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h)
100 einfo "Building ${PF} against vdr-${VDRVERSION}"
101 }
102
103 vdr-plugin_src_unpack() {
104 [ -z "$1" ] && vdr-plugin_src_unpack unpack patchmakefile
105
106 while [ "$1" ]; do
107
108 case "$1" in
109 unpack)
110 base_src_unpack
111 ;;
112 patchmakefile)
113 cd ${S}
114
115 ebegin "Patching Makefile"
116 sed -i.orig Makefile \
117 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
118 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
119 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
120 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
121 -e 's:^CXXFLAGS:#CXXFLAGS:' \
122 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \
123 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
124 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \
125 -e 's:$(VDRDIR)/\([a-z]*\.h\|Make.config\):$(VDRDIR)/vdr/\1:'
126 eend $?
127 ;;
128 esac
129
130 shift
131 done
132 }
133
134 vdr-plugin_copy_source_tree() {
135 cp -r ${S} ${T}/source-tree
136 cd ${T}/source-tree
137 mv Makefile.orig Makefile
138 sed -i Makefile \
139 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
140 -e 's:^CXXFLAGS:#CXXFLAGS:' \
141 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
142 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):'
143 }
144
145 vdr-plugin_install_source_tree() {
146 einfo "Installing sources"
147 destdir=${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN}
148 insinto ${destdir}-${PV}
149 doins -r ${T}/source-tree/*
150
151 dosym ${VDRPLUGIN}-${PV} ${destdir}
152 }
153
154 vdr-plugin_src_compile() {
155 [ -z "$1" ] && vdr-plugin_src_compile prepare compile
156
157 while [ "$1" ]; do
158
159 case "$1" in
160 prepare)
161 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_copy_source_tree
162 ;;
163 compile)
164 cd ${S}
165
166 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed"
167 ;;
168 esac
169
170 shift
171 done
172 }
173
174 vdr-plugin_src_install() {
175 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree
176 cd ${S}
177
178 insinto "${VDR_PLUGIN_DIR}"
179 doins libvdr-*.so.*
180 dodoc README* HISTORY CHANGELOG
181
182 for f in ${FILESDIR}/confd-${PV} ${FILESDIR}/confd; do
183 if [[ -f "${f}" ]]; then
184 insinto /etc/conf.d
185 newins "${f}" vdr.${VDRPLUGIN}
186 VDR_PLUGIN_CONFIG_FILE_INSTALLED=1
187 break
188 fi
189 done
190
191 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do
192 if [[ -f "${f}" ]]; then
193 insinto "${VDR_RC_DIR}"
194 newins "${f}" plugin-${VDRPLUGIN}.sh
195 break
196 fi
197 done
198 }
199
200 vdr-plugin_pkg_postinst() {
201 update_vdrplugindb
202 einfo
203 einfo "The vdr plugin ${VDRPLUGIN} has now been installed."
204 einfo "To activate execute the following command:"
205 einfo
206 einfo " emerge --config ${PN}"
207 einfo
208 if [[ -n "${VDR_PLUGIN_CONFIG_FILE_INSTALLED}" ]]; then
209 einfo "And have a look at the config-file"
210 einfo "/etc/conf.d/vdr.${VDRPLUGIN}"
211 einfo
212 fi
213 }
214
215 vdr-plugin_pkg_postrm() {
216 remove_vdrplugindb
217 }
218
219 vdr-plugin_pkg_config_final() {
220 diff ${conf_orig} ${conf}
221 rm ${conf_orig}
222 }
223
224 vdr-plugin_pkg_config() {
225 if [[ -z "${INSTALLPLUGIN}" ]]; then
226 INSTALLPLUGIN="${VDRPLUGIN}"
227 fi
228 # First test if plugin is already inside PLUGINS
229 local conf=/etc/conf.d/vdr
230 conf_orig=${conf}.before_emerge_config
231 cp ${conf} ${conf_orig}
232
233 einfo "Reading ${conf}"
234 if ! grep -q "^PLUGINS=" ${conf}; then
235 local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1)
236 if [[ -n "${LINE}" ]]; then
237 sed -e ${LINE}'a PLUGINS=""' -i ${conf}
238 else
239 echo 'PLUGINS=""' >> ${conf}
240 fi
241 unset LINE
242 fi
243
244 unset PLUGINS
245 PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS})
246
247 active=0
248 for p in ${PLUGINS}; do
249 if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then
250 active=1
251 break;
252 fi
253 done
254
255 if [[ "${active}" == "1" ]]; then
256 einfo "${INSTALLPLUGIN} already activated"
257 echo
258 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
259 if [[ "${answer}" != "yes" ]]; then
260 einfo "aborted"
261 return
262 fi
263 einfo "Removing ${INSTALLPLUGIN} from active plugins."
264 local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1)
265 sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \
266 -e ${LINE}'s/ \( \)*/ /g' \
267 -e ${LINE}'s/ "/"/g' \
268 -e ${LINE}'s/" /"/g'
269
270 vdr-plugin_pkg_config_final
271 return
272 fi
273
274
275 einfo "Adding ${INSTALLPLUGIN} to active plugins."
276 local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1)
277 sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \
278 -e ${LINE}'s/ \( \)*/ /g' \
279 -e ${LINE}'s/ "/"/g' \
280 -e ${LINE}'s/" /"/g'
281
282 vdr-plugin_pkg_config_final
283 }
284
285 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config

  ViewVC Help
Powered by ViewVC 1.1.20