/[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.53 Revision 1.58
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.53 2008/02/13 19:44:44 zzam Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/vdr-plugin.eclass,v 1.58 2008/04/22 11:04:05 zzam Exp $
4# 4#
5# Author: 5# Author:
6# Matthias Schwarzott <zzam@gentoo.org> 6# Matthias Schwarzott <zzam@gentoo.org>
7# Joerg Bornkessel <hd_brummy@gentoo.org> 7# Joerg Bornkessel <hd_brummy@gentoo.org>
8 8
145 doins header-md5-${PN} 145 doins header-md5-${PN}
146 fi 146 fi
147 fi 147 fi
148} 148}
149 149
150vdr-plugin_pkg_setup() { 150fix_vdr_libsi_include()
151 # -fPIC is needed for shared objects on some platforms (amd64 and others) 151{
152 append-flags -fPIC 152 einfo "Fixing include of libsi-headers"
153 local f
154 for f; do
155 sed -i "${f}" \
156 -e '/#include/s:"\(.*libsi.*\)":<\1>:' \
157 -e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:'
158 done
159}
153 160
154 # Where should the plugins live in the filesystem 161vdr_patchmakefile() {
155 VDR_PLUGIN_DIR="/usr/$(get_libdir)/vdr/plugins" 162 einfo "Patching Makefile"
156 VDR_CHECKSUM_DIR="${VDR_PLUGIN_DIR%/plugins}/checksums" 163 [[ -e Makefile ]] || die "Makefile of plugin can not be found!"
164 cp Makefile "${WORKDIR}"/Makefile.before
157 165
158 # was /usr/lib/... some time ago 166 ebegin " Setting Pathes"
159 # since gentoo-vdr-scripts-0.3.6 it works with /usr/share/... 167 sed -i Makefile \
160 VDR_RC_DIR="/usr/share/vdr/rcscript" 168 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
169 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
170 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
171 -e 's:-I$(VDRDIR)/include:-I'"${VDR_INCLUDE_DIR%vdr}"':' \
172 -e "/^DVBDIR/d" \
173 -e 's:-I$(DVBDIR)/include::'
174 eend $?
161 175
162 # Pathes to includes 176 # maybe needed for multiproto:
163 VDR_INCLUDE_DIR="/usr/include/vdr" 177 #sed -i Makefile \
164 DVB_INCLUDE_DIR="/usr/include" 178 # -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
179 # -e 's:-I$(VDRDIR)/include -I$(DVBDIR)/include:-I$(DVBDIR)/include -I$(VDRDIR)/include:' \
180 # -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):'
165 181
182 if ! grep -q APIVERSION Makefile; then
183 ebegin " Converting to APIVERSION"
184 sed -i Makefile \
185 -e 's:^APIVERSION = :APIVERSION ?= :' \
186 -e 's:$(LIBDIR)/$@.$(VDRVERSION):$(LIBDIR)/$@.$(APIVERSION):' \
187 -e '/VDRVERSION =/a\APIVERSION = $(shell sed -ne '"'"'/define APIVERSION/s/^.*"\\(.*\\)".*$$/\\1/p'"'"' $(VDRDIR)/config.h)'
188 eend $?
189 fi
166 190
167 TMP_LOCALE_DIR="${WORKDIR}/tmp-locale" 191 # Correcting Compile-Flags
168 LOCDIR="/usr/share/vdr/locale" 192 # Do not overwrite CXXFLAGS, add LDFLAGS if missing
193 sed -i Makefile \
194 -e '/^CXXFLAGS[[:space:]]*=/s/=/?=/' \
195 -e '/LDFLAGS/!s:-shared:$(LDFLAGS) -shared:'
196
197 # Disabling file stripping, useful for debugging
198 sed -i Makefile \
199 -e '/@.*strip/d' \
200 -e '/strip \$(LIBDIR)\/\$@/d' \
201 -e '/@.*\$(STRIP)/d'
202
203 # Use a file instead of a variable as single-stepping via ebuild
204 # destroys environment.
205 touch "${WORKDIR}"/.vdr-plugin_makefile_patched
206}
207
208vdr_add_local_patch() {
209 if test -d "${VDR_LOCAL_PATCHES_DIR}/${PN}"; then
210 echo
211 einfo "Applying local patches"
212 for LOCALPATCH in "${VDR_LOCAL_PATCHES_DIR}/${PN}/${PV}"/*.{diff,patch}; do
213 test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}"
214 done
215 fi
216}
217
218vdr_has_gettext() {
169 if has_version ">=media-video/vdr-1.5.7"; then 219 has_version ">=media-video/vdr-1.5.7"
170 USE_GETTEXT=1 220}
221
222plugin_has_gettext() {
223 [[ -d po ]]
224}
225
226vdr_i18n_convert_to_gettext() {
227 local i18n_tool="${ROOT}/usr/share/vdr/bin/i18n-to-gettext.pl"
228
229 if [[ ${NO_GETTEXT_HACK} == "1" ]]; then
230 ewarn "Conversion to gettext disabled in ebuild"
231 return 1
232 fi
233
234 if [[ ! -x ${i18n_tool} ]]; then
235 eerror "Missing ${i18n_tool}"
236 eerror "Please re-emerge vdr"
237 die "Missing ${i18n_tool}"
238 fi
239
240 ebegin "Auto converting translations to gettext"
241 # call i18n-to-gettext tool
242 # take all texts missing tr call into special file
243 "${i18n_tool}" 2>/dev/null \
244 |sed -e '/^"/!d' \
245 -e '/^""$/d' \
246 -e 's/\(.*\)/trNOOP(\1)/' \
247 > dummy-translations-trNOOP.c
248
249 # if there were untranslated texts just run it again
250 # now the missing calls are listed in
251 # dummy-translations-trNOOP.c
252 if [[ -s dummy-translations-trNOOP.c ]]; then
253 "${i18n_tool}" &>/dev/null
254 fi
255
256 # now use the modified Makefile
257 if [[ -f Makefile.new ]]; then
258 mv Makefile.new Makefile
259 eend 0 ""
171 else 260 else
172 USE_GETTEXT=0 261 eend 1 "Conversion to gettext failed. Plugin needs fixing."
262 return 1
173 fi 263 fi
174
175 VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
176 APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
177 [[ -z ${APIVERSION} ]] && APIVERSION="${VDRVERSION}"
178
179 einfo "Building ${PF} against vdr-${VDRVERSION}"
180 einfo "APIVERSION: ${APIVERSION}"
181} 264}
182 265
183vdr-plugin_src_unpack() { 266vdr_i18n_disable_gettext() {
184 if [[ -z ${VDR_INCLUDE_DIR} ]]; then 267 ebegin "Disabling gettext support in plugin"
185 eerror "Wrong use of vdr-plugin.eclass." 268 # Remove i18n Target if using older vdr
186 eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin_pkg_setup." 269 sed -i Makefile \
187 echo 270 -e '/^all:/s/ i18n//'
188 eerror "Please report this at bugs.gentoo.org." 271 eend 0
189 die "vdr-plugin_pkg_setup not called!" 272}
190 fi
191 [ -z "$1" ] && vdr-plugin_src_unpack unpack add_local_patch patchmakefile i18n
192 273
193 while [ "$1" ]; do 274vdr_i18n() {
194 275 if vdr_has_gettext; then
195 case "$1" in 276 einfo "VDR has gettext support"
196 all_but_unpack) 277 if plugin_has_gettext; then
197 vdr-plugin_src_unpack add_local_patch patchmakefile i18n 278 einfo "Plugin has gettext support, fine"
198 ;; 279 else
199 unpack) 280 vdr_i18n_convert_to_gettext
200 base_src_unpack 281 if [[ $? != 0 ]]; then
201 ;; 282 eerror ""
202 patchmakefile) 283 eerror "Plugin will have only english OSD texts"
203 if ! cd "${S}"; then 284 eerror "it needs manual fixing."
204 ewarn "There seems to be no plugin-directory with the name ${S##*/}"
205 ewarn "Perhaps you find one among these:"
206 cd "${WORKDIR}"
207 ewarn "$(/bin/ls -1 "${WORKDIR}")"
208 die "Could not change to plugin-source-directory!"
209 fi 285 fi
210
211 einfo "Patching Makefile"
212 [[ -e Makefile ]] || die "Makefile of plugin can not be found!"
213 cp Makefile "${WORKDIR}"/Makefile.before
214
215 sed -i Makefile \
216 -e '1i\#Makefile was patched by vdr-plugin.eclass'
217
218 ebegin " Setting Pathes"
219 sed -i Makefile \
220 -e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
221 -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
222 -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
223 -e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
224 -e 's:-I$(VDRDIR)/include -I$(DVBDIR)/include:-I$(DVBDIR)/include -I$(VDRDIR)/include:' \
225 -e 's:-I$(VDRDIR)/include:-I'"${VDR_INCLUDE_DIR%vdr}"':' \
226 -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):'
227 eend $?
228
229 ebegin " Converting to APIVERSION"
230 sed -i Makefile \
231 -e 's:^APIVERSION = :APIVERSION ?= :' \
232 -e 's:$(LIBDIR)/$@.$(VDRVERSION):$(LIBDIR)/$@.$(APIVERSION):' \
233 -e '2i\APIVERSION = '"${APIVERSION}"
234 eend $?
235
236 ebegin " Correcting Compile-Flags"
237 sed -i Makefile \
238 -e 's:^CXXFLAGS:#CXXFLAGS:' \
239 -e '/LDFLAGS/!s:-shared:$(LDFLAGS) -shared:'
240 eend $?
241
242 ebegin " Disabling file stripping"
243 sed -i Makefile \
244 -e '/@.*strip/d' \
245 -e '/strip \$(LIBDIR)\/\$@/d' \
246 -e '/^STRIP =/d' \
247 -e '/@.*\$(STRIP)/d'
248 eend $?
249
250 # Use a file instead of an variable as single-stepping via ebuild
251 # destroys environment.
252 touch "${WORKDIR}"/.vdr-plugin_makefile_patched
253 ;;
254 add_local_patch)
255 cd "${S}"
256 if test -d "${VDR_LOCAL_PATCHES_DIR}/${PN}"; then
257 echo
258 einfo "Applying local patches"
259 for LOCALPATCH in "${VDR_LOCAL_PATCHES_DIR}/${PN}/${PV}"/*.{diff,patch}; do
260 test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}"
261 done
262 fi 286 fi
263 ;; 287 else
264 i18n) 288 einfo "VDR has no gettext support"
265 cd "${S}" 289 if plugin_has_gettext; then
266 if [[ ${USE_GETTEXT} = 0 ]]; then 290 vdr_i18n_disable_gettext
267 # Remove i18n Target if using older vdr
268 sed -i Makefile \
269 -e '/^all:/s/ i18n//'
270 elif [[ ${USE_GETTEXT} = 1 && ! -d po && ${NO_GETTEXT_HACK} != 1 ]]; then
271 einfo "Converting translations to gettext"
272
273 local i18n_tool="${ROOT}/usr/share/vdr/bin/i18n-to-gettext.pl"
274 if [[ ! -x ${i18n_tool} ]]; then
275 eerror "Missing ${i18n_tool}"
276 eerror "Please re-emerge vdr"
277 die "Missing ${i18n_tool}"
278 fi
279
280 # call i18n-to-gettext tool
281 # take all texts missing tr call into special file
282 "${i18n_tool}" 2>/dev/null \
283 |sed -e '/^"/!d' \
284 -e '/^""$/d' \
285 -e 's/\(.*\)/trNOOP(\1)/' \
286 > dummy-translations-trNOOP.c
287
288 # if there were untranslated texts just run it again
289 # now the missing calls are listed in
290 # dummy-translations-trNOOP.c
291 if [[ -s dummy-translations-trNOOP.c ]]; then
292 "${i18n_tool}" &>/dev/null
293 fi
294
295 # now use the modified Makefile
296 mv Makefile.new Makefile
297 fi 291 fi
298 esac 292 fi
299
300 shift
301 done
302} 293}
303 294
304vdr-plugin_copy_source_tree() { 295vdr-plugin_copy_source_tree() {
305 pushd . >/dev/null 296 pushd . >/dev/null
306 cp -r "${S}" "${T}"/source-tree 297 cp -r "${S}" "${T}"/source-tree
321 doins -r "${T}"/source-tree/* 312 doins -r "${T}"/source-tree/*
322 313
323 dosym "${VDRPLUGIN}-${PV}" "${destdir}" 314 dosym "${VDRPLUGIN}-${PV}" "${destdir}"
324} 315}
325 316
317vdr-plugin_print_enable_command() {
318 elog
319 elog "To activate this vdr-plugin execute the following command:"
320 elog "\teselect vdr-plugin enable ${PN#vdr-}"
321 elog
322}
323
324
325## exported functions
326
327vdr-plugin_pkg_setup() {
328 # -fPIC is needed for shared objects on some platforms (amd64 and others)
329 append-flags -fPIC
330
331 # Where should the plugins live in the filesystem
332 VDR_PLUGIN_DIR="/usr/$(get_libdir)/vdr/plugins"
333 VDR_CHECKSUM_DIR="${VDR_PLUGIN_DIR%/plugins}/checksums"
334
335 # was /usr/lib/... some time ago
336 # since gentoo-vdr-scripts-0.3.6 it works with /usr/share/...
337 VDR_RC_DIR="/usr/share/vdr/rcscript"
338
339 # Pathes to includes
340 VDR_INCLUDE_DIR="/usr/include/vdr"
341 DVB_INCLUDE_DIR="/usr/include"
342
343
344 TMP_LOCALE_DIR="${WORKDIR}/tmp-locale"
345 LOCDIR="/usr/share/vdr/locale"
346
347 VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
348 APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
349 [[ -z ${APIVERSION} ]] && APIVERSION="${VDRVERSION}"
350
351 einfo "Compiling against"
352 einfo "\tvdr-${VDRVERSION} [API version ${APIVERSION}]"
353}
354
355vdr-plugin_src_unpack() {
356 if [[ -z ${VDR_INCLUDE_DIR} ]]; then
357 eerror "Wrong use of vdr-plugin.eclass."
358 eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin_pkg_setup."
359 echo
360 eerror "Please report this at bugs.gentoo.org."
361 die "vdr-plugin_pkg_setup not called!"
362 fi
363 [ -z "$1" ] && vdr-plugin_src_unpack unpack add_local_patch patchmakefile i18n
364
365 while [ "$1" ]; do
366
367 case "$1" in
368 all_but_unpack)
369 vdr-plugin_src_unpack add_local_patch patchmakefile i18n
370 ;;
371 unpack)
372 base_src_unpack
373 ;;
374 add_local_patch)
375 cd "${S}" || die "Could not change to plugin-source-directory!"
376 vdr_add_local_patch
377 ;;
378 patchmakefile)
379 cd "${S}" || die "Could not change to plugin-source-directory!"
380 vdr_patchmakefile
381 ;;
382 i18n)
383 cd "${S}" || die "Could not change to plugin-source-directory!"
384 vdr_i18n
385 ;;
386 esac
387
388 shift
389 done
390}
391
326vdr-plugin_src_compile() { 392vdr-plugin_src_compile() {
327 [ -z "$1" ] && vdr-plugin_src_compile prepare compile 393 [ -z "$1" ] && vdr-plugin_src_compile prepare compile
328 394
329 while [ "$1" ]; do 395 while [ "$1" ]; do
330 396
378 444
379 cd "${S}" 445 cd "${S}"
380 insinto "${VDR_PLUGIN_DIR}" 446 insinto "${VDR_PLUGIN_DIR}"
381 doins libvdr-*.so.* 447 doins libvdr-*.so.*
382 448
383 if [[ ${USE_GETTEXT} = 1 && -d ${TMP_LOCALE_DIR} ]]; then 449 if vdr_has_gettext && [[ -d ${TMP_LOCALE_DIR} ]]; then
384 einfo "Installing locales" 450 einfo "Installing locales"
385 cd "${TMP_LOCALE_DIR}" 451 cd "${TMP_LOCALE_DIR}"
386 insinto "${LOCDIR}" 452 insinto "${LOCDIR}"
387 doins -r * 453 doins -r *
388 fi 454 fi
411 477
412 create_header_checksum_file 478 create_header_checksum_file
413 create_plugindb_file 479 create_plugindb_file
414} 480}
415 481
416vdr-plugin_print_enable_command() {
417 ewarn "emerge --config ${PN} is deprecated"
418 elog
419 elog "To activate this vdr-plugin execute the following command:"
420 elog "\teselect vdr-plugin enable ${PN#vdr-}"
421 elog
422}
423
424vdr-plugin_pkg_postinst() { 482vdr-plugin_pkg_postinst() {
425 vdr-plugin_print_enable_command 483 vdr-plugin_print_enable_command
426 484
427 if [[ -n "${VDR_CONFD_FILE}" ]]; then 485 if [[ -n "${VDR_CONFD_FILE}" ]]; then
428 elog "Please have a look at the config-file" 486 elog "Please have a look at the config-file"
433 491
434vdr-plugin_pkg_postrm() { 492vdr-plugin_pkg_postrm() {
435 delete_orphan_plugindb_file 493 delete_orphan_plugindb_file
436} 494}
437 495
438vdr-plugin_pkg_config_legacy() {
439 elog "Using old interface to gentoo-vdr-scripts-0.3.7"
440 if [[ -z "${INSTALLPLUGIN}" ]]; then
441 INSTALLPLUGIN="${VDRPLUGIN}"
442 fi
443
444 active=0
445 # First test if plugin is already inside PLUGINS
446 local conf=/etc/conf.d/vdr.plugins
447 exec 3<${conf}
448 while read -u 3 line; do
449 [[ ${line} == "" ]] && continue
450 [[ ${line:0:1} == "#" ]] && continue
451 set -- ${line}
452 [[ ${1} == ${INSTALLPLUGIN} ]] && active=1
453 done
454 exec 3<&-
455
456 if [[ $active == 0 ]]; then
457 elog "Adding ${INSTALLPLUGIN} to active plugins."
458
459 # The pure edit process.
460 echo "${INSTALLPLUGIN}" >> "${conf}"
461 else
462 elog "${INSTALLPLUGIN} already activated"
463 echo
464 read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer
465 if [[ "${answer}" != "yes" ]]; then
466 elog "aborted"
467 return
468 fi
469 elog "Removing ${INSTALLPLUGIN} from active plugins."
470
471 # The pure edit process
472 sed -i "${conf}" -e "/^[[:space:]]*${INSTALLPLUGIN}[[:space:]]*\$/d"
473 fi
474}
475
476vdr-plugin_pkg_config() { 496vdr-plugin_pkg_config() {
497 ewarn "emerge --config ${PN} is no longer supported"
477 vdr-plugin_print_enable_command 498 vdr-plugin_print_enable_command
478
479 einfo "Calling this now"
480 eselect vdr-plugin enable "${PN#vdr-}"
481}
482
483fix_vdr_libsi_include()
484{
485 einfo "Fixing include of libsi-headers"
486 local f
487 for f; do
488 sed -i "${f}" \
489 -e '/#include/s:"\(.*libsi.*\)":<\1>:' \
490 -e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:'
491 done
492} 499}
493 500
494EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config 501EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_config

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.58

  ViewVC Help
Powered by ViewVC 1.1.20