Use https by default
[gentoo.git] / media-video / vdr / vdr-2.0.6-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit eutils flag-o-matic multilib toolchain-funcs
8
9 # Switches supported by extensions-patch
10 EXT_PATCH_FLAGS="alternatechannel ddepgentry dvlvidprefer graphtft
11         jumpplay jumpingseconds mainmenuhooks menuorg naludump permashift permashift_v1
12         pinplugin rotor ttxtsubs vasarajanauloja wareagleicon yaepg"
13
14 # names of the use-flags
15 EXT_PATCH_FLAGS_RENAMED=""
16
17 # names ext-patch uses internally, here only used for maintainer checks
18 EXT_PATCH_FLAGS_RENAMED_EXT_NAME=""
19
20 IUSE="bidi debug html vanilla ${EXT_PATCH_FLAGS} ${EXT_PATCH_FLAGS_RENAMED}"
21
22 MY_PV="${PV%_p*}"
23 MY_P="${PN}-${MY_PV}"
24 S="${WORKDIR}/${MY_P}"
25
26 EXT_P="extpng-${P}-gentoo-edition-v6"
27
28 DESCRIPTION="Video Disk Recorder - turns a pc into a powerful set top box for DVB"
29 HOMEPAGE="http://www.tvdr.de/"
30 SRC_URI="ftp://ftp.tvdr.de/vdr/${MY_P}.tar.bz2
31         https://dev.gentoo.org/~hd_brummy/distfiles/${EXT_P}.patch.bz2"
32
33 KEYWORDS="amd64 ~arm ~ppc x86"
34 SLOT="0"
35 LICENSE="GPL-2"
36
37 REQUIRED_USE="
38         permashift? ( !permashift_v1 )
39         permashift_v1? ( !permashift )"
40
41 COMMON_DEPEND="virtual/jpeg:*
42         sys-libs/libcap
43         >=media-libs/fontconfig-2.4.2
44         >=media-libs/freetype-2"
45
46 DEPEND="${COMMON_DEPEND}
47         >=virtual/linuxtv-dvb-headers-5.3
48         sys-devel/gettext"
49
50 RDEPEND="${COMMON_DEPEND}
51         dev-lang/perl
52         >=media-tv/gentoo-vdr-scripts-2.5_rc1
53         media-fonts/corefonts
54         bidi? ( dev-libs/fribidi )"
55
56 CONF_DIR=/etc/vdr
57 CAP_FILE=${S}/capabilities.sh
58 CAPS="# Capabilities of the vdr-executable for use by startscript etc."
59
60 pkg_setup() {
61         use debug && append-flags -g
62
63         PLUGIN_LIBDIR="/usr/$(get_libdir)/vdr/plugins"
64
65         tc-export CC CXX AR
66 }
67
68 add_cap() {
69         local arg
70         for arg; do
71                 CAPS="${CAPS}\n${arg}=1"
72         done
73 }
74
75 enable_patch() {
76         local arg ARG_UPPER
77         for arg; do
78                 ARG_UPPER=$(echo $arg|tr '[:lower:]' '[:upper:]')
79                 echo "${ARG_UPPER} = 1" >> Make.config
80
81                 # codesnippet to bring the extpng defines into the vdr.pc CXXFLAGS CFLAGS
82                 echo "-DUSE_${ARG_UPPER}" >> "${T}"/defines.tmp
83                 cat "${T}"/defines.tmp | tr \\\012 ' '  > "${T}"/defines.IUSE
84                 export DEFINES_IUSE=$( cat ${T}/defines.IUSE )
85         done
86 }
87
88 extensions_add_make_conf()
89 {
90         # copy all ifdef for extensions-patch to Make.config
91         sed -e '1,/need to touch the following:/d' \
92                 -e '/need to touch the following/,/^$/d' \
93                 Make.config.template >> Make.config
94 }
95
96 extensions_all_defines() {
97         # extract all possible settings for extensions-patch
98         sed -e '/^#\?[A-Z].*= 1/!d' -e 's/^#\?//' -e 's/ .*//' \
99                 Make.config.template \
100                 | sort \
101                 | tr '[:upper:]' '[:lower:]'
102 }
103
104 lang_po() {
105         LING_PO=$( ls ${S}/po | sed -e "s:.po::g" | cut -d_ -f1 | tr \\\012 ' ' )
106 }
107
108 src_prepare() {
109         # apply maintainace-patches
110         ebegin "Changing paths for gentoo"
111
112         local DVBDIR=/usr/include
113         local i
114         for i in ${DVB_HEADER_PATH} /usr/include/v4l-dvb-hg /usr/include; do
115                 [[ -d ${i} ]] || continue
116                 if [[ -f ${i}/linux/dvb/dmx.h ]]; then
117                         einfo "Found DVB header files in ${i}"
118                         DVBDIR=${i}
119                         break
120                 fi
121         done
122
123         # checking for s2api headers
124         local api_version
125         api_version=$(awk -F' ' '/define DVB_API_VERSION / {print $3}' "${DVBDIR}"/linux/dvb/version.h)
126         api_version=${api_version}*$(awk -F' ' '/define DVB_API_VERSION_MINOR / {print $3}' "${DVBDIR}"/linux/dvb/version.h)
127
128         if [[ ${api_version:-0} -lt 5*3 ]]; then
129                 eerror "DVB header files do not contain s2api support or too old for ${P}"
130                 eerror "You cannot compile VDR against old dvb-header"
131                 die "DVB headers too old"
132         fi
133
134         cat > Make.config <<-EOT
135                 #
136                 # Generated by ebuild ${PF}
137                 #
138                 PREFIX                  = /usr
139                 DVBDIR                  = ${DVBDIR}
140                 PLUGINLIBDIR    = ${PLUGIN_LIBDIR}
141                 CONFDIR                 = ${CONF_DIR}
142                 VIDEODIR                = /var/vdr/video
143                 LOCDIR                  = \$(PREFIX)/share/locale
144                 INCDIR                  = \$(PREFIX)/include
145
146                 DEFINES                 += -DCONFDIR=\"\$(CONFDIR)\"
147                 INCLUDES                += -I\$(DVBDIR)
148
149                 # >=vdr-1.7.36-r1; parameter only used for compiletime on vdr
150                 # PLUGINLIBDIR (plugin Makefile old) = LIBDIR (plugin Makefile new)
151                 LIBDIR                  = ${PLUGIN_LIBDIR}
152                 PCDIR                   = /usr/$(get_libdir)/pkgconfig
153         EOT
154         eend 0
155
156         # support languages, written from right to left
157         BUILD_PARAMS+=" BIDI=$(usex bidi 1 0)"
158
159         epatch "${FILESDIR}/${PN}-2.0.6_gentoo.patch"
160
161         if ! use vanilla; then
162
163                 # Now apply extensions patch
164                 epatch "${WORKDIR}/${EXT_P}.patch"
165
166                 # This allows us to start even if some plugin does not exist
167                 # or is not loadable.
168                 enable_patch PLUGINMISSING
169                 enable_patch CHANNELBIND
170
171                 if [[ -n ${VDR_MAINTAINER_MODE} ]]; then
172                         einfo "Doing maintainer checks:"
173
174                         # we do not support these patches
175                         # (or have them already hard enabled)
176                         local IGNORE_PATCHES="pluginmissing  channelbind"
177
178                         extensions_all_defines > "${T}"/new.IUSE
179                         echo $EXT_PATCH_FLAGS $EXT_PATCH_FLAGS_RENAMED_EXT_NAME \
180                                         $IGNORE_PATCHES | \
181                                 tr ' ' '\n' |sort > "${T}"/old.IUSE
182                         local DIFFS=$(diff -u "${T}"/old.IUSE "${T}"/new.IUSE|grep '^[+-][^+-]')
183                         if [[ -z ${DIFFS} ]]; then
184                                 einfo "EXT_PATCH_FLAGS is up to date."
185                         else
186                                 ewarn "IUSE differences!"
187                                 local diff
188                                 for diff in $DIFFS; do
189                                         ewarn "$diff"
190                                 done
191                         fi
192                 fi
193
194                 ebegin "Enabling selected patches"
195                 local flag
196                 for flag in $EXT_PATCH_FLAGS; do
197                         use $flag && enable_patch ${flag}
198                 done
199
200                 eend 0
201
202                 extensions_add_make_conf
203
204                 # add defined use-flags compile options to vdr.pc
205                 sed -e "s:\$(CDEFINES) \$(CINCLUDES) \$(HDRDIR):\$(CDEFINES) \$(CINCLUDES) \$(HDRDIR) \$(DEFINES_IUSE):" \
206                         -i Makefile
207
208                 ebegin "Make depend"
209                 emake .dependencies >/dev/null
210                 eend $? "make depend failed"
211         fi
212
213         epatch_user
214
215         add_cap CAP_UTF8
216
217         add_cap CAP_IRCTRL_RUNTIME_PARAM \
218                         CAP_VFAT_RUNTIME_PARAM \
219                         CAP_CHUID \
220                         CAP_SHUTDOWN_AUTO_RETRY
221
222         echo -e ${CAPS} > "${CAP_FILE}"
223
224         # LINGUAS support
225         einfo "\n \t VDR supports the LINGUAS values"
226
227         lang_po
228
229         einfo "\t Please set one of this values in your sytem make.conf"
230         einfo "\t LINGUAS=\"${LING_PO}\"\n"
231
232         if [[ -z ${LINGUAS} ]]; then
233                 einfo "\n \t No values in LINGUAS="
234                 einfo "\t You will get only english text on OSD \n"
235         fi
236
237         strip-linguas ${LING_PO} en
238 }
239
240 src_install() {
241 #       # trick makefile not to create a videodir by supplying it with an existing
242 #       # directory
243         emake \
244         VIDEODIR="/" \
245         DESTDIR="${D}" install || die "emake install failed"
246
247         keepdir "${PLUGIN_LIBDIR}"
248
249         keepdir "${CONF_DIR}"/plugins
250         keepdir "${CONF_DIR}"/themes
251
252         if use html; then
253                 dohtml *.html
254         fi
255
256         dodoc MANUAL INSTALL README* HISTORY CONTRIBUTORS
257
258         insinto /usr/share/vdr
259         doins "${CAP_FILE}"
260
261         if use alternatechannel; then
262                 insinto /etc/vdr
263                 doins "${FILESDIR}"/channel_alternative.conf
264         fi
265
266         chown -R vdr:vdr "${D}/${CONF_DIR}"
267 }
268
269 pkg_postinst() {
270         elog "It is a good idea to run vdrplugin-rebuild now."
271
272         elog "To get nice symbols in OSD we recommend to install"
273         elog "\t1. emerge media-fonts/vdrsymbols-ttf"
274         elog "\t2. select font VDRSymbolsSans in Setup"
275         elog ""
276         elog "To get an idea how to proceed now, have a look at our vdr-guide:"
277         elog "\thttps://wiki.gentoo.org/wiki/VDR"
278 }