summaryrefslogtreecommitdiff
blob: 21cd694f0a180bd596cde81ec4d5a0010f265abc (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit flag-o-matic eutils

DESCRIPTION="A X11/RDP/VNC proxy server especially well suited to low bandwidth links such as wireless, WANS, and worse"
HOMEPAGE="http://www.2x.com/terminalserver/"
SRC_URI="http://code.2x.com/release/linuxterminalserver/src/linuxterminalserver-1.5.0-r21-src.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="rdesktop vnc"

DEPEND="
	dev-libs/glib
	dev-libs/openssl
	dev-perl/BSD-Resource
	dev-perl/GDGraph
	dev-perl/Passwd-Linux
	dev-perl/Unix-Syslog
	dev-perl/DBI
	dev-perl/DBD-SQLite
	dev-perl/Error
	media-libs/jpeg
	media-libs/libpng
	sys-libs/zlib
	x11-misc/gccmakedep
	net-misc/nxclient-2xterminalserver"
RDEPEND="${DEPEND}"

S="${WORKDIR}"

pkg_preinst() {
	enewuser nx -1 -1 /usr/NX/home/nx
}

src_unpack() {
	unpack ${A}

	cd ${S}
	epatch ${FILESDIR}/1.5.0/nx-x11-1.5.0-amd64.patch || die
	epatch ${FILESDIR}/1.5.0/nx-x11-1.5.0-plastik-render-fix.patch || die
	epatch ${FILESDIR}/1.5.0/nx-x11-1.5.0-tmp-exec.patch || die
	epatch ${FILESDIR}/1.5.0/nx-x11-1.5.0-xorg7-font-fix.patch || die
	epatch ${FILESDIR}/1.5.0/nx-x11-1.5.0-windows-linux-resume.patch || die
	epatch ${FILESDIR}/1.5.0/${P}-insitu.patch || die
	epatch ${FILESDIR}/1.5.0/${P}-external-nxcomp.patch || die
	epatch ${FILESDIR}/1.5.0/${P}-setup.patch || die
	sed -i 's/-Wnested-externs/-Wnested-externs -fPIC/' \
		common/nxcompext/Makefile.in || die "sed failed"

	# Set correct product name (until proper tarballs are available)
	einfo "Setting correct product name (this will take some time)"
	find . -type f -exec sed -i "s/@PRODUCT_NAME@/2X TerminalServer/g" {} \;
}

src_compile() {
	cd ${S}/common/nxcompext
	append-ldflags "-L/usr/NX/lib"
	econf || die
	emake || die

	cd ${S}/common/nx-X11
	emake World || die

	if use rdesktop; then
		cd ${S}/client/nxdesktop
		CC=(tc-getCC) ./configure || die
		emake || die
	fi

	if use vnc; then
		cd ${S}/server/nxviewer
		xmkmf -a || die
		emake World || die
	fi

	cd ${S}/server/nxspool/source
	econf --without-ldap --without-krb5 || die
	# We can't use emake here - it doesn't trigger the right target
	# for some reason
	make || die

	cd ${S}/server/nxsensor
	emake glib12=1 || die

	cd ${S}/server/nxuexec
	emake || die

	cd ${S}/server/nxnode/src
	./configure || die
	make setversion
	make nxnode.pl nxserver.pl || die
	perl MakeConfigFile.pl DEBIAN > node-gentoo.cfg.sample
}

src_install() {
	NODE_SRC=${S}/server/nxnode/src

	# Main binaries
	into /usr/NX
	dobin ${S}/common/nx-X11/programs/Xserver/nxagent
	dobin ${S}/server/nxsensor/nxsensor
	dobin ${S}/server/nxnode/setup/nxsetup
	newbin ${S}/server/nxspool/source/bin/smbspool nxspool
	dobin ${S}/server/nxuexec/nxuexec

	if use rdesktop; then
		dobin ${S}/client/nxdesktop/nxdesktop
	fi
	if use vnc; then
		dobin ${S}/server/nxviewer/nxviewer/nxviewer
		dobin ${S}/server/nxviewer/nxpasswd/nxpasswd
	fi

	# Libraries
	dodir /usr/NX/lib
	cp -P ${S}/common/nxcompext/libXcompext.so* \
		${S}/common/nx-X11/lib/X11/libX11.so* ${D}/usr/NX/lib || die
	# And helper scripts
	exeinto /usr/NX/scripts
	newexe ${S}/server/nxnode/bin/nxnodeenv.sh nxenv.sh
	newexe ${S}/server/nxnode/bin/nxnodeenv.csh nxenv.csh
	exeinto /usr/NX/scripts/restricted
	doexe ${S}/server/nxnode/bin/nxaddinitd.sh
	doexe ${S}/server/nxnode/scripts/nxinit.sh
	newexe ${S}/server/nxnode/bin/nxprinter.sh-LINUX nxprinter.sh
	doexe ${S}/server/nxnode/bin/nxsessreg.sh
	doexe ${S}/server/nxnode/bin/nxuseradd.sh

	# The server itself (and wrappers and perl modules)
	dobin ${NODE_SRC}/nxnode.pl
	dobin ${NODE_SRC}/nxserver.pl
	make_wrapper nxnode "perl -I/usr/NX/lib/perl /usr/NX/bin/nxnode.pl" /usr/NX/bin /usr/NX/lib /usr/NX/bin
	make_wrapper nxserver "perl -I/usr/NX/lib/perl /usr/NX/bin/nxserver.pl" /usr/NX/bin /usr/NX/lib /usr/NX/bin

	dodir /usr/NX/lib/perl
	cp -RH ${NODE_SRC}/*.pm ${NODE_SRC}/Config ${NODE_SRC}/Exception \
		${NODE_SRC}/NXShellDialogs ${NODE_SRC}/handlers ${NODE_SRC}/nxstat \
		${D}/usr/NX/lib/perl/ || die

	# etc, var, home, ...
	dodir /usr/NX/etc/keys
	for x in passwords users administrators; do
		cp ${S}/server/nxnode/etc/${x} ${D}/usr/NX/etc/${x}.db.sample
	done
	cp ${NODE_SRC}/node-gentoo.cfg.sample ${D}/usr/NX/etc/ || die

	cp -R ${S}/server/nxnode/share ${D}/usr/NX || die
	cp -R ${S}/server/nxnode/home ${D}/usr/NX || die
	keepdir /usr/NX/var/log
	keepdir /usr/NX/var/run
	keepdir /usr/NX/var/db/closed
	keepdir /usr/NX/var/db/failed
	keepdir /usr/NX/var/db/nxstat
	keepdir /usr/NX/var/db/running
}

pkg_postinst() {
	usermod -s /usr/NX/bin/nxserver nx || die "Unable to set login shell of nx user!!"
	usermod -d /usr/NX/home/nx nx || die "Unable to set home directory of nx user!!"
	# Workaround fonts link
	if has_version '>=x11-base/xorg-x11-7.0' && ! [ -e /usr/lib/X11/fonts ];
	then
		ln -s /usr/share/fonts /usr/lib/X11/fonts
	fi

	# only run install when no configuration file is found
	if [ -f /usr/NX/etc/node.cfg ]; then
		einfo "Running 2X update script"
		${ROOT}/usr/NX/bin/nxsetup --update
	else
		einfo "Running 2X setup script"
		${ROOT}/usr/NX/bin/nxsetup --install
	fi
}