summaryrefslogtreecommitdiff
blob: 013d7007bfdb25b63d07d2cb9c84b61970f26017 (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
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/teamviewer/teamviewer-8.0.20931.ebuild,v 1.1 2013/09/21 19:52:20 hasufell Exp $

EAPI=5

inherit eutils gnome2-utils systemd unpacker

# Major version
MV=${PV/\.*}
MY_PN=${PN}${MV}
DESCRIPTION="All-In-One Solution for Remote Access and Support over the Internet"
HOMEPAGE="http://www.teamviewer.com"
SRC_URI="http://www.teamviewer.com/download/version_${MV}x/teamviewer_linux.deb -> ${P}.deb"

LICENSE="TeamViewer !system-wine? ( LGPL-2.1 )"
SLOT=${MV}
KEYWORDS="~amd64 ~x86"
IUSE="system-wine"

RESTRICT="mirror"

RDEPEND="
	app-shells/bash
	x11-misc/xdg-utils
	!system-wine? (
		amd64? (
			>=sys-libs/zlib-1.2.8-r1[abi_x86_32]
			>=app-arch/bzip2-1.0.6-r6[abi_x86_32]
			>=media-libs/freetype-2.4.12[abi_x86_32]
			>=x11-libs/libICE-1.0.8-r1[abi_x86_32]
			>=x11-libs/libSM-1.2.2[abi_x86_32]
			>=x11-libs/libX11-1.6.2[abi_x86_32]
			>=x11-libs/libXau-1.0.8[abi_x86_32]
			>=x11-libs/libxcb-1.9.1[abi_x86_32]
			>=x11-libs/libXdamage-1.1.4-r1[abi_x86_32]
			>=x11-libs/libXdmcp-1.1.1-r1[abi_x86_32]
			>=x11-libs/libXext-1.3.2[abi_x86_32]
			>=x11-libs/libXfixes-5.0.1[abi_x86_32]
			>=x11-libs/libXi-1.7.2[abi_x86_32]
			>=x11-libs/libXrender-0.9.8[abi_x86_32]
			>=x11-libs/libXtst-1.2.2[abi_x86_32]
		)
		x86? (
			sys-libs/zlib
			x11-libs/libSM
			x11-libs/libX11
			x11-libs/libXau
			x11-libs/libXdamage
			x11-libs/libXext
			x11-libs/libXfixes
			x11-libs/libXtst
		)
	)
	system-wine? ( app-emulation/wine )"

QA_PREBUILT="opt/teamviewer${MV}/*"

S=${WORKDIR}/opt/teamviewer${MV}/tv_bin

make_winewrapper() {
	cat << EOF > "${T}/${MY_PN}"
#!/bin/sh
export WINEDLLPATH=/opt/${MY_PN}
exec wine "/opt/${MY_PN}/TeamViewer.exe" "\$@"
EOF
	chmod go+rx "${T}/${MY_PN}"
	exeinto /opt/bin
	doexe "${T}/${MY_PN}"
}

src_prepare() {
	epatch "${FILESDIR}"/${P}-gentoo.patch

	sed \
		-e "s/@TVV@/${MV}/g" \
		"${FILESDIR}"/${PN}d.init > "${T}"/${PN}d${MV} || die

	sed -i \
		-e "s#/opt/teamviewer9/tv_bin/teamviewerd#/opt/${MY_PN}/teamviewerd#" \
		script/${PN}d.service || die
}

src_install () {
	if use system-wine ; then
		make_winewrapper
		exeinto /opt/${MY_PN}
		doexe wine/drive_c/TeamViewer/*
	else
		# install scripts and .reg
		insinto /opt/${MY_PN}/script
		doins script/*.reg
		exeinto /opt/${MY_PN}/script
		doexe script/teamviewer{,_desktop} script/tvw_{aux,config,exec,extra,main,profile}

		# install internal wine
		insinto /opt/${MY_PN}
		doins -r wine
		dosym /opt/${MY_PN}/script/${PN} /opt/bin/${MY_PN}

		# fix permissions
		fperms 755 /opt/${MY_PN}/wine/bin/wine{,-preloader,server}
		fperms 755 /opt/${MY_PN}/wine/drive_c/TeamViewer/TeamViewer.exe
		find "${D}"/opt/${MY_PN} -type f -name "*.so*" -execdir chmod 755 '{}' \;
	fi

	# necessary symlinks
	dosym ./script/teamviewer /opt/${MY_PN}/TeamViewer
	dosym ./script/teamviewer_desktop /opt/${MY_PN}/TeamViewer_Desktop

	# install daemon binary
	exeinto /opt/${MY_PN}
	doexe ${PN}d

	# set up logdir
	keepdir /var/log/${MY_PN}
	dosym /var/log/${MY_PN} /opt/${MY_PN}/logfiles

	# set up config dir
	keepdir /etc/${MY_PN}
	dosym /etc/${MY_PN} /opt/${MY_PN}/config

	doinitd "${T}"/${PN}d${MV}
	systemd_dounit script/${PN}d.service

	newicon -s 48 desktop/${PN}.png ${MY_PN}.png
	dodoc ../doc/linux_FAQ_{EN,DE}.txt
	make_desktop_entry ${MY_PN} TeamViewer ${MY_PN}
}

pkg_preinst() {
	gnome2_icon_savelist
}

pkg_postinst() {
	gnome2_icon_cache_update

	if use system-wine ; then
		echo
		eerror "IMPORTANT NOTICE!"
		elog "Using ${PN} with system wine is not supported and experimental."
		elog "Do not report gentoo bugs while using this version."
		echo
	fi

	eerror "STARTUP NOTICE:"
	elog "You cannot start the daemon via \"teamviewer --daemon start\"."
	elog "Instead use the provided gentoo initscript:"
	elog "  /etc/init.d/${PN}d${MV} start"
	elog
	elog "Logs are written to \"/var/log/teamviewer9\""

}

pkg_postrm() {
	gnome2_icon_cache_update
}