summaryrefslogtreecommitdiff
path: root/eclass/vdr-plugin-2.eclass
blob: 289c3d1a624a5630d2ac894974fa8dff5b50628f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: vdr-plugin-2.eclass
# @MAINTAINER:
# Gentoo VDR Project <vdr@gentoo.org>
# @AUTHOR:
# Matthias Schwarzott <zzam@gentoo.org>
# Joerg Bornkessel <hd_brummy@gentoo.org>
# Christian Ruppert <idl0r@gentoo.org>
# (undisclosed contributors)
# @SUPPORTED_EAPIS: 7 8
# @BLURB: common vdr plugin ebuild functions
# @DESCRIPTION:
# Eclass for easing maintenance of vdr plugin ebuilds

# @ECLASS_VARIABLE: VDRPLUGIN
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# The name of the vdr plugin, plain name without "vdr-" or "plugin" prefix or suffix.
# This variable is derived from ${PN} and is read-only for the ebuild.

# @ECLASS_VARIABLE: VDR_CONFD_FILE
# @DEFAULT_UNSET
# @DESCRIPTION:
# A plugin config file can be specified through the $VDR_CONFD_FILE variable, it
# defaults to ${FILESDIR}/confd. Each config file will be installed as e.g.
# ${D}/etc/conf.d/vdr.${VDRPLUGIN}

# @ECLASS_VARIABLE: VDR_RCADDON_FILE
# @DEFAULT_UNSET
# @DESCRIPTION:
# Installing rc-addon files is basically the same as for plugin config files
# (see above), it's just using the $VDR_RCADDON_FILE variable instead.
# The default value when $VDR_RCADDON_FILE is undefined is:
# ${FILESDIR}/rc-addon.sh and will be installed as
# ${VDR_RC_DIR}/plugin-${VDRPLUGIN}.sh
#
# The rc-addon files will be sourced by the startscript when the specific plugin
# has been enabled.
# rc-addon files may be used to prepare everything that is necessary for the
# plugin start/stop, like passing extra command line options and so on.
#
# NOTE: rc-addon files must be valid shell scripts!

# @ECLASS_VARIABLE: GENTOO_VDR_CONDITIONAL
# @DEFAULT_UNSET
# @DESCRIPTION:
# This is a hack for ebuilds like vdr-xineliboutput that want to
# conditionally install a vdr-plugin

# @ECLASS_VARIABLE: PO_SUBDIR
# @DEFAULT_UNSET
# @DESCRIPTION:
# By default, translation are found in"${S}"/po but this
# default can be overridden by defining PO_SUBDIR.
#
# Example:
# @CODE
# PO_SUBDIR="bla foo/bla"
# @CODE

case ${EAPI} in
	7|8) ;;
	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac

if [[ -z ${_VDR_PLUGIN_2_ECLASS} ]]; then
_VDR_PLUGIN_2_ECLASS=1

inherit flag-o-matic strip-linguas toolchain-funcs unpacker

# Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
VDRPLUGIN="${PN/#vdrplugin-/}"
VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
VDRPLUGIN="${VDRPLUGIN/%-cvs/}"

DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin-2.eclass)"

# Works in most cases
S="${WORKDIR}/${VDRPLUGIN}-${PV}"

# depend on headers for DVB-driver and vdr-scripts
BDEPEND="virtual/pkgconfig"
DEPEND="media-tv/gentoo-vdr-scripts
	sys-kernel/linux-headers"
RDEPEND="media-tv/gentoo-vdr-scripts
	app-eselect/eselect-vdr"

if [[ "${GENTOO_VDR_CONDITIONAL:-no}" = "yes" ]]; then
	IUSE="${IUSE} vdr"
	DEPEND="vdr? ( ${DEPEND} )"
	RDEPEND="vdr? ( ${RDEPEND} )"
fi

# @FUNCTION: vdr_create_plugindb_file
# @INTERNAL
# @USAGE: <plugin name> [more plugin names]
# @DESCRIPTION:
# New method of storing plugindb
# Called from src_install
# file maintained by normal portage-methods
vdr_create_plugindb_file() {
	local NEW_VDRPLUGINDB_DIR=/usr/share/vdr/vdrplugin-rebuild/
	local DB_FILE="${NEW_VDRPLUGINDB_DIR}/${CATEGORY}-${PF}"
	insinto "${NEW_VDRPLUGINDB_DIR}"

#	BUG: portage-2.1.4_rc9 will delete the EBUILD= line, so we cannot use this code.
#	cat <<-EOT > "${D}/${DB_FILE}"
#		VDRPLUGIN_DB=1
#		CREATOR=ECLASS
#		EBUILD=${CATEGORY}/${PN}
#		EBUILD_V=${PVR}
#	EOT
#	obsolet? fix me later...
	{
		echo "VDRPLUGIN_DB=1"
		echo "CREATOR=ECLASS"
		echo "EBUILD=${CATEGORY}/${PN}"
		echo "EBUILD_V=${PVR}"
		echo "PLUGINS=\"$@\""
	} > "${D%/}/${DB_FILE}"
}

# @FUNCTION: vdr_create_header_checksum_file
# @USAGE:
# @INTERNAL
# @DESCRIPTION:
# Create a file with md5 checksums of .h header files of the plugin being compiled.
# The checksum files are used to detect if a plugin is compiled against the current
# vdr binary.
vdr_create_header_checksum_file() {
	# Danger: Not using $ROOT here, as compile will also not use it !!!
	# If vdr in $ROOT and / differ, plugins will not run anyway

	local CHKSUM="header-md5-vdr"

	if [[ -f ${VDR_CHECKSUM_DIR}/header-md5-vdr ]]; then
		cp "${VDR_CHECKSUM_DIR}/header-md5-vdr" "${CHKSUM}" \
			|| die "Could not copy header-md5-vdr"
	elif type -p md5sum >/dev/null 2>&1; then
		(
			cd "${VDR_INCLUDE_DIR}"
			md5sum *.h libsi/*.h|LC_ALL=C sort --key=2
		) > "${CHKSUM}"
	else
		die "Could not create md5 checksum of headers"
	fi

	insinto "${VDR_CHECKSUM_DIR}"
	local p_name
	for p_name; do
		newins "${CHKSUM}" "header-md5-${p_name}"
	done
}

# @FUNCTION: fix_vdr_libsi_include
# @USAGE: <filename> [more filenames]
# @DESCRIPTION:
# Plugins failed on compile with wrong path of libsi includes,
# this can be fixed by 'function + space separated list of files'
fix_vdr_libsi_include() {
	local f
	for f; do
		sed -i "${f}" \
			-e '/#include/s:"\(.*libsi.*\)":<\1>:' \
			-e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:' \
			|| die "sed failed while fixing include of libsi-headers"
	done
}

# @FUNCTION: vdr_patchmakefile
# @USAGE:
# @INTERNAL
# @DESCRIPTION:
# fix Makefile of the plugin for common mistakes often made by the authors or fix
# missing things introduced with new vdr versions
vdr_patchmakefile() {
	einfo "Patching Makefile"
	[[ -e Makefile ]] || die "Makefile of plugin can not be found!"
	cp Makefile "${WORKDIR}"/Makefile.before || die "Failed to copy Makefile"

	# plugin makefiles use VDRDIR in strange ways
	# assumptions:
	#   1. $(VDRDIR) contains Make.config
	#   2. $(VDRDIR) contains config.h
	#   3. $(VDRDIR)/include/vdr contains the headers
	#   4. $(VDRDIR) contains main vdr Makefile
	#   5. $(VDRDIR)/locale exists
	#   6. $(VDRDIR) allows to access vdr source files
	#
	# We only have one directory (for now /usr/include/vdr),
	# that contains vdr-headers and Make.config.
	# To satisfy 1-3 we do this:
	#   Set VDRDIR=/usr/include/vdr
	#   Set VDRINCDIR=/usr/include
	#   Change $(VDRDIR)/include to $(VDRINCDIR)

	sed -i Makefile \
		-e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
		-e "/^VDRDIR/a VDRINCDIR = ${VDR_INCLUDE_DIR%/vdr}" \
		-e '/VDRINCDIR.*=/!s:$(VDRDIR)/include:$(VDRINCDIR):' \
		\
		-e 's:-I$(DVBDIR)/include::' \
		-e 's:-I$(DVBDIR)::' \
		|| die "sed failed to set \$VDRDIR"

	if ! grep -q APIVERSION Makefile; then
		ebegin "  Converting to APIVERSION"
		sed -i Makefile \
			-e 's:^APIVERSION = :APIVERSION ?= :' \
			-e 's:$(LIBDIR)/$@.$(VDRVERSION):$(LIBDIR)/$@.$(APIVERSION):' \
			-e '/VDRVERSION =/a\APIVERSION = $(shell sed -ne '"'"'/define APIVERSION/s/^.*"\\(.*\\)".*$$/\\1/p'"'"' $(VDRDIR)/config.h)' \
			|| die "sed failed to change APIVERSION"
		eend $?
	fi

	# Correcting Compile-Flags
	# Do not overwrite CXXFLAGS, add LDFLAGS if missing
	sed -i Makefile \
		-e '/^CXXFLAGS[[:space:]]*=/s/=/?=/' \
		-e '/LDFLAGS/!s:-shared:$(LDFLAGS) -shared:' \
		|| die "sed failed to fix compile-flags"

	# Disabling file stripping, the package manager takes care of it
	sed -i Makefile \
		-e '/@.*strip/d' \
		-e '/strip \$(LIBDIR)\/\$@/d' \
		-e 's/STRIP.*=.*$/STRIP = true/' \
		|| die "sed failed to fix file stripping"

	# Use a file instead of a variable as single-stepping via ebuild
	# destroys environment.
	touch "${WORKDIR}"/.vdr-plugin_makefile_patched
}

# @FUNCTION: vdr_gettext_missing
# @USAGE:
# @INTERNAL
# @DESCRIPTION:
# emit a warning when a plugin is using the old localization methods
vdr_gettext_missing() {
	# plugins without converting to gettext

	local GETTEXT_MISSING=$( grep xgettext Makefile )
	if [[ -z ${GETTEXT_MISSING} ]]; then
		einfo "Notice: Plugin isn't converted to gettext handling!"
	fi
}

# @FUNCTION: vdr_detect_po_dir
# @INTERNAL
# @USAGE:
# @DESCRIPTION:
# helper function to find the
# DIR ${S}/po or DIR ${S]/_subdir_/po
vdr_detect_po_dir() {
	[[ -f po ]] && local po_dir="${S}"
	local po_subdir=( "${S}"/${PO_SUBDIR} )

	pofile_dir=( ${po_dir} "${po_subdir[@]}" )
}

# @FUNCTION: vdr_linguas_support
# @INTERNAL
# @USAGE:
# @DESCRIPTION:
# Patching Makefile for linguas support.
# Only locales, enabled through the LINGUAS (make.conf) variable will be
# compiled and installed.
vdr_linguas_support() {

	einfo "Patching for Linguas support"
	einfo "available Languages for ${P} are:"

	vdr_detect_po_dir

	for f in ${pofile_dir[*]}; do
		if [[ -d ${f}/po ]]; then
			PLUGIN_LINGUAS=$( ls ${f}/po --ignore="*.pot" | sed -e "s:.po::g" | cut -d_ -f1 | tr \\\012 ' ' )
		fi
		einfo "LINGUAS=\"${PLUGIN_LINGUAS}\""

		sed -i ${f}/Makefile \
			-e 's:\$(wildcard[[:space:]]*\$(PODIR)/\*.po):\$(foreach dir,\$(LINGUAS),\$(wildcard \$(PODIR)\/\$(dir)\*.po)):' \
			|| die "sed failed for Linguas"
	done

	strip-linguas ${PLUGIN_LINGUAS} en
}

# @FUNCTION: vdr_i18n
# @INTERNAL
# @USAGE:
# @DESCRIPTION:
# i18n handling was deprecated since >=media-video/vdr-1.5.9,
# finally with >=media-video/vdr-1.7.27 it has been dropped entirely and some
# plugins will fail to compile because they're still using the old variant.
# Simply remove the i18n.o object from Makefile (OBJECT) and
# remove "static const tI18nPhrase*" from i18n.h.
vdr_i18n() {
	vdr_gettext_missing

	local I18N_OBJECT=$( grep i18n.o Makefile )
	if [[ -n ${I18N_OBJECT} ]]; then

		if [[ "${KEEP_I18NOBJECT:-no}" = "yes" ]]; then
			einfo "Notice: Forced to keep i18n.o"
		else
			sed -i "s:i18n.o::g" Makefile \
				|| die "sed failed to remove i18n from Makefile"
			einfo "Notice: OBJECT i18n.o found, removed per sed"
		fi
	fi

	local I18N_STRING=$( [[ -e i18n.h ]] && grep tI18nPhrase i18n.h )
	if [[ -n ${I18N_STRING} ]]; then
		sed -i "s:^extern[[:space:]]*const[[:space:]]*tI18nPhrase://static const tI18nPhrase:" i18n.h \
			|| die "sed failed to replace tI18nPhrase"
		einfo "Notice: obsolete tI18nPhrase found, disabled per sed"
	fi
}

# @FUNCTION: vdr_remove_i18n_include
# @USAGE: <filename> [more filenames]
# @DESCRIPTION:
# Compile will fail if plugin still use the old i18n language handling,
# most parts are fixed by vdr-plugin-2.eclass internal functions itself.
# Remove unneeded i18n.h includes from files, if they are still wrong there,
# this can be fixed by this function with a space separated list of files
vdr_remove_i18n_include() {
	local f
	for f; do
		sed -i "${f}" \
		-e "s:^#include[[:space:]]*\"i18n.h\"://:" \
		|| die "sed failed to remove i18n_include"
	done

	einfo "Notice: removed i18n.h include in ${@}"
}

# @FUNCTION: vdr-plugin-2_print_enable_command
# @INTERNAL
# @USAGE:
# @DESCRIPTION:
# print out a hint how to enable this plugin
vdr-plugin-2_print_enable_command() {
	local p_name c=0 l=""
	for p_name in ${vdr_plugin_list}; do
		c=$(( c+1 ))
		l="$l ${p_name#vdr-}"
	done

	elog
	case $c in
	1)	elog "Installed plugin${l}" ;;
	*)	elog "Installed $c plugins:${l}" ;;
	esac
	elog "To activate a plugin execute this command:"
	elog "\teselect vdr-plugin enable <plugin_name> ..."
	elog
}

# @FUNCTION: has_vdr
# @INTERNAL
# @USAGE:
# @RETURN: 0=header file found   1=header file not found
# @DESCRIPTION:
# safety check if vdr header file exists
has_vdr() {
	[[ -f "${VDR_INCLUDE_DIR}"/config.h ]]
}

## exported functions

vdr-plugin-2_pkg_setup() {
	# missing ${chost}- tag
	tc-export CC CXX

	# -fPIC is needed for shared objects on some platforms (amd64 and others)
	append-flags -fPIC

	# Plugins need to be compiled with position independent code, otherwise linking
	# VDR against it will fail
	append-cxxflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

	# Where should the plugins live in the filesystem
	local PKG__CONFIG=$(tc-getPKG_CONFIG)
	VDR_PLUGIN_DIR=$(${PKG__CONFIG} --variable=libdir vdr)

	VDR_CHECKSUM_DIR="${VDR_PLUGIN_DIR%/plugins}/checksums"

	VDR_RC_DIR="/usr/share/vdr/rcscript"

	# Paths to includes
	VDR_INCLUDE_DIR="/usr/include/vdr"
	DVB_INCLUDE_DIR="/usr/include"

	TMP_LOCALE_DIR="${T}/tmp-locale"

	LOCDIR=$(${PKG__CONFIG} --variable=locdir vdr)

	if ! has_vdr; then
		# set to invalid values to detect abuses
		VDRVERSION="eclass_no_vdr_installed"
		APIVERSION="eclass_no_vdr_installed"

		if [[ "${GENTOO_VDR_CONDITIONAL:-no}" = "yes" ]] && ! use vdr; then
			einfo "VDR not found!"
		else
			# if vdr is required
			die "VDR not found!"
		fi
		return
	fi

	VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
	APIVERSION=$(${PKG__CONFIG} --variable=apiversion vdr)

	einfo "Compiling against"
	einfo "\tvdr-${VDRVERSION} [API version ${APIVERSION}]"

	if [[ -n "${VDR_LOCAL_PATCHES_DIR}" ]]; then
		eerror "Using VDR_LOCAL_PATCHES_DIR is deprecated!"
		eerror "Please move all your patches into"
		eerror "${EROOT%/}/etc/portage/patches/${CATEGORY}/${P}"
		eerror "and remove or unset the VDR_LOCAL_PATCHES_DIR variable."
		die
	fi
}

# @FUNCTION: vdr-plugin-2_src_util
# @USAGE: [ list of wanted eclass helper functions to call ]
# @DESCRIPTION:
# wrapper function to call other functions in this eclass
vdr-plugin-2_src_util() {
	while [ "$1" ]; do
		case "$1" in
		all)
			vdr-plugin-2_src_util unpack add_local_patch patchmakefile linguas_patch i18n
			;;
		prepare)
			vdr-plugin-2_src_util add_local_patch patchmakefile linguas_patch i18n
			;;
		unpack)
			unpacker_src_unpack
			;;
		add_local_patch)
			cd "${S}" || die "Could not change to plugin-source-directory (src_util)"
			eapply_user
			;;
		patchmakefile)
			cd "${S}" || die "Could not change to plugin-source-directory (src_util)"
			vdr_patchmakefile
			;;
		i18n)
			vdr_i18n
			;;
		linguas_patch)
			vdr_linguas_support
			;;
		esac

		shift
	done
}

vdr-plugin-2_src_unpack() {
	if [[ -z ${VDR_INCLUDE_DIR} ]]; then
		eerror "Wrong use of vdr-plugin-2.eclass."
		eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_unpack."
		echo
		eerror "Please report this at bugs.gentoo.org."
		die "vdr-plugin-2_src_unpack not called!"
	fi

	if [ -z "$1" ]; then
		vdr-plugin-2_src_util unpack
	else
		vdr-plugin-2_src_util $@
	fi
}

vdr-plugin-2_src_prepare() {
	if [[ -z ${VDR_INCLUDE_DIR} ]]; then
		eerror "Wrong use of vdr-plugin-2.eclass."
		eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_prepare."
		echo
		eerror "Please report this at bugs.gentoo.org."
		die "vdr-plugin-2_src_prepare not called!"
	fi

	[[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}"

	debug-print "$FUNCNAME: applying user patches"

	vdr-plugin-2_src_util prepare
}

vdr-plugin-2_src_compile() {
	[ -z "$1" ] && vdr-plugin-2_src_compile compile

	while [ "$1" ]; do
		case "$1" in
		compile)
			if [[ ! -f ${WORKDIR}/.vdr-plugin_makefile_patched ]]; then
				eerror "Wrong use of vdr-plugin-2.eclass."
				eerror "An ebuild for a vdr-plugin will not work without"
				eerror "calling vdr-plugin-2_src_compile to patch the Makefile."
				echo
				eerror "Please report this at bugs.gentoo.org."
				die "vdr-plugin-2_src_compile not called!"
			fi
			cd "${S}" || die "could not change to plugin source directory (src_compile)"

			emake all ${BUILD_PARAMS} \
				LOCALEDIR="${TMP_LOCALE_DIR}" \
				LOCDIR="${TMP_LOCALE_DIR}" \
				LIBDIR="${S}" \
				TMPDIR="${T}" \
				|| die "emake all failed"
			;;
		esac

		shift
	done
}

vdr-plugin-2_src_install() {
	if [[ -z ${VDR_INCLUDE_DIR} ]]; then
		eerror "Wrong use of vdr-plugin-2.eclass."
		eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_install."
		echo
		eerror "Please report this at bugs.gentoo.org."
		die "vdr-plugin-2_src_install not called!"
	fi

	cd "${WORKDIR}" || die "could not change to plugin workdir directory (src_install)"

	if [[ -n ${VDR_MAINTAINER_MODE} ]]; then
		local mname="${P}-Makefile"
		cp "${S}"/Makefile "${mname}.patched" \
			|| die "could not copy to Makefile.patched"
		cp Makefile.before "${mname}.before" \
			|| die "could not copy to Makefile.before"

		diff -u "${mname}.before" "${mname}.patched" > "${mname}.diff"
		[[ $? -ge 2 ]] && die "problem with diff"

		insinto "/usr/share/vdr/maintainer-data/makefile-changes"
		doins "${mname}.diff"

		insinto "/usr/share/vdr/maintainer-data/makefile-before"
		doins "${mname}.before"

		insinto "/usr/share/vdr/maintainer-data/makefile-patched"
		doins "${mname}.patched"
	fi

	cd "${S}" || die "could not change to plugin source directory (src_install)"

	local SOFILE_STRING=$(grep SOFILE Makefile)
	if [[ -n ${SOFILE_STRING} ]]; then
		emake install \
		${BUILD_PARAMS} \
		TMPDIR="${T}" \
		DESTDIR="${D%/}" \
		|| die "emake install (makefile target) failed"
	else
		einfo "Notice: Plugin use still the old Makefile handling"
		insinto "${VDR_PLUGIN_DIR}"
		doins libvdr-*.so.*
	fi

	if [[ -d ${TMP_LOCALE_DIR} ]]; then
		einfo "Installing locales"
		cd "${TMP_LOCALE_DIR}" || die "could not change to TMP_LOCALE_DIR"

		local linguas
		for linguas in ${LINGUAS[*]}; do
		insinto "${LOCDIR}"
		cp -r --parents ${linguas}* "${D%/}"/${LOCDIR} \
			|| die "could not copy linguas files"
		done
	fi

	cd "${D%/}/usr/$(get_libdir)/vdr/plugins" \
		|| die "could not change to \$D/usr/libdir/vdr/plugins"

	# create list of all created plugin libs
	vdr_plugin_list=""
	local p_name
	for p in libvdr-*.so.*; do
		p_name="${p%.so*}"
		p_name="${p_name#lib}"
		vdr_plugin_list="${vdr_plugin_list} ${p_name}"
	done

	cd "${S}" || die "could not change to plugin source directory (src_install)"

	vdr_create_header_checksum_file ${vdr_plugin_list}
	vdr_create_plugindb_file ${vdr_plugin_list}

	einstalldocs

	# if VDR_CONFD_FILE is empty and ${FILESDIR}/confd exists take it
	[[ -z ${VDR_CONFD_FILE} ]] && [[ -e ${FILESDIR}/confd ]] && VDR_CONFD_FILE=${FILESDIR}/confd

	if [[ -n ${VDR_CONFD_FILE} ]]; then
		newconfd "${VDR_CONFD_FILE}" vdr.${VDRPLUGIN}
	fi

	# if VDR_RCADDON_FILE is empty and ${FILESDIR}/rc-addon.sh exists take it
	[[ -z ${VDR_RCADDON_FILE} ]] && [[ -e ${FILESDIR}/rc-addon.sh ]] && VDR_RCADDON_FILE=${FILESDIR}/rc-addon.sh

	if [[ -n ${VDR_RCADDON_FILE} ]]; then
		insinto "${VDR_RC_DIR}"
		newins "${VDR_RCADDON_FILE}" plugin-${VDRPLUGIN}.sh
	fi
}

vdr-plugin-2_pkg_postinst() {
	vdr-plugin-2_print_enable_command

	if [[ -n "${VDR_CONFD_FILE}" ]]; then
		elog "Please have a look at the config-file"
		elog "\t/etc/conf.d/vdr.${VDRPLUGIN}"
		elog
	fi
}

vdr-plugin-2_pkg_postrm() {
:
}

vdr-plugin-2_pkg_config() {
:
}

fi

EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm pkg_config