/[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.12
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.12 2006/02/03 21:18:52 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:
27 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
28inherit eutils flag-o-matic 46inherit base 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
38S="${WORKDIR}/${VDRPLUGIN}-${PV}" 56S="${WORKDIR}/${VDRPLUGIN}-${PV}"
39 57
40# depend on headers for DVB-driver 58# depend on headers for DVB-driver
41RDEPEND="" 59RDEPEND=""
42DEPEND="|| ( 60DEPEND="media-tv/linuxtv-dvb-headers"
43 >=sys-kernel/linux-headers-2.6.11-r2
44 media-tv/linuxtv-dvb
45 )"
46 61
47# Where should the plugins live in the filesystem 62# Where should the plugins live in the filesystem
48VDR_PLUGIN_DIR="/usr/lib/vdr/plugins" 63VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"
64
65VDR_RC_DIR="/usr/lib/vdr/rcscript"
49 66
50# Pathes to includes 67# Pathes to includes
51VDR_INCLUDE_DIR="/usr/include" 68VDR_INCLUDE_DIR="/usr/include"
52DVB_INCLUDE_DIR="/usr/include" 69DVB_INCLUDE_DIR="/usr/include"
53 70
71
72# this code is from linux-mod.eclass
73update_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
86remove_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
54vdr-plugin_pkg_setup() { 95vdr-plugin_pkg_setup() {
55 # -fPIC is needed for shared objects on some platforms (amd64 and others) 96 # -fPIC is needed for shared objects on some platforms (amd64 and others)
56 append-flags -fPIC 97 append-flags -fPIC
57 98
58 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h) 99 VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h)
64 105
65 while [ "$1" ]; do 106 while [ "$1" ]; do
66 107
67 case "$1" in 108 case "$1" in
68 unpack) 109 unpack)
69 unpack ${A} 110 base_src_unpack
70 ;; 111 ;;
71 patchmakefile) 112 patchmakefile)
72 cd ${S} 113 cd ${S}
73 114
74 ebegin "Patching Makefile" 115 ebegin "Patching Makefile"
75 sed -i Makefile \ 116 sed -i.orig Makefile \
76 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \ 117 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
77 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ 118 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
78 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ 119 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
79 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \ 120 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
80 -e 's:^CXXFLAGS:#CXXFLAGS:' \ 121 -e 's:^CXXFLAGS:#CXXFLAGS:' \
81 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \ 122 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \
82 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \ 123 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
83 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \ 124 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \
84 -e 's:$(VDRDIR)/\(config.h\|Make.config\):$(VDRDIR)/vdr/\1:' 125 -e 's:$(VDRDIR)/\([a-z]*\.h\|Make.config\):$(VDRDIR)/vdr/\1:'
85 eend $? 126 eend $?
86 ;; 127 ;;
87 esac 128 esac
88 129
89 shift 130 shift
90 done 131 done
91} 132}
92 133
134vdr-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
145vdr-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
93vdr-plugin_src_compile() { 154vdr-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)
94 cd ${S} 164 cd ${S}
95 165
96 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed" 166 emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed"
167 ;;
168 esac
169
170 shift
171 done
97} 172}
98 173
99vdr-plugin_src_install() { 174vdr-plugin_src_install() {
175 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree
100 cd ${S} 176 cd ${S}
101 177
102 insinto "${VDR_PLUGIN_DIR}" 178 insinto "${VDR_PLUGIN_DIR}"
103 doins libvdr-*.so.* 179 doins libvdr-*.so.*
104 dodoc README* HISTORY CHANGELOG 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 break
187 fi
188 done
189
190 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do
191 if [[ -f "${f}" ]]; then
192 insinto "${VDR_RC_DIR}"
193 newins "${f}" plugin-${VDRPLUGIN}.sh
194 break
195 fi
196 done
105} 197}
106 198
107vdr-plugin_pkg_postinst() { 199vdr-plugin_pkg_postinst() {
200 update_vdrplugindb
108 einfo 201 einfo
109 einfo "The vdr plugin ${VDRPLUGIN} has now been installed," 202 einfo "The vdr plugin ${VDRPLUGIN} has now been installed."
110 einfo "to activate it you have to add it to /etc/conf.d/vdr." 203 einfo "To activate execute the following command:"
111 einfo 204 einfo
205 einfo " emerge --config ${PN}"
206 einfo
112} 207}
113 208
209vdr-plugin_pkg_postrm() {
210 remove_vdrplugindb
211}
212
213vdr-plugin_pkg_config_final() {
214 diff ${conf_orig} ${conf}
215 rm ${conf_orig}
216}
217
218vdr-plugin_pkg_config() {
219 if [[ -z "${INSTALLPLUGIN}" ]]; then
220 INSTALLPLUGIN="${VDRPLUGIN}"
221 fi
222 # First test if plugin is already inside PLUGINS
223 local conf=/etc/conf.d/vdr
224 conf_orig=${conf}.before_emerge_config
225 cp ${conf} ${conf_orig}
226
227 einfo "Reading ${conf}"
228 if ! grep -q "^PLUGINS=" ${conf}; then
229 local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1)
230 if [[ -n "${LINE}" ]]; then
231 sed -e ${LINE}'a PLUGINS=""' -i ${conf}
232 else
233 echo 'PLUGINS=""' >> ${conf}
234 fi
235 unset LINE
236 fi
237
238 unset PLUGINS
239 PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS})
240
241 active=0
242 for p in ${PLUGINS}; do
243 if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then
244 active=1
245 break;
246 fi
247 done
248
249 if [[ "${active}" == "1" ]]; then
250 einfo "${INSTALLPLUGIN} already activated"
251 echo
252 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
253 if [[ "${answer}" != "yes" ]]; then
254 einfo "aborted"
255 return
256 fi
257 einfo "Removing ${INSTALLPLUGIN} from active plugins."
258 local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1)
259 sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \
260 -e ${LINE}'s/ \( \)*/ /g' \
261 -e ${LINE}'s/ "/"/g' \
262 -e ${LINE}'s/" /"/g'
263
264 vdr-plugin_pkg_config_final
265 return
266 fi
267
268
269 einfo "Adding ${INSTALLPLUGIN} to active plugins."
270 local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1)
271 sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \
272 -e ${LINE}'s/ \( \)*/ /g' \
273 -e ${LINE}'s/ "/"/g' \
274 -e ${LINE}'s/" /"/g'
275
276 vdr-plugin_pkg_config_final
277}
278
114EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst 279EXPORT_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.12

  ViewVC Help
Powered by ViewVC 1.1.20