/[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.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.53 2008/02/13 19:44:44 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 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" 211 einfo "Applying local patches"
259 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
260 test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}" 213 test -f "${LOCALPATCH}" && epatch "${LOCALPATCH}"
261 done 214 done
262 fi 215 fi
263 ;; 216}
264 i18n) 217
265 cd "${S}" 218vdr_i18n() {
266 if [[ ${USE_GETTEXT} = 0 ]]; then 219 if [[ ${USE_GETTEXT} = 0 ]]; then
267 # Remove i18n Target if using older vdr 220 # Remove i18n Target if using older vdr
268 sed -i Makefile \ 221 sed -i Makefile \
269 -e '/^all:/s/ i18n//' 222 -e '/^all:/s/ i18n//'
270 elif [[ ${USE_GETTEXT} = 1 && ! -d po && ${NO_GETTEXT_HACK} != 1 ]]; then 223 elif [[ ${USE_GETTEXT} = 1 && ! -d po && ${NO_GETTEXT_HACK} != 1 ]]; then
224 einfo "Plugin is not yet changed for new translation system."
271 einfo "Converting translations to gettext" 225 einfo "Auto converting translations to gettext"
272 226
273 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"
274 if [[ ! -x ${i18n_tool} ]]; then 228 if [[ ! -x ${i18n_tool} ]]; then
275 eerror "Missing ${i18n_tool}" 229 eerror "Missing ${i18n_tool}"
276 eerror "Please re-emerge vdr" 230 eerror "Please re-emerge vdr"
277 die "Missing ${i18n_tool}" 231 die "Missing ${i18n_tool}"
278 fi 232 fi
279 233
280 # call i18n-to-gettext tool 234 # call i18n-to-gettext tool
281 # take all texts missing tr call into special file 235 # take all texts missing tr call into special file
282 "${i18n_tool}" 2>/dev/null \ 236 "${i18n_tool}" 2>/dev/null \
283 |sed -e '/^"/!d' \ 237 |sed -e '/^"/!d' \
284 -e '/^""$/d' \ 238 -e '/^""$/d' \
285 -e 's/\(.*\)/trNOOP(\1)/' \ 239 -e 's/\(.*\)/trNOOP(\1)/' \
286 > dummy-translations-trNOOP.c 240 > dummy-translations-trNOOP.c
287 241
288 # if there were untranslated texts just run it again 242 # if there were untranslated texts just run it again
289 # now the missing calls are listed in 243 # now the missing calls are listed in
290 # dummy-translations-trNOOP.c 244 # dummy-translations-trNOOP.c
291 if [[ -s dummy-translations-trNOOP.c ]]; then 245 if [[ -s dummy-translations-trNOOP.c ]]; then
292 "${i18n_tool}" &>/dev/null 246 "${i18n_tool}" &>/dev/null
293 fi 247 fi
294 248
295 # now use the modified Makefile 249 # now use the modified Makefile
250 if [[ -f Makefile.new ]]; then
296 mv Makefile.new Makefile 251 mv Makefile.new Makefile
252 else
253 ewarn "Conversion to gettext failed. Plugin needs fixing."
297 fi 254 fi
298 esac 255 fi
299
300 shift
301 done
302} 256}
303 257
304vdr-plugin_copy_source_tree() { 258vdr-plugin_copy_source_tree() {
305 pushd . >/dev/null 259 pushd . >/dev/null
306 cp -r "${S}" "${T}"/source-tree 260 cp -r "${S}" "${T}"/source-tree
321 doins -r "${T}"/source-tree/* 275 doins -r "${T}"/source-tree/*
322 276
323 dosym "${VDRPLUGIN}-${PV}" "${destdir}" 277 dosym "${VDRPLUGIN}-${PV}" "${destdir}"
324} 278}
325 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
326vdr-plugin_src_compile() { 360vdr-plugin_src_compile() {
327 [ -z "$1" ] && vdr-plugin_src_compile prepare compile 361 [ -z "$1" ] && vdr-plugin_src_compile prepare compile
328 362
329 while [ "$1" ]; do 363 while [ "$1" ]; do
330 364
411 445
412 create_header_checksum_file 446 create_header_checksum_file
413 create_plugindb_file 447 create_plugindb_file
414} 448}
415 449
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() { 450vdr-plugin_pkg_postinst() {
425 vdr-plugin_print_enable_command 451 vdr-plugin_print_enable_command
426 452
427 if [[ -n "${VDR_CONFD_FILE}" ]]; then 453 if [[ -n "${VDR_CONFD_FILE}" ]]; then
428 elog "Please have a look at the config-file" 454 elog "Please have a look at the config-file"
433 459
434vdr-plugin_pkg_postrm() { 460vdr-plugin_pkg_postrm() {
435 delete_orphan_plugindb_file 461 delete_orphan_plugindb_file
436} 462}
437 463
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() { 464vdr-plugin_pkg_config() {
465 ewarn "emerge --config ${PN} is no longer supported"
477 vdr-plugin_print_enable_command 466 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} 467}
493 468
494EXPORT_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.53  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.20