File x2goserver.spec of Package x2goserver
#
# spec file for package x2goserver
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: x2goserver
Version: 4.0.1.22
Release: 0
Summary: x2go tools for session administration
License: GPL-2.0+
Group: Productivity/Networking/Remote Desktop
Url: http://x2go.org/
#DL-URL: http://code.x2go.org/releases/source/x2goserver/
#Git-Clone: git://code.x2go.org/x2goserver
#Git-Web: http://code.x2go.org/gitweb?p=x2goserver.git;a=summary
Source: http://code.x2go.org/releases/source/%name/%name-%version.tar.gz
Source2: http://code.x2go.org/releases/source/%name/%name-%version.tar.gz.asc
Source3: %name.keyring
Source4: %name-rpmlintrc
Source5: x2gocleansessions.service
Patch2: x2goserver-corrected-numlock-basb.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: fdupes
BuildRequires: man2html
BuildRequires: shadow
BuildRequires: systemd-rpm-macros
BuildRequires: perl(Config::Simple)
BuildRequires: perl(DBD::SQLite)
BuildRequires: perl(DBI) >= 1.617
PreReq: permissions
Requires(pre): shadow
Requires(post): perl(Config::Simple)
Requires(post): perl(DBD::SQLite)
Requires(post): perl(DBI) >= 1.617
Requires: coreutils
Requires: findutils
Requires: fonts-config
Requires: fuse
Requires: gawk
Requires: grep
Requires: iproute2
Requires: lsof
Requires: makepasswd
Requires: numlockx
Requires: perl-base
Requires: psmisc
Requires: sed
Requires: setxkbmap
Requires: sshfs
Requires: util-linux
Requires: util-linux
Requires: x2goagent
Requires: xkeyboard-config
Requires: xmessage
Requires: xorg-x11-xauth
Requires: xwininfo
Requires: perl(Capture::Tiny)
Requires: perl(Config::Simple)
Requires: perl(Cwd)
Requires: perl(DBD::Pg)
Requires: perl(DBD::SQLite) >= 1.27
Requires: perl(DBI)
Requires: perl(File::BaseDir)
Requires: perl(File::Basename)
Requires: perl(File::Copy)
Requires: perl(File::Path)
Requires: perl(File::ReadBackwards)
Requires: perl(File::Which)
Requires: perl(Getopt::Long)
Requires: perl(POSIX)
Requires: perl(Sys::Hostname)
Requires: perl(Sys::Syslog) >= 0.14
# bindir:
# x2golistdesktops -> ls, grep, xwininfo
# x2gomountdirs -> ln, mount, sshfs
# x2goprint -> su
# x2goterminate -> kill
# x2goresume-session -> awk, kill, cat
# x2goruncommand -> basename, kill
# x2goruncommand -> canoneof(firefox,iceweasel,abrowser,konqueror,galeon,chromium-browser)
# x2goruncommand -> canoneof(thunderbird,icedove,kmail,evolution)
# x2goruncommand -> canoneof(loffice,ooffice)
# x2goruncommand -> canoneof(konsole,gnome-terminal,lxterminal,rxvt,xterm)
# x2goserver-run-extensions -> find
# x2gosetkeyboard -> cat, cut, egrep, head, tail, setxkbmap
# x2goshowblocks -> lsof, grep, su
# x2gostartagent -> awk, date, mcookie, perl, sed, xauth, xwininfo, x2goagent
# x2gosuspendsession -> awk, killall
# x2goterminate-session -> awk, kill, sleep, rm
# x2goumount-session -> fusermount, canoneof(kdialog,zenity)
# x2goversion -> cat, egrep, head, cut, ls
# sbindir:
# x2gocleansessions -> tail, hostname, su
# x2godbadmin -> makepasswd
# x2golistsessions_root -> tail, su
# libexecdir/x2go:
# nothing new.
# - sudo is not used
# No need for DBD::Pg here because only the SQLite DB is created in %%post
%if "%{?sles_version}" == "11"
# libexecdir is set to %%_exec_prefix/%%_lib. What gives?
%define _libexecdir %_exec_prefix/lib
%endif
%if "%{?_initddir}" == ""
%define _initddir %_initrddir
%endif
%description
The terminal server solution x2goserver is a "server based computing environment"
combining the advantages of different existing solutions. This package contains
the main daemon and tools for session administrations (scripts).
%prep
%setup -q
%patch2 -p1
%build
# Distro-specific.
perl -i -pe '
s{^\s*"lib"\x29.*}{"lib"\x29 echo -n "%_libdir/x2go";;};
s{^\s*"libexec"\x29.*}{"libexec"\x29 echo -n "%_libexecdir/x2go";;};
s{^\s*"xinerama"\x29.*}{"xinerama"\x29 echo -n "%_libexecdir/NX3/%_lib/Xinerama";;};
' x2goserver/bin/x2gopath
chmod a+x x2goserver/bin/x2gopath
make %{?_smp_mflags} PREFIX="%_prefix" LIBDIR="%_libexecdir/x2go"
%install
# We have too much commands in this specfile. Most of this should have
# been done by make install.
b="%buildroot"
make install DESTDIR="%buildroot" \
PREFIX="%_prefix" LIBDIR="%_libexecdir/x2go" \
INSTALL_DIR="install -dm0755" \
INSTALL_FILE="install -pm0644" \
INSTALL_PROGRAM="install -pm0755"
mkdir -p "$b/%_libdir/x2go"
if [ "%_libexecdir" != "%_libdir" ]; then
mv "$b/%_libexecdir/x2go"/*.pm "$b/%_libdir/x2go/"
fi
mkdir -p \
"$b/%_localstatedir/lib/x2go" \
"$b/%_localstatedir/spool/x2goprint"
find "$b" -type f -exec chmod u-s "{}" "+" -exec chmod g-s "{}" "+"
find "$b" -type f -name ".*" -size 0 -delete
mkdir -p "$b/%_sysconfdir/permissions.d"
cat >"$b/%_sysconfdir/permissions.d/%name" <<-EOF
%_bindir/x2goprint root:x2goprint 02755
%_libexecdir/x2go/x2gosqlitewrapper root:x2gouser 02755
EOF
mkdir -p "$b/%_sysconfdir/X11/Xsession.d"
# Ignoring this file again in %%files so as to jump over
# "ERROR: link target for /etc/x2go/Xresources not found"
touch "$b/%_sysconfdir/X11/Xresources"
# session cleaner daemon startup files
install -d -m 775 %{buildroot}/%{_sbindir}
%if 0%{?_unitdir:1}
# systemd
mkdir -p "$b/%_unitdir"
install -pm0644 "%_sourcedir"/*.service "$b/%_unitdir"
%if 0%{?suse_version}
ln -s -f service %{buildroot}/%{_sbindir}/rcx2gocleansessions
%endif
%else
mkdir -p "$b/%_initddir"
# init file
install -pm0755 rpm/x2goserver.init "$b/%_initddir/x2gocleansessions"
perl -i -pe '
s{x2goserver}{x2gocleansessions}g;
s{Default-Start:.*}{Default-Start: 3 5}g;
s{Default-Stop:.*}{Default-Stop: 0 1 2 6}g;
' "$b/%_initddir/x2gocleansessions"
# rc-file
%if 0%{?suse_version}
pushd %{buildroot}/%{_sbindir}
ln -s -f %_initddir/x2gocleansessions rcx2gocleansessions
popd
%endif
%endif
mkdir -p "$b/%_localstatedir/lib/x2go"
mkdir -p "$b/%_localstatedir/lib/x2go"
# mkr
mkdir -p "$b/%_libexecdir/x2go/extensions"/{pre,post}-runcommand.d
%if 0%{?fdupes:1}
%fdupes %buildroot/%_prefix
%endif
%pre
# add users
/usr/bin/getent group x2gouser >/dev/null 2>/dev/null || \
/usr/sbin/groupadd -r x2gouser
/usr/bin/getent passwd x2gouser >/dev/null 2>/dev/null || \
/usr/sbin/useradd -c "x2go server/user" -d %_localstatedir/lib/x2go \
-g x2gouser -r -s /bin/false x2gouser
/usr/bin/getent group x2goprint >/dev/null 2>/dev/null || \
/usr/sbin/groupadd -r x2goprint
/usr/bin/getent passwd x2goprint >/dev/null 2>/dev/null || \
/usr/sbin/useradd -c "x2go server/print" \
-d %_localstatedir/spool/x2goprint \
-g x2goprint -r -s /bin/false x2goprint
%if 0%{?sles_version} == 11
%else
%if 0%{?service_add_pre:1}
%service_add_pre x2gocleansessions.service
%endif
%endif
%post
%if 0%{?suse_version}
%if 0%{?suse_version} <= 1130
%run_permissions
%else
%set_permissions %_bindir/x2goprint %_libexecdir/x2go/x2gosqlitewrapper
%endif
%endif
db="%_localstatedir/lib/x2go/x2go_sessions"
if test ! -e "$db"; then
"%_sbindir/x2godbadmin" --create
# Uff. Ignore return codes to make rpmlint's test %%post run succeed.
chgrp x2gouser "$db" || :
chmod ug=rw "$db" || :
fi
%if 0%{?systemd_post:1}
%systemd_post x2gocleansessions.service
%else
%if 0%{?sles_version} == 11
%else
%if 0%{?service_add_post:1}
%service_add_post x2gocleansessions.service
%endif
%endif
%endif
%if 0%{?suse_version}
%verifyscript
%verify_permissions -e %_bindir/x2goprint %_libexecdir/x2go/x2gosqlitewrapper
%endif
%preun
%if 0%{?systemd_preun:1}
%systemd_preun x2gocleansessions.service
%else
%if 0%{?sles_version} == 11
%stop_on_removal x2gocleansession
%else
%if 0%{?service_del_preun:1}
%stop_on_removal x2gocleansession
%service_del_preun x2gocleansessions.service
%endif
%endif
%endif
%postun
%if 0%{?systemd_postun:1}
%systemd_postun x2gocleansessions.service
%else
%if 0%{?sles_version} == 11
%restart_on_update x2gocleansessions
%insserv_cleanup
%else
%if 0%{?service_del_postun:1}
%restart_on_update x2gocleansessions
%insserv_cleanup
%service_del_postun x2gocleansessions.service
%endif
%endif
%endif
%files
%defattr(-,root,root)
%dir %_sysconfdir/logcheck/
%dir %_sysconfdir/logcheck/ignore.d.server/
%config %_sysconfdir/logcheck/ignore.d.server/x2*
%config %_sysconfdir/X11/*
%exclude %_sysconfdir/X11/Xresources
%config %_sysconfdir/permissions.d/%name
%dir %attr(0750,root,root) %_sysconfdir/sudoers.d
%config %_sysconfdir/sudoers.d/x2go*
%config %_sysconfdir/x2go
#%dir %attr(0750,root,root) %_sysconfdir/logcheck
#%dir %attr(0750,root,root) %_sysconfdir/logcheck/ignore.d.server
#%config %_sysconfdir/logcheck/ignore.d.server/x2goserver
%if 0%{?_unitdir:1}
%_unitdir
%else
%_initddir/x2gocleansessions
%endif
%if 0%{?suse_version}
%_sbindir/rcx2gocleansessions
%endif
%_bindir/x2gopath
%attr(02755,root,x2goprint) %_bindir/x2goprint
%_bindir/x2go[a-oq-z]*
%_libdir/x2go
%dir %_libexecdir/x2go
%attr(02755,root,x2gouser) %_libexecdir/x2go/x2gosqlitewrapper
%_libexecdir/x2go/x2go[c-rt-z]*
%_libexecdir/x2go/x2gosqlitewrapper.pl
%_libexecdir/x2go/x2gosuspend-agent
%_libexecdir/x2go/x2gosyslog
%_libexecdir/x2go/extensions
%_sbindir/x2go*
%_mandir/man5/x2go*
%_mandir/man8/x2go*
%attr(0664,root,root) %_datadir/applications/x2gofm.desktop
%_datadir/x2go
%attr(0664,root,root) %_datadir/mime/packages/sshfs-x2go.xml
%attr(0775,root,x2gouser) %dir %_localstatedir/lib/x2go
%attr(0770,x2goprint,x2goprint) %_localstatedir/spool/x2goprint
%changelog