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

Contents of /eclass/vdr-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (hide annotations) (download)
Wed Apr 26 13:36:10 2006 UTC (7 years, 11 months ago) by zzam
Branch: MAIN
Changes since 1.18: +3 -3 lines
Correct a problem with getting version numbers for newer versions. Reported by Harri Kukkonen <harrik@gmail.com>.

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

  ViewVC Help
Powered by ViewVC 1.1.20