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