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

Contents of /eclass/vdr-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download)
Wed Mar 15 09:14:37 2006 UTC (8 years, 9 months ago) by zzam
Branch: MAIN
Changes since 1.14: +4 -1 lines
added debug use-flag

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.14 2006/03/14 16:03:01 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 IUSE="debug"
49
50 # Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
51 VDRPLUGIN="${PN/#vdrplugin-/}"
52 VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
53 VDRPLUGIN="${VDRPLUGIN/%-cvs/}"
54
55 DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin.eclass)"
56
57 # works in most cases
58 S="${WORKDIR}/${VDRPLUGIN}-${PV}"
59
60 # depend on headers for DVB-driver
61 RDEPEND=""
62 DEPEND="media-tv/linuxtv-dvb-headers"
63
64 # Where should the plugins live in the filesystem
65 VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"
66
67 VDR_RC_DIR="/usr/lib/vdr/rcscript"
68
69 # Pathes to includes
70 VDR_INCLUDE_DIR="/usr/include"
71 DVB_INCLUDE_DIR="/usr/include"
72
73
74 # this code is from linux-mod.eclass
75 update_vdrplugindb() {
76 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
77
78 if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then
79 [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR}
80 touch ${VDRPLUGINDB_DIR}/vdrplugindb
81 fi
82 if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
83 einfo "Adding plugin to vdrplugindb."
84 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb
85 fi
86 }
87
88 remove_vdrplugindb() {
89 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
90
91 if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
92 einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb."
93 sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb
94 fi
95 }
96
97 vdr-plugin_pkg_setup() {
98 # -fPIC is needed for shared objects on some platforms (amd64 and others)
99 append-flags -fPIC
100 use debug && append-flags -g
101
102 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h)
103 einfo "Building ${PF} against vdr-${VDRVERSION}"
104 }
105
106 vdr-plugin_src_unpack() {
107 [ -z "$1" ] && vdr-plugin_src_unpack unpack patchmakefile
108
109 while [ "$1" ]; do
110
111 case "$1" in
112 unpack)
113 base_src_unpack
114 ;;
115 patchmakefile)
116 cd ${S}
117
118 ebegin "Patching Makefile"
119 sed -i.orig Makefile \
120 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
121 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
122 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
123 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
124 -e 's:^CXXFLAGS:#CXXFLAGS:' \
125 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \
126 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
127 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \
128 -e 's:$(VDRDIR)/\([a-z]*\.h\|Make.config\):$(VDRDIR)/vdr/\1:'
129 eend $?
130 ;;
131 esac
132
133 shift
134 done
135 }
136
137 vdr-plugin_copy_source_tree() {
138 cp -r ${S} ${T}/source-tree
139 cd ${T}/source-tree
140 mv Makefile.orig Makefile
141 sed -i Makefile \
142 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
143 -e 's:^CXXFLAGS:#CXXFLAGS:' \
144 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
145 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):'
146 }
147
148 vdr-plugin_install_source_tree() {
149 einfo "Installing sources"
150 destdir=${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN}
151 insinto ${destdir}-${PV}
152 doins -r ${T}/source-tree/*
153
154 dosym ${VDRPLUGIN}-${PV} ${destdir}
155 }
156
157 vdr-plugin_src_compile() {
158 [ -z "$1" ] && vdr-plugin_src_compile prepare compile
159
160 while [ "$1" ]; do
161
162 case "$1" in
163 prepare)
164 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_copy_source_tree
165 ;;
166 compile)
167 cd ${S}
168
169 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed"
170 ;;
171 esac
172
173 shift
174 done
175 }
176
177 vdr-plugin_src_install() {
178 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree
179 cd ${S}
180
181 insinto "${VDR_PLUGIN_DIR}"
182 doins libvdr-*.so.*
183 dodoc README* HISTORY CHANGELOG
184
185 for f in ${FILESDIR}/confd-${PV} ${FILESDIR}/confd; do
186 if [[ -f "${f}" ]]; then
187 insinto /etc/conf.d
188 newins "${f}" vdr.${VDRPLUGIN}
189 VDR_PLUGIN_CONFIG_FILE_INSTALLED=1
190 break
191 fi
192 done
193
194 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do
195 if [[ -f "${f}" ]]; then
196 insinto "${VDR_RC_DIR}"
197 newins "${f}" plugin-${VDRPLUGIN}.sh
198 break
199 fi
200 done
201
202 if which md5sum >/dev/null 2>&1; then
203 cd ${S}
204 insinto /usr/lib/vdr/checksums
205 (
206 cd ${ROOT}${VDR_INCLUDE_DIR}/vdr
207 md5sum *.h libsi/*.h|sort --key=2
208 ) > header-md5-${PN}
209 doins header-md5-${PN}
210 fi
211 }
212
213 vdr-plugin_pkg_postinst() {
214 update_vdrplugindb
215 einfo
216 einfo "The vdr plugin ${VDRPLUGIN} has now been installed."
217 einfo "To activate execute the following command:"
218 einfo
219 einfo " emerge --config ${PN}"
220 einfo
221 if [[ -n "${VDR_PLUGIN_CONFIG_FILE_INSTALLED}" ]]; then
222 einfo "And have a look at the config-file"
223 einfo "/etc/conf.d/vdr.${VDRPLUGIN}"
224 einfo
225 fi
226 }
227
228 vdr-plugin_pkg_postrm() {
229 remove_vdrplugindb
230 }
231
232 vdr-plugin_pkg_config_final() {
233 diff ${conf_orig} ${conf}
234 rm ${conf_orig}
235 }
236
237 vdr-plugin_pkg_config() {
238 if [[ -z "${INSTALLPLUGIN}" ]]; then
239 INSTALLPLUGIN="${VDRPLUGIN}"
240 fi
241 # First test if plugin is already inside PLUGINS
242 local conf=/etc/conf.d/vdr
243 conf_orig=${conf}.before_emerge_config
244 cp ${conf} ${conf_orig}
245
246 einfo "Reading ${conf}"
247 if ! grep -q "^PLUGINS=" ${conf}; then
248 local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1)
249 if [[ -n "${LINE}" ]]; then
250 sed -e ${LINE}'a PLUGINS=""' -i ${conf}
251 else
252 echo 'PLUGINS=""' >> ${conf}
253 fi
254 unset LINE
255 fi
256
257 unset PLUGINS
258 PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS})
259
260 active=0
261 for p in ${PLUGINS}; do
262 if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then
263 active=1
264 break;
265 fi
266 done
267
268 if [[ "${active}" == "1" ]]; then
269 einfo "${INSTALLPLUGIN} already activated"
270 echo
271 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
272 if [[ "${answer}" != "yes" ]]; then
273 einfo "aborted"
274 return
275 fi
276 einfo "Removing ${INSTALLPLUGIN} from active plugins."
277 local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1)
278 sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \
279 -e ${LINE}'s/ \( \)*/ /g' \
280 -e ${LINE}'s/ "/"/g' \
281 -e ${LINE}'s/" /"/g'
282
283 vdr-plugin_pkg_config_final
284 return
285 fi
286
287
288 einfo "Adding ${INSTALLPLUGIN} to active plugins."
289 local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1)
290 sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \
291 -e ${LINE}'s/ \( \)*/ /g' \
292 -e ${LINE}'s/ "/"/g' \
293 -e ${LINE}'s/" /"/g'
294
295 vdr-plugin_pkg_config_final
296 }
297
298 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config

  ViewVC Help
Powered by ViewVC 1.1.20