/[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.2 Revision 1.14
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/vdr-plugin.eclass,v 1.2 2005/08/07 13:55:43 zzam Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.14 2006/03/14 16:03:01 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 27# There are some special files in ${FILESDIR} which get installed when
28# they exist: 28# they exist:
29 29
30# ${FILESDIR}/confd-${PV} or ${FILESDIR}/confd: 30# ${FILESDIR}/confd-${PV} or ${FILESDIR}/confd:
34# Everything put in variable _EXTRAOPTS is appended to the command line of 34# Everything put in variable _EXTRAOPTS is appended to the command line of
35# the plugin. 35# the plugin.
36 36
37 37
38# ${FILESDIR}/rc-addon-${PV}.sh or ${FILESDIR}/rc-addon.sh: 38# ${FILESDIR}/rc-addon-${PV}.sh or ${FILESDIR}/rc-addon.sh:
39# The first matching is installed under /usr/lib/vdr/rcscript/vdr.${VDRPLUGIN}.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/vdr.femon.sh) 40# (in example vdr-femon this would be /usr/lib/vdr/rcscript/plugin-femon.sh)
41# 41#
42# This file is sourced by the startscript when plugin is activated in /etc/conf.d/vdr 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 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. 44# plugin command line options from a nicer version of a conf.d file.
45 45
46inherit eutils flag-o-matic 46inherit base eutils flag-o-matic
47 47
48# 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
49VDRPLUGIN="${PN/#vdrplugin-/}" 49VDRPLUGIN="${PN/#vdrplugin-/}"
50VDRPLUGIN="${VDRPLUGIN/#vdr-/}" 50VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
51VDRPLUGIN="${VDRPLUGIN/%-cvs/}" 51VDRPLUGIN="${VDRPLUGIN/%-cvs/}"
55# works in most cases 55# works in most cases
56S="${WORKDIR}/${VDRPLUGIN}-${PV}" 56S="${WORKDIR}/${VDRPLUGIN}-${PV}"
57 57
58# depend on headers for DVB-driver 58# depend on headers for DVB-driver
59RDEPEND="" 59RDEPEND=""
60DEPEND="|| ( 60DEPEND="media-tv/linuxtv-dvb-headers"
61 >=sys-kernel/linux-headers-2.6.11-r2
62 media-tv/linuxtv-dvb
63 )"
64 61
65# Where should the plugins live in the filesystem 62# Where should the plugins live in the filesystem
66VDR_PLUGIN_DIR="/usr/lib/vdr/plugins" 63VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"
67 64
68VDR_RC_DIR="/usr/lib/vdr/rcscript" 65VDR_RC_DIR="/usr/lib/vdr/rcscript"
72DVB_INCLUDE_DIR="/usr/include" 69DVB_INCLUDE_DIR="/usr/include"
73 70
74 71
75# this code is from linux-mod.eclass 72# this code is from linux-mod.eclass
76update_vdrplugindb() { 73update_vdrplugindb() {
77 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugins-rebuild/ 74 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
78 75
79 if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then 76 if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then
80 [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR} 77 [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR}
81 touch ${VDRPLUGINDB_DIR}/vdrplugindb 78 touch ${VDRPLUGINDB_DIR}/vdrplugindb
82 fi 79 fi
85 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb 82 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb
86 fi 83 fi
87} 84}
88 85
89remove_vdrplugindb() { 86remove_vdrplugindb() {
90 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugins-rebuild/ 87 local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/
91 88
92 if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then 89 if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then
93 einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb." 90 einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb."
94 sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb 91 sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb
95 fi 92 fi
108 105
109 while [ "$1" ]; do 106 while [ "$1" ]; do
110 107
111 case "$1" in 108 case "$1" in
112 unpack) 109 unpack)
113 unpack ${A} 110 base_src_unpack
114 ;; 111 ;;
115 patchmakefile) 112 patchmakefile)
116 cd ${S} 113 cd ${S}
117 114
118 ebegin "Patching Makefile" 115 ebegin "Patching Makefile"
119 sed -i Makefile \ 116 sed -i.orig Makefile \
120 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \ 117 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
121 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \ 118 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
122 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ 119 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
123 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \ 120 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
124 -e 's:^CXXFLAGS:#CXXFLAGS:' \ 121 -e 's:^CXXFLAGS:#CXXFLAGS:' \
125 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \ 122 -e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \
126 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \ 123 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
127 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \ 124 -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \
128 -e 's:$(VDRDIR)/\(config.h\|Make.config\):$(VDRDIR)/vdr/\1:' 125 -e 's:$(VDRDIR)/\([a-z]*\.h\|Make.config\):$(VDRDIR)/vdr/\1:'
129 eend $? 126 eend $?
130 ;; 127 ;;
131 esac 128 esac
132 129
133 shift 130 shift
134 done 131 done
135} 132}
136 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
137vdr-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)
138 cd ${S} 164 cd ${S}
139 165
140 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
141} 172}
142 173
143vdr-plugin_src_install() { 174vdr-plugin_src_install() {
175 [[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin_install_source_tree
144 cd ${S} 176 cd ${S}
145 177
146 insinto "${VDR_PLUGIN_DIR}" 178 insinto "${VDR_PLUGIN_DIR}"
147 doins libvdr-*.so.* 179 doins libvdr-*.so.*
148 dodoc README* HISTORY CHANGELOG 180 dodoc README* HISTORY CHANGELOG
149 181
150 for f in ${FILESDIR}/confd-${PV} ${FILESDIR}/confd; do 182 for f in ${FILESDIR}/confd-${PV} ${FILESDIR}/confd; do
151 if [[ -f "${f}" ]]; then 183 if [[ -f "${f}" ]]; then
152 insinto /etc/conf.d 184 insinto /etc/conf.d
153 newins "${f}" vdr.${VDRPLUGIN} 185 newins "${f}" vdr.${VDRPLUGIN}
186 VDR_PLUGIN_CONFIG_FILE_INSTALLED=1
154 break 187 break
155 fi 188 fi
156 done 189 done
157 190
158 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do 191 for f in ${FILESDIR}/rc-addon-${PV}.sh ${FILESDIR}/rc-addon.sh; do
159 if [[ -f "${f}" ]]; then 192 if [[ -f "${f}" ]]; then
160 insinto "${VDR_RC_DIR}" 193 insinto "${VDR_RC_DIR}"
161 newins "${f}" vdr.${VDRPLUGIN}.sh 194 newins "${f}" plugin-${VDRPLUGIN}.sh
162 break 195 break
163 fi 196 fi
164 done 197 done
198
199 if which md5sum >/dev/null 2>&1; then
200 cd ${S}
201 insinto /usr/lib/vdr/checksums
202 (
203 cd ${ROOT}${VDR_INCLUDE_DIR}/vdr
204 md5sum *.h libsi/*.h|sort --key=2
205 ) > header-md5-${PN}
206 doins header-md5-${PN}
207 fi
165} 208}
166 209
167vdr-plugin_pkg_postinst() { 210vdr-plugin_pkg_postinst() {
168 update_vdrplugindb 211 update_vdrplugindb
169 einfo 212 einfo
170 einfo "The vdr plugin ${VDRPLUGIN} has now been installed," 213 einfo "The vdr plugin ${VDRPLUGIN} has now been installed."
171 einfo "to activate it you have to add it to /etc/conf.d/vdr." 214 einfo "To activate execute the following command:"
172 einfo 215 einfo
216 einfo " emerge --config ${PN}"
217 einfo
218 if [[ -n "${VDR_PLUGIN_CONFIG_FILE_INSTALLED}" ]]; then
219 einfo "And have a look at the config-file"
220 einfo "/etc/conf.d/vdr.${VDRPLUGIN}"
221 einfo
222 fi
173} 223}
174 224
175vdr-plugin_pkg_postrm() { 225vdr-plugin_pkg_postrm() {
176 remove_vdrplugindb 226 remove_vdrplugindb
177} 227}
178 228
229vdr-plugin_pkg_config_final() {
230 diff ${conf_orig} ${conf}
231 rm ${conf_orig}
232}
233
234vdr-plugin_pkg_config() {
235 if [[ -z "${INSTALLPLUGIN}" ]]; then
236 INSTALLPLUGIN="${VDRPLUGIN}"
237 fi
238 # First test if plugin is already inside PLUGINS
239 local conf=/etc/conf.d/vdr
240 conf_orig=${conf}.before_emerge_config
241 cp ${conf} ${conf_orig}
242
243 einfo "Reading ${conf}"
244 if ! grep -q "^PLUGINS=" ${conf}; then
245 local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1)
246 if [[ -n "${LINE}" ]]; then
247 sed -e ${LINE}'a PLUGINS=""' -i ${conf}
248 else
249 echo 'PLUGINS=""' >> ${conf}
250 fi
251 unset LINE
252 fi
253
254 unset PLUGINS
255 PLUGINS=$(source /etc/conf.d/vdr; echo ${PLUGINS})
256
257 active=0
258 for p in ${PLUGINS}; do
259 if [[ "${p}" == "${INSTALLPLUGIN}" ]]; then
260 active=1
261 break;
262 fi
263 done
264
265 if [[ "${active}" == "1" ]]; then
266 einfo "${INSTALLPLUGIN} already activated"
267 echo
268 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
269 if [[ "${answer}" != "yes" ]]; then
270 einfo "aborted"
271 return
272 fi
273 einfo "Removing ${INSTALLPLUGIN} from active plugins."
274 local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1)
275 sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \
276 -e ${LINE}'s/ \( \)*/ /g' \
277 -e ${LINE}'s/ "/"/g' \
278 -e ${LINE}'s/" /"/g'
279
280 vdr-plugin_pkg_config_final
281 return
282 fi
283
284
285 einfo "Adding ${INSTALLPLUGIN} to active plugins."
286 local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1)
287 sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \
288 -e ${LINE}'s/ \( \)*/ /g' \
289 -e ${LINE}'s/ "/"/g' \
290 -e ${LINE}'s/" /"/g'
291
292 vdr-plugin_pkg_config_final
293}
294
179EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm 295EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20