1SUMMARY = "An open source remote desktop protocol(rdp) server."
2
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://COPYING;md5=72cfbe4e7bd33a0a1de9630c91195c21 \
5"
6
7inherit features_check autotools pkgconfig useradd systemd
8
9DEPENDS = "openssl virtual/libx11 libxfixes libxrandr libpam nasm-native imlib2 pixman libsm"
10
11REQUIRED_DISTRO_FEATURES = "x11 pam"
12
13SRC_URI = "https://github.com/neutrinolabs/${BPN}/releases/download/v${PV}/${BPN}-${PV}.tar.gz \
14           file://xrdp.sysconfig \
15           file://0001-Added-req_distinguished_name-in-etc-xrdp-openssl.con.patch \
16           file://0001-Fix-the-compile-error.patch \
17           file://0001-arch-Define-NO_NEED_ALIGN-on-ppc64.patch \
18           file://0001-mark-count-with-unused-attribute.patch \
19           "
20
21SRC_URI[sha256sum] = "94017d30e475c6d7a24f651e16791551862ae46f82d8de62385e63393f5f93d0"
22
23CFLAGS += " -Wno-deprecated-declarations"
24
25PACKAGECONFIG ??= ""
26PACKAGECONFIG[fuse] = " --enable-fuse, --disable-fuse, fuse"
27
28USERADD_PACKAGES = "${PN}"
29GROUPADD_PARAM:${PN} = "--system xrdp"
30USERADD_PARAM:${PN}  = "--system --home /var/run/xrdp -g xrdp \
31                        --no-create-home --shell /bin/false xrdp"
32
33FILES:${PN} += "${datadir}/dbus-1/services/*.service \
34                ${datadir}/dbus-1/accessibility-services/*.service "
35
36FILES:${PN}-dev += "${libdir}/xrdp/libcommon.so \
37                    ${libdir}/xrdp/libxrdp.so \
38                    ${libdir}/xrdp/libscp.so \
39                    ${libdir}/xrdp/libxrdpapi.so "
40
41EXTRA_OECONF = "--enable-pam-config=suse --enable-fuse \
42                --enable-pixman --enable-painter --enable-vsock \
43                --enable-ipv6 --with-imlib2 --with-socketdir=${localstatedir}/run/${PN}"
44
45do_configure:prepend() {
46    cd ${S}
47    ./bootstrap
48    cd -
49}
50
51do_compile:prepend() {
52    sed -i 's/(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am/(MAKE) $(AM_MAKEFLAGS) install-exec-am/g' ${S}/keygen/Makefile.in
53    echo "" > ${B}/xrdp_configure_options.h
54}
55
56do_install:append() {
57
58	# deal with systemd unit files
59	install -d ${D}${systemd_unitdir}/system
60	install -m 0644 ${S}/instfiles/xrdp.service.in ${D}${systemd_unitdir}/system/xrdp.service
61	install -m 0644 ${S}/instfiles/xrdp-sesman.service.in ${D}${systemd_unitdir}/system/xrdp-sesman.service
62	sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/xrdp.service ${D}${systemd_unitdir}/system/xrdp-sesman.service
63	sed -i -e 's,@sysconfdir@,${sysconfdir},g' ${D}${systemd_unitdir}/system/xrdp.service ${D}${systemd_unitdir}/system/xrdp-sesman.service
64	sed -i -e 's,@sbindir@,${sbindir},g' ${D}${systemd_unitdir}/system/xrdp.service ${D}${systemd_unitdir}/system/xrdp-sesman.service
65
66	install -d ${D}${sysconfdir}/sysconfig/xrdp
67	install -m 0644 ${S}/instfiles/*.ini ${D}${sysconfdir}/xrdp/
68	install -m 0644 ${S}/keygen/openssl.conf ${D}${sysconfdir}/xrdp/
69	install -m 0644 ${WORKDIR}/xrdp.sysconfig ${D}${sysconfdir}/sysconfig/xrdp/
70	chown xrdp:xrdp ${D}${sysconfdir}/xrdp
71}
72
73SYSTEMD_SERVICE:${PN} = "xrdp.service xrdp-sesman.service"
74
75pkg_postinst:${PN}() {
76	if test -z "$D"
77	then
78		if test -x ${bindir}/xrdp-keygen
79		then
80			${bindir}/xrdp-keygen xrdp ${sysconfdir}/xrdp/rsakeys.ini >/dev/null
81                fi
82		if test ! -s ${sysconfdir}/xrdp/cert.pem
83		then
84			openssl req -x509 -newkey rsa:2048 -sha256 -nodes -days 3652 \
85			-keyout ${sysconfdir}/xrdp/key.pem \
86			-out ${sysconfdir}/xrdp/cert.pem \
87			-config ${sysconfdir}/xrdp/openssl.conf >/dev/null 2>&1
88			chmod 400 ${sysconfdir}/xrdp/key.pem
89		fi
90        fi
91}
92