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