summaryrefslogtreecommitdiff
path: root/gentoo/vdr-vdrmanager-9999.ebuild
blob: 632028f3bf43aa3717555d5fbcfe2f7066e9b7b1 (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
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-plugins/vdr-vdrmanager/vdr-vdrmanager-0.10.ebuild,v 1.1 2013/12/27 17:18:28 hd_brummy Exp $

EAPI="5"

inherit vdr-plugin-2 ssl-cert git-2

EGIT_REPO_URI="git://projects.vdr-developer.org/vdr-manager.git"

DESCRIPTION="VDR Plugin: allows remote programming VDR using VDR-Manager running on Android devices"
HOMEPAGE="http://projects.vdr-developer.org/projects/vdr-manager/wiki"

KEYWORDS="~x86 ~amd64"
SLOT="0"
LICENSE="GPL-2"

IUSE="-stream +ssl +zlib -gzip"

DEPEND=">=media-video/vdr-2
        ssl? ( dev-libs/openssl )
        zlib? ( sys-libs/zlib )"
RDEPEND="stream? ( media-plugins/vdr-streamdev[server] )
        gzip? ( app-arch/gzip )
        $DEPEND"

VDRMANAGER_SSL_KEY_DIR="/etc/vdr/plugins/vdrmanager"
VDRMANAGER_SSL_KEY_FILE="${VDRMANAGER_SSL_KEY_DIR}/vdrmanager"

S="${WORKDIR}/${P}"

make_vdrmanager_cert() {
    SSL_COUNTRY="${SSL_COUNTRY:-}"
    SSL_STATE="${SSL_STATE:-Unknown}"
    SSL_LOCALITY="${VDRMANAGER_SSL_LOCALITY:-Unkown}"
    SSL_ORGANIZATION="${VDRMNAGER_SSL_ORGANIZATION:-VDR-Manager Plugin}"
    SSL_UNIT="${VDRMANAGER_SSL_UNIT:-VDR Server}"
    SSL_COMMONNAME="${VDRMANAGER_SSL_COMMONNAME:-`hostname -f`}"
    SSL_EMAIL="${VDRMANAGER_SSL_EMAIL:-Unknown}"
	SSL_BITS="${VDRMANAGER_SSL_BITS:-1024}"
	SSL_DAYS="${VDRMANAGER_SSL_DAYS:-720}"

	rm -f ${ROOT}${VDRMANAGER_SSL_KEY_FILE}.*

	install_cert ${VDRMANAGER_SSL_KEY_FILE}

	rm -f ${ROOT}${VDRMANAGER_SSL_KEY_FILE}.{crt,csr,key}
	chown vdr:vdr "${ROOT}${VDRMANAGER_SSL_KEY_FILE}.pem"
	chmod 600 "${ROOT}${VDRMANAGER_SSL_KEY_FILE}.pem"
}

src_unpack() {
	git-2_src_unpack
	S=${WORKDIR}/${P}/${PN}
}

src_prepare() {

    use ssl  || BUILD_PARAMS="$BUILD_PARAMS VDRMANAGER_USE_SSL=0"
    use gzip || BUILD_PARAMS="$BUILD_PARAMS VDRMANAGER_USE_GZIP=0"
    use zlib || BUILD_PARAMS="$BUILD_PARAMS VDRMANAGER_USE_ZLIB=0"

    vdr-plugin-2_src_prepare
}

pkg_postinst() {
	vdr-plugin-2_pkg_postinst

	einfo "Add a password to /etc/conf.d/vdr.vdrmanager"

	if use ssl; then
		if path_exists -a "${ROOT}${VDRMANAGER_SSL_KEY_FILE}.pem"; then
			einfo "found an existing SSL cert, to create a new SSL cert, run:\n"
			einfo "emerge --config ${PN}"
		else
			einfo "No SSL cert found, creating a default one now"
			make_vdrmanager_cert
		fi
		einfo
	fi

	if use gzip; then
		einfo 'The plugin was installed with USE flag "gzip" set.'
		einfo 'You must install app-arch/gzip to use the gzip'
		einfo 'compression method.'
	fi
}

pkg_config() {
	make_vdrmanager_cert
}