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

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.20