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

Diff of /eclass/vdr-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.8
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/vdr-plugin.eclass,v 1.1 2005/07/23 15:11:25 zzam Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/vdr-plugin.eclass,v 1.8 2005/11/20 14:10:05 zzam Exp $
4# 4#
5# Author: 5# Author:
6# Matthias Schwarzott <zzam@gentoo.org> 6# Matthias Schwarzott <zzam@gentoo.org>
7 7
8# vdr-plugin.eclass 8# vdr-plugin.eclass
20# SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz" 20# SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz"
21# LICENSE="GPL-2" 21# LICENSE="GPL-2"
22# KEYWORDS="~x86" 22# KEYWORDS="~x86"
23# DEPEND=">=media-video/vdr-1.3.27" 23# DEPEND=">=media-video/vdr-1.3.27"
24# 24#
25# 25#
26 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.
27 45
28inherit eutils flag-o-matic 46inherit eutils flag-o-matic
29 47
30# Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes 48# Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
31VDRPLUGIN="${PN/#vdrplugin-/}" 49VDRPLUGIN="${PN/#vdrplugin-/}"
32VDRPLUGIN="${PN/#vdr-/}" 50VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
33VDRPLUGIN="${VDRPLUGIN/%-cvs/}" 51VDRPLUGIN="${VDRPLUGIN/%-cvs/}"
34 52
35DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin.eclass)" 53DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin.eclass)"
36 54
37# works in most cases 55# works in most cases
45 )" 63 )"
46 64
47# Where should the plugins live in the filesystem 65# Where should the plugins live in the filesystem
48VDR_PLUGIN_DIR="/usr/lib/vdr/plugins" 66VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"
49 67
68VDR_RC_DIR="/usr/lib/vdr/rcscript"
69
50# Pathes to includes 70# Pathes to includes
51VDR_INCLUDE_DIR="/usr/include" 71VDR_INCLUDE_DIR="/usr/include"
52DVB_INCLUDE_DIR="/usr/include" 72DVB_INCLUDE_DIR="/usr/include"
53 73
74
75# this code is from linux-mod.eclass
76update_vdrplugindb() {
77 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
78
79 if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then
80 [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR}
81 touch ${VDRPLUGINDB_DIR}/vdrplugindb
82 fi
83 if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
84 einfo "Adding plugin to vdrplugindb."
85 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb
86 fi
87}
88
89remove_vdrplugindb() {
90 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
91
92 if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
93 einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb."
94 sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb
95 fi
96}
97
54vdr-plugin_pkg_setup() { 98vdr-plugin_pkg_setup() {
55 # -fPIC is needed for shared objects on some platforms (amd64 and others) 99 # -fPIC is needed for shared objects on some platforms (amd64 and others)
56 append-flags -fPIC 100 append-flags -fPIC
57 101
58 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h) 102 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h)
70 ;; 114 ;;
71 patchmakefile) 115 patchmakefile)
72 cd ${S} 116 cd ${S}
73 117
74 ebegin "Patching Makefile" 118 ebegin "Patching Makefile"
75 sed -i Makefile \ 119 sed -i.orig Makefile \
76 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \ 120 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
77 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ 121 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
78 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ 122 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
79 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \ 123 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
80 -e 's:^CXXFLAGS:#CXXFLAGS:' \ 124 -e 's:^CXXFLAGS:#CXXFLAGS:' \
88 132
89 shift 133 shift
90 done 134 done
91} 135}
92 136
137vdr-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
148vdr-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
93vdr-plugin_src_compile() { 157vdr-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)
94 cd ${S} 167 cd ${S}
95 168
96 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed" 169 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed"
170 ;;
171 esac
172
173 shift
174 done
97} 175}
98 176
99vdr-plugin_src_install() { 177vdr-plugin_src_install() {
178 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree
100 cd ${S} 179 cd ${S}
101 180
102 insinto "${VDR_PLUGIN_DIR}" 181 insinto "${VDR_PLUGIN_DIR}"
103 doins libvdr-*.so.* 182 doins libvdr-*.so.*
104 dodoc README* HISTORY CHANGELOG 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 break
190 fi
191 done
192
193 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do
194 if [[ -f "${f}" ]]; then
195 insinto "${VDR_RC_DIR}"
196 newins "${f}" plugin-${VDRPLUGIN}.sh
197 break
198 fi
199 done
105} 200}
106 201
107vdr-plugin_pkg_postinst() { 202vdr-plugin_pkg_postinst() {
203 update_vdrplugindb
108 einfo 204 einfo
109 einfo "The vdr plugin ${VDRPLUGIN} has now been installed," 205 einfo "The vdr plugin ${VDRPLUGIN} has now been installed,"
110 einfo "to activate it you have to add it to /etc/conf.d/vdr." 206 einfo "to activate it you have to add it to /etc/conf.d/vdr."
111 einfo 207 einfo
112} 208}
113 209
210vdr-plugin_pkg_postrm() {
211 remove_vdrplugindb
212}
213
214vdr-plugin_pkg_config_final() {
215 diff ${conf_orig} ${conf}
216 rm ${conf_orig}
217}
218
219vdr-plugin_pkg_config() {
220 if [[ -z "${INSTALLPLUGIN}" ]]; then
221 INSTALLPLUGIN="${VDRPLUGIN}"
222 fi
223 # First test if plugin is already inside PLUGINS
224 local conf=/etc/conf.d/vdr
225 conf_orig=${conf}.before_emerge_config
226 cp ${conf} ${conf_orig}
227
228 einfo "Reading ${conf}"
229 if ! grep -q "^PLUGINS=" ${conf}; then
230 local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1)
231 if [[ -n "${LINE}" ]]; then
232 sed -e ${LINE}'a PLUGINS=""' -i ${conf}
233 else
234 echo 'PLUGINS=""' >> ${conf}
235 fi
236 unset LINE
237 fi
238
239 unset PLUGINS
240 PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS})
241
242 active=0
243 for p in ${PLUGINS}; do
244 if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then
245 active=1
246 break;
247 fi
248 done
249
250 if [[ "${active}" == "1" ]]; then
251 einfo "${INSTALLPLUGIN} already activated"
252 echo
253 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
254 if [[ "${answer}" != "yes" ]]; then
255 einfo "aborted"
256 return
257 fi
258 einfo "Removing ${INSTALLPLUGIN} from active plugins."
259 local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1)
260 sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \
261 -e ${LINE}'s/ \( \)*/ /g' \
262 -e ${LINE}'s/ "/"/g' \
263 -e ${LINE}'s/" /"/g'
264
265 vdr-plugin_pkg_config_final
266 return
267 fi
268
269
270 einfo "Adding ${INSTALLPLUGIN} to active plugins."
271 local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1)
272 sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \
273 -e ${LINE}'s/ \( \)*/ /g' \
274 -e ${LINE}'s/ "/"/g' \
275 -e ${LINE}'s/" /"/g'
276
277 vdr-plugin_pkg_config_final
278}
279
114EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst 280EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20