summaryrefslogtreecommitdiff
blob: dfc8ef4f5e0bb6832ae960e88322bd7de073ecc0 (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
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CMAKE_IN_SOURCE_BUILD=1
inherit autotools cmake flag-o-matic java-pkg-opt-2 optfeature systemd xdg

XSERVER_VERSION="21.1.13"
XSERVER_PATCH_VERSION="21"

DESCRIPTION="Remote desktop viewer display system"
HOMEPAGE="https://tigervnc.org"
SRC_URI="server? ( ftp://ftp.freedesktop.org/pub/xorg/individual/xserver/xorg-server-${XSERVER_VERSION}.tar.xz )"

if [[ ${PV} == *9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/TigerVNC/tigervnc/"
else
	SRC_URI+=" https://github.com/TigerVNC/tigervnc/archive/v${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi

LICENSE="GPL-2"
SLOT="0"
IUSE="dri3 +drm gnutls java nls +opengl +server +viewer xinerama"
REQUIRED_USE="
	dri3? ( drm )
	java? ( viewer )
	opengl? ( server )
	|| ( server viewer )
"

# TODO: sys-libs/libselinux
COMMON_DEPEND="
	dev-libs/gmp:=
	dev-libs/nettle:=
	media-libs/libjpeg-turbo:=
	sys-libs/zlib:=
	x11-libs/libX11
	x11-libs/libXext
	x11-libs/libXrandr
	x11-libs/pixman
	gnutls? ( net-libs/gnutls:= )
	nls? ( virtual/libiconv )
	server? (
		dev-libs/openssl:0=
		sys-libs/pam
		x11-libs/libXau
		x11-libs/libXdamage
		x11-libs/libXdmcp
		x11-libs/libXfixes
		x11-libs/libXfont2
		x11-libs/libXtst
		x11-libs/pixman
		x11-apps/xauth
		x11-apps/xinit
		x11-apps/xkbcomp
		x11-apps/xsetroot
		x11-misc/xkeyboard-config
		opengl? ( media-libs/libglvnd[X] )
		!net-misc/turbovnc[server]
	)
	viewer? (
		media-video/ffmpeg:=
		x11-libs/fltk:1
		x11-libs/libXi
		x11-libs/libXrender
		!net-misc/turbovnc[viewer]
	)
"
RDEPEND="${COMMON_DEPEND}
	java? ( >=virtual/jre-1.8:* )
	server? ( dev-lang/perl )
"
DEPEND="${COMMON_DEPEND}
	java? ( >=virtual/jdk-1.8:* )
	drm? ( x11-libs/libdrm )
	server? (
		media-fonts/font-util
		x11-base/xorg-proto
		x11-libs/libxcvt
		x11-libs/libXi
		x11-libs/libxkbfile
		x11-libs/libXrender
		x11-libs/xtrans
		x11-misc/util-macros
		opengl? ( media-libs/mesa )
	)
"
BDEPEND="
	virtual/pkgconfig
	nls? ( sys-devel/gettext )
"

PATCHES=(
	# Restore Java viewer
	"${FILESDIR}"/${PN}-1.11.0-install-java-viewer.patch
	"${FILESDIR}"/${PN}-1.14.0-xsession-path.patch
	"${FILESDIR}"/${PN}-1.12.80-disable-server-and-pam.patch
)

src_unpack() {
	if [[ ${PV} == *9999 ]]; then
		git-r3_src_unpack
		use server && unpack xorg-server-${XSERVER_VERSION}.tar.xz
	else
		default
	fi
}

src_prepare() {
	if use server; then
		cp -r "${WORKDIR}"/xorg-server-${XSERVER_VERSION}/. unix/xserver || die
	fi

	cmake_src_prepare

	if use server; then
		cd unix/xserver || die
		eapply ../xserver${XSERVER_PATCH_VERSION}.patch
		eautoreconf
		sed -i '/strcmp.*-fakescreenfps/,/^        \}/d' os/utils.c || die

		if use drm; then
			cd "${WORKDIR}" && \
			sed -i 's:\(drm_fourcc.h\):libdrm/\1:' $(grep drm_fourcc.h -rl .) || die
		fi
	fi
}

src_configure() {
	if use arm || use hppa; then
		append-flags "-fPIC"
	fi

	local mycmakeargs=(
		-DENABLE_GNUTLS=$(usex gnutls)
		-DENABLE_NLS=$(usex nls)
		-DBUILD_JAVA=$(usex java)
		-DBUILD_SERVER=$(usex server)
		-DBUILD_VIEWER=$(usex viewer)
	)

	cmake_src_configure

	if use server; then
		cd unix/xserver || die
		econf \
			$(use_enable opengl glx) \
			$(use_enable drm libdrm) \
			--disable-config-hal \
			--disable-config-udev \
			--disable-devel-docs \
			--disable-dri \
			$(use_enable dri3) \
			--disable-glamor \
			--disable-kdrive \
			--disable-libunwind \
			--disable-linux-acpi \
			--disable-record \
			--disable-selective-werror \
			--disable-static \
			--disable-unit-tests \
			--disable-xephyr \
			$(use_enable xinerama) \
			--disable-xnest \
			--disable-xorg \
			--disable-xvfb \
			--disable-xwin \
			--enable-dri2 \
			--with-pic \
			--without-dtrace \
			--with-sha1=libcrypto
	fi
}

src_compile() {
	cmake_src_compile

	if use server; then
		# deps of the vnc module and the module itself
		local d subdirs=(
			fb xfixes Xext dbe $(usex opengl glx "") $(usev dri3) randr render
			damageext miext Xi xkb composite dix mi os present hw/vnc
		)
		for d in "${subdirs[@]}"; do
			emake -C unix/xserver/"${d}"
		done
	fi
}

src_install() {
	cmake_src_install

	if use server; then
		emake -C unix/xserver/hw/vnc DESTDIR="${D}" install
		rm -v "${ED}"/usr/$(get_libdir)/xorg/modules/extensions/libvnc.la || die

		newconfd "${FILESDIR}"/${PN}-1.14.0.confd ${PN}
		newinitd "${FILESDIR}"/${PN}-1.14.0.initd ${PN}

		systemd_douserunit unix/vncserver/vncserver@.service

		# comment out pam_selinux.so, the server does not start if missing
		# part of bug #746227
		sed -i -e '/pam_selinux/s/^/#/' "${ED}"/etc/pam.d/tigervnc || die

		# install vncserver to /usr/bin too, see bug #836620
		dosym -r /usr/libexec/vncserver /usr/bin/vncserver
	fi
}

pkg_postinst() {
	xdg_pkg_postinst

	use server && [[ -n ${REPLACING_VERSIONS} ]] && ver_test "${REPLACING_VERSIONS}" -lt 1.13.1-r3 && {
		elog 'OpenRC users: please migrate to one service per display as documented here:'
		elog 'https://wiki.gentoo.org/wiki/TigerVNC#Migrating_from_1.13.1-r2_or_lower:'
		elog
	}

	use server && {
		elog 'PLEASE NOTE:'
		elog '	The default config directory is now ${XDG_CONFIG_HOME}/tigervnc or'
		elog '	~/.config/tigervnc instead of ~/.vnc'
		elog
	}

	local OPTIONAL_DM="gnome-base/gdm x11-misc/lightdm x11-misc/sddm x11-misc/slim"
	use server && \
		optfeature "keeping track of the xorg-server module" net-misc/tigervnc-xorg-module && \
		optfeature_header "Install any additional display manager package:" && \
		optfeature "proper session support" ${OPTIONAL_DM}
}