| 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.39 2007/01/05 13:16:57 zzam Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.40 2007/01/05 17:24:19 hd_brummy 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 | |
| … | |
… | |
| 84 | if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then |
84 | if [[ ! -f ${VDRPLUGINDB_DIR}/vdrplugindb ]]; then |
| 85 | [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR} |
85 | [[ ! -d ${VDRPLUGINDB_DIR} ]] && mkdir -p ${VDRPLUGINDB_DIR} |
| 86 | touch ${VDRPLUGINDB_DIR}/vdrplugindb |
86 | touch ${VDRPLUGINDB_DIR}/vdrplugindb |
| 87 | fi |
87 | fi |
| 88 | if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
88 | if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
| 89 | einfo "Adding plugin to vdrplugindb." |
89 | elog "Adding plugin to vdrplugindb." |
| 90 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb |
90 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${VDRPLUGINDB_DIR}/vdrplugindb |
| 91 | fi |
91 | fi |
| 92 | } |
92 | } |
| 93 | |
93 | |
| 94 | remove_vdrplugindb() { |
94 | remove_vdrplugindb() { |
| 95 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/ |
95 | local VDRPLUGINDB_DIR=${ROOT}/var/lib/vdrplugin-rebuild/ |
| 96 | |
96 | |
| 97 | if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
97 | if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${VDRPLUGINDB_DIR}/vdrplugindb) ]]; then |
| 98 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb." |
98 | elog "Removing ${CATEGORY}/${PN}-${PVR} from vdrplugindb." |
| 99 | sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb |
99 | sed -ie "/.*${CATEGORY}\/${P}.*/d" ${VDRPLUGINDB_DIR}/vdrplugindb |
| 100 | fi |
100 | fi |
| 101 | } |
101 | } |
| 102 | |
102 | |
| 103 | # New method of storing plugindb |
103 | # New method of storing plugindb |
| … | |
… | |
| 119 | # vdrplugin-rebuild.ebuild converted plugindb and files are |
119 | # vdrplugin-rebuild.ebuild converted plugindb and files are |
| 120 | # not deleted by portage itself - should only be needed as |
120 | # not deleted by portage itself - should only be needed as |
| 121 | # long as not every system has switched over to |
121 | # long as not every system has switched over to |
| 122 | # vdrplugin-rebuild-0.2 |
122 | # vdrplugin-rebuild-0.2 |
| 123 | delete_orphan_plugindb_file() { |
123 | delete_orphan_plugindb_file() { |
| 124 | #einfo Testing for orphaned plugindb file |
124 | #elog Testing for orphaned plugindb file |
| 125 | local NEW_VDRPLUGINDB_DIR=/usr/share/vdr/vdrplugin-rebuild/ |
125 | local NEW_VDRPLUGINDB_DIR=/usr/share/vdr/vdrplugin-rebuild/ |
| 126 | local DB_FILE=${ROOT}/${NEW_VDRPLUGINDB_DIR}/${CATEGORY}-${PF} |
126 | local DB_FILE=${ROOT}/${NEW_VDRPLUGINDB_DIR}/${CATEGORY}-${PF} |
| 127 | |
127 | |
| 128 | # file exists |
128 | # file exists |
| 129 | [[ -f ${DB_FILE} ]] || return |
129 | [[ -f ${DB_FILE} ]] || return |
| 130 | |
130 | |
| 131 | # will portage handle the file itself |
131 | # will portage handle the file itself |
| 132 | if grep -q CREATOR=ECLASS ${DB_FILE}; then |
132 | if grep -q CREATOR=ECLASS ${DB_FILE}; then |
| 133 | #einfo file owned by eclass - don't touch it |
133 | #elog file owned by eclass - don't touch it |
| 134 | return |
134 | return |
| 135 | fi |
135 | fi |
| 136 | |
136 | |
| 137 | einfo "Removing orphaned plugindb-file." |
137 | elog "Removing orphaned plugindb-file." |
| 138 | einfo "#rm ${DB_FILE}" |
138 | elog "#rm ${DB_FILE}" |
| 139 | rm ${DB_FILE} |
139 | rm ${DB_FILE} |
| 140 | } |
140 | } |
| 141 | |
141 | |
| 142 | vdr-plugin_pkg_setup() { |
142 | vdr-plugin_pkg_setup() { |
| 143 | # -fPIC is needed for shared objects on some platforms (amd64 and others) |
143 | # -fPIC is needed for shared objects on some platforms (amd64 and others) |
| … | |
… | |
| 158 | |
158 | |
| 159 | VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' ${VDR_INCLUDE_DIR}/config.h) |
159 | VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' ${VDR_INCLUDE_DIR}/config.h) |
| 160 | APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' ${VDR_INCLUDE_DIR}/config.h) |
160 | APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' ${VDR_INCLUDE_DIR}/config.h) |
| 161 | [[ -z ${APIVERSION} ]] && APIVERSION="${VDRVERSION}" |
161 | [[ -z ${APIVERSION} ]] && APIVERSION="${VDRVERSION}" |
| 162 | |
162 | |
| 163 | einfo "Building ${PF} against vdr-${VDRVERSION}" |
163 | elog "Building ${PF} against vdr-${VDRVERSION}" |
| 164 | einfo "APIVERSION: ${APIVERSION}" |
164 | elog "APIVERSION: ${APIVERSION}" |
| 165 | } |
165 | } |
| 166 | |
166 | |
| 167 | vdr-plugin_src_unpack() { |
167 | vdr-plugin_src_unpack() { |
| 168 | if [[ -z ${VDR_INCLUDE_DIR} ]]; then |
168 | if [[ -z ${VDR_INCLUDE_DIR} ]]; then |
| 169 | eerror "Wrong use of vdr-plugin.eclass." |
169 | eerror "Wrong use of vdr-plugin.eclass." |
| … | |
… | |
| 186 | patchmakefile) |
186 | patchmakefile) |
| 187 | if ! cd ${S}; then |
187 | if ! cd ${S}; then |
| 188 | ewarn "There seems to be no plugin-directory with the name ${S##*/}" |
188 | ewarn "There seems to be no plugin-directory with the name ${S##*/}" |
| 189 | ewarn "Perhaps you find one among these:" |
189 | ewarn "Perhaps you find one among these:" |
| 190 | cd "${WORKDIR}" |
190 | cd "${WORKDIR}" |
| 191 | einfo "$(/bin/ls -1 ${WORKDIR})" |
191 | elog "$(/bin/ls -1 ${WORKDIR})" |
| 192 | die "Could not change to plugin-source-directory!" |
192 | die "Could not change to plugin-source-directory!" |
| 193 | fi |
193 | fi |
| 194 | |
194 | |
| 195 | einfo "Patching Makefile" |
195 | elog "Patching Makefile" |
| 196 | [[ -e Makefile ]] || die "Makefile of plugin can not be found!" |
196 | [[ -e Makefile ]] || die "Makefile of plugin can not be found!" |
| 197 | cp Makefile Makefile.orig |
197 | cp Makefile Makefile.orig |
| 198 | |
198 | |
| 199 | sed -i Makefile \ |
199 | sed -i Makefile \ |
| 200 | -e '1i\#Makefile was patched by vdr-plugin.eclass' |
200 | -e '1i\#Makefile was patched by vdr-plugin.eclass' |
| … | |
… | |
| 237 | ;; |
237 | ;; |
| 238 | add_local_patch) |
238 | add_local_patch) |
| 239 | cd ${S} |
239 | cd ${S} |
| 240 | if test -d "${VDR_LOCAL_PATCHES_DIR}/${PN}"; then |
240 | if test -d "${VDR_LOCAL_PATCHES_DIR}/${PN}"; then |
| 241 | echo |
241 | echo |
| 242 | einfo "Applying local patches" |
242 | elog "Applying local patches" |
| 243 | for LOCALPATCH in ${VDR_LOCAL_PATCHES_DIR}/${PN}/${PV}/*.{diff,patch}; do |
243 | for LOCALPATCH in ${VDR_LOCAL_PATCHES_DIR}/${PN}/${PV}/*.{diff,patch}; do |
| 244 | test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}" |
244 | test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}" |
| 245 | done |
245 | done |
| 246 | fi |
246 | fi |
| 247 | ;; |
247 | ;; |
| … | |
… | |
| 263 | -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' |
263 | -e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' |
| 264 | popd >/dev/null |
264 | popd >/dev/null |
| 265 | } |
265 | } |
| 266 | |
266 | |
| 267 | vdr-plugin_install_source_tree() { |
267 | vdr-plugin_install_source_tree() { |
| 268 | einfo "Installing sources" |
268 | elog "Installing sources" |
| 269 | destdir=${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN} |
269 | destdir=${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN} |
| 270 | insinto ${destdir}-${PV} |
270 | insinto ${destdir}-${PV} |
| 271 | doins -r ${T}/source-tree/* |
271 | doins -r ${T}/source-tree/* |
| 272 | |
272 | |
| 273 | dosym ${VDRPLUGIN}-${PV} ${destdir} |
273 | dosym ${VDRPLUGIN}-${PV} ${destdir} |
| … | |
… | |
| 368 | |
368 | |
| 369 | vdr-plugin_pkg_postinst() { |
369 | vdr-plugin_pkg_postinst() { |
| 370 | if has_version "<=media-tv/vdrplugin-rebuild-0.1"; then |
370 | if has_version "<=media-tv/vdrplugin-rebuild-0.1"; then |
| 371 | update_vdrplugindb |
371 | update_vdrplugindb |
| 372 | fi |
372 | fi |
| 373 | einfo |
373 | elog |
| 374 | einfo "The vdr plugin ${VDRPLUGIN} has now been installed." |
374 | elog "The vdr plugin ${VDRPLUGIN} has now been installed." |
| 375 | einfo "To activate execute the following command:" |
375 | elog "To activate execute the following command:" |
| 376 | einfo |
376 | elog |
| 377 | einfo " emerge --config ${PN}" |
377 | elog " emerge --config ${PN}" |
| 378 | einfo |
378 | elog |
| 379 | if [[ -n "${VDR_CONFD_FILE}" ]]; then |
379 | if [[ -n "${VDR_CONFD_FILE}" ]]; then |
| 380 | einfo "And have a look at the config-file" |
380 | elog "And have a look at the config-file" |
| 381 | einfo "/etc/conf.d/vdr.${VDRPLUGIN}" |
381 | elog "/etc/conf.d/vdr.${VDRPLUGIN}" |
| 382 | einfo |
382 | elog |
| 383 | fi |
383 | fi |
| 384 | } |
384 | } |
| 385 | |
385 | |
| 386 | vdr-plugin_pkg_postrm() { |
386 | vdr-plugin_pkg_postrm() { |
| 387 | if has_version "<=media-tv/vdrplugin-rebuild-0.1"; then |
387 | if has_version "<=media-tv/vdrplugin-rebuild-0.1"; then |
| … | |
… | |
| 394 | diff ${conf_orig} ${conf} |
394 | diff ${conf_orig} ${conf} |
| 395 | rm ${conf_orig} |
395 | rm ${conf_orig} |
| 396 | } |
396 | } |
| 397 | |
397 | |
| 398 | vdr-plugin_pkg_config_old() { |
398 | vdr-plugin_pkg_config_old() { |
| 399 | einfo "Using interface of gentoo-vdr-scripts-0.3.6 and older" |
399 | elog "Using interface of gentoo-vdr-scripts-0.3.6 and older" |
| 400 | if [[ -z "${INSTALLPLUGIN}" ]]; then |
400 | if [[ -z "${INSTALLPLUGIN}" ]]; then |
| 401 | INSTALLPLUGIN="${VDRPLUGIN}" |
401 | INSTALLPLUGIN="${VDRPLUGIN}" |
| 402 | fi |
402 | fi |
| 403 | # First test if plugin is already inside PLUGINS |
403 | # First test if plugin is already inside PLUGINS |
| 404 | local conf=/etc/conf.d/vdr |
404 | local conf=/etc/conf.d/vdr |
| 405 | conf_orig=${conf}.before_emerge_config |
405 | conf_orig=${conf}.before_emerge_config |
| 406 | cp ${conf} ${conf_orig} |
406 | cp ${conf} ${conf_orig} |
| 407 | |
407 | |
| 408 | einfo "Reading ${conf}" |
408 | elog "Reading ${conf}" |
| 409 | if ! grep -q "^PLUGINS=" ${conf}; then |
409 | if ! grep -q "^PLUGINS=" ${conf}; then |
| 410 | local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1) |
410 | local LINE=$(sed ${conf} -n -e '/^#.*PLUGINS=/=' | tail -n 1) |
| 411 | if [[ -n "${LINE}" ]]; then |
411 | if [[ -n "${LINE}" ]]; then |
| 412 | sed -e ${LINE}'a PLUGINS=""' -i ${conf} |
412 | sed -e ${LINE}'a PLUGINS=""' -i ${conf} |
| 413 | else |
413 | else |
| … | |
… | |
| 426 | break; |
426 | break; |
| 427 | fi |
427 | fi |
| 428 | done |
428 | done |
| 429 | |
429 | |
| 430 | if [[ "${active}" == "1" ]]; then |
430 | if [[ "${active}" == "1" ]]; then |
| 431 | einfo "${INSTALLPLUGIN} already activated" |
431 | elog "${INSTALLPLUGIN} already activated" |
| 432 | echo |
432 | echo |
| 433 | read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer |
433 | read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer |
| 434 | if [[ "${answer}" != "yes" ]]; then |
434 | if [[ "${answer}" != "yes" ]]; then |
| 435 | einfo "aborted" |
435 | elog "aborted" |
| 436 | return |
436 | return |
| 437 | fi |
437 | fi |
| 438 | einfo "Removing ${INSTALLPLUGIN} from active plugins." |
438 | elog "Removing ${INSTALLPLUGIN} from active plugins." |
| 439 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1) |
439 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=.*\<'${INSTALLPLUGIN}'\>/=' | tail -n 1) |
| 440 | sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \ |
440 | sed -i ${conf} -e ${LINE}'s/\<'${INSTALLPLUGIN}'\>//' \ |
| 441 | -e ${LINE}'s/ \( \)*/ /g' \ |
441 | -e ${LINE}'s/ \( \)*/ /g' \ |
| 442 | -e ${LINE}'s/ "/"/g' \ |
442 | -e ${LINE}'s/ "/"/g' \ |
| 443 | -e ${LINE}'s/" /"/g' |
443 | -e ${LINE}'s/" /"/g' |
| … | |
… | |
| 445 | vdr-plugin_pkg_config_final |
445 | vdr-plugin_pkg_config_final |
| 446 | return |
446 | return |
| 447 | fi |
447 | fi |
| 448 | |
448 | |
| 449 | |
449 | |
| 450 | einfo "Adding ${INSTALLPLUGIN} to active plugins." |
450 | elog "Adding ${INSTALLPLUGIN} to active plugins." |
| 451 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1) |
451 | local LINE=$(sed ${conf} -n -e '/^PLUGINS=/=' | tail -n 1) |
| 452 | sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \ |
452 | sed -i ${conf} -e ${LINE}'s/^PLUGINS=" *\(.*\)"/PLUGINS="\1 '${INSTALLPLUGIN}'"/' \ |
| 453 | -e ${LINE}'s/ \( \)*/ /g' \ |
453 | -e ${LINE}'s/ \( \)*/ /g' \ |
| 454 | -e ${LINE}'s/ "/"/g' \ |
454 | -e ${LINE}'s/ "/"/g' \ |
| 455 | -e ${LINE}'s/" /"/g' |
455 | -e ${LINE}'s/" /"/g' |
| 456 | |
456 | |
| 457 | vdr-plugin_pkg_config_final |
457 | vdr-plugin_pkg_config_final |
| 458 | } |
458 | } |
| 459 | |
459 | |
| 460 | vdr-plugin_pkg_config_new() { |
460 | vdr-plugin_pkg_config_new() { |
| 461 | einfo "Using interface introduced with gentoo-vdr-scripts-0.3.7" |
461 | elog "Using interface introduced with gentoo-vdr-scripts-0.3.7" |
| 462 | if [[ -z "${INSTALLPLUGIN}" ]]; then |
462 | if [[ -z "${INSTALLPLUGIN}" ]]; then |
| 463 | INSTALLPLUGIN="${VDRPLUGIN}" |
463 | INSTALLPLUGIN="${VDRPLUGIN}" |
| 464 | fi |
464 | fi |
| 465 | |
465 | |
| 466 | active=0 |
466 | active=0 |
| … | |
… | |
| 474 | [[ ${1} == ${INSTALLPLUGIN} ]] && active=1 |
474 | [[ ${1} == ${INSTALLPLUGIN} ]] && active=1 |
| 475 | done |
475 | done |
| 476 | exec 3<&- |
476 | exec 3<&- |
| 477 | |
477 | |
| 478 | if [[ $active == 0 ]]; then |
478 | if [[ $active == 0 ]]; then |
| 479 | einfo "Adding ${INSTALLPLUGIN} to active plugins." |
479 | elog "Adding ${INSTALLPLUGIN} to active plugins." |
| 480 | |
480 | |
| 481 | # The pure edit process. |
481 | # The pure edit process. |
| 482 | echo "${INSTALLPLUGIN}" >> "${conf}" |
482 | echo "${INSTALLPLUGIN}" >> "${conf}" |
| 483 | else |
483 | else |
| 484 | einfo "${INSTALLPLUGIN} already activated" |
484 | elog "${INSTALLPLUGIN} already activated" |
| 485 | echo |
485 | echo |
| 486 | read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer |
486 | read -p "Do you want to deactivate ${INSTALLPLUGIN} (yes/no) " answer |
| 487 | if [[ "${answer}" != "yes" ]]; then |
487 | if [[ "${answer}" != "yes" ]]; then |
| 488 | einfo "aborted" |
488 | elog "aborted" |
| 489 | return |
489 | return |
| 490 | fi |
490 | fi |
| 491 | einfo "Removing ${INSTALLPLUGIN} from active plugins." |
491 | elog "Removing ${INSTALLPLUGIN} from active plugins." |
| 492 | |
492 | |
| 493 | # The pure edit process |
493 | # The pure edit process |
| 494 | sed -i "${conf}" -e "/^[[:space:]]*${INSTALLPLUGIN}[[:space:]]*\$/d" |
494 | sed -i "${conf}" -e "/^[[:space:]]*${INSTALLPLUGIN}[[:space:]]*\$/d" |
| 495 | fi |
495 | fi |
| 496 | } |
496 | } |
| … | |
… | |
| 503 | fi |
503 | fi |
| 504 | } |
504 | } |
| 505 | |
505 | |
| 506 | fix_vdr_libsi_include() |
506 | fix_vdr_libsi_include() |
| 507 | { |
507 | { |
| 508 | einfo "Fixing include of libsi-headers" |
508 | elog "Fixing include of libsi-headers" |
| 509 | local f |
509 | local f |
| 510 | for f; do |
510 | for f; do |
| 511 | sed -i "${f}" \ |
511 | sed -i "${f}" \ |
| 512 | -e '/#include/s:"\(.*libsi.*\)":<\1>:' \ |
512 | -e '/#include/s:"\(.*libsi.*\)":<\1>:' \ |
| 513 | -e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:' |
513 | -e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:' |