libreoffice-online/coolwsd.spec.in
Caolán McNamara 85eaec2311 add 'mount_namespaces' option to use linux mount namespaces
if experimental_features and mount_namespaces is enabled and it is
possible to "unshare" then instead of coolforkit exec coolforkitns which
doesn't have any capabilities set and inprocess mount inside a namespace
instead of calling coolmount

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I48bef12b9156f41c78221e750a30aacee8a737a9
2024-07-02 13:31:38 +01:00

153 lines
6 KiB
RPMSpec

# spec file for package coolwsd
#
# Copyright (c) 2023 Collabora
#
# This file is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Name: coolwsd
Version: @PACKAGE_VERSION@
Release: 1
Vendor: Collabora Productivity Ltd.
Summary: Collabora Online WebSocket Daemon
License: EULA
Source0: coolwsd-@PACKAGE_VERSION@.tar.gz
BuildRequires: libcap-devel pam-devel rsync
Requires: collaboraoffice collaboraoffice-ure collaboraofficebasis-core collaboraofficebasis-writer collaboraofficebasis-impress collaboraofficebasis-graphicfilter collaboraofficebasis-en-US collaboraofficebasis-calc collaboraofficebasis-ooofonts collaboraofficebasis-images collaboraofficebasis-draw collaboraofficebasis-extension-pdf-import collaboraofficebasis-ooolinguistic collaboraofficebasis-math
Requires(post): coreutils grep sed cpio /usr/sbin/setcap
Provides: loolwsd
Obsoletes: loolwsd collaboraoffice-dict-br collaboraoffice-dict-et collaboraoffice-dict-gd collaboraoffice-dict-gu collaboraoffice-dict-hi collaboraoffice-dict-lt collaboraoffice-dict-lv collaboraoffice-dict-ro collaboraoffice-dict-sr collaboraoffice-dict-te collaboraofficebasis-as collaboraofficebasis-bn-IN collaboraofficebasis-ast collaboraofficebasis-br collaboraofficebasis-ca-valencia collaboraofficebasis-cy collaboraofficebasis-et collaboraofficebasis-ga collaboraofficebasis-gd collaboraofficebasis-gu collaboraofficebasis-hi collaboraofficebasis-km collaboraofficebasis-kn collaboraofficebasis-lt collaboraofficebasis-lv collaboraofficebasis-ml collaboraofficebasis-mr collaboraofficebasis-nn collaboraofficebasis-or collaboraofficebasis-pa-IN collaboraofficebasis-ro collaboraofficebasis-sr collaboraofficebasis-sr-Latn collaboraofficebasis-ta collaboraofficebasis-te
%description
%prep
%setup -n coolwsd-@PACKAGE_VERSION@
%build
%configure \
--enable-silent-rules \
--with-lokit-path=bundled/include \
--with-lo-path=/opt/collaboraoffice \
--disable-setcap \
--disable-tests \
%if 0%{?config_options:1}
%{config_options}
%endif
env BUILDING_FROM_RPMBUILD=yes make %{?_smp_mflags}
%check
#env BUILDING_FROM_RPMBUILD=yes make check
%install
env BUILDING_FROM_RPMBUILD=yes make install DESTDIR=%{buildroot}
install -D -m 444 coolwsd.service %{buildroot}/usr/lib/systemd/system/coolwsd.service
# Apache webserver on RH-like distributions
install -d -m 755 %{buildroot}/etc/httpd/conf
install -D -m 755 etc/apache2/coolwsd.conf %{buildroot}/etc/httpd/conf
mkdir -p %{buildroot}/etc/pam.d
echo "auth required pam_unix.so" > %{buildroot}/etc/pam.d/coolwsd
echo "account required pam_unix.so" >> %{buildroot}/etc/pam.d/coolwsd
%files
%defattr(-,root,root,-)
/usr/bin/coolwsd
/usr/bin/loolwsd
/usr/bin/coolwsd-systemplate-setup
/usr/bin/loolwsd-systemplate-setup
/usr/bin/coolforkit
/usr/bin/coolforkitns
/usr/bin/coolconvert
/usr/bin/coolconfig
/usr/bin/loolconfig
/usr/bin/coolstress
/usr/bin/coolmount
/usr/share/coolwsd/discovery.xml
/usr/share/coolwsd/favicon.ico
/usr/share/coolwsd/browser
/usr/share/doc/coolwsd/README.md
/usr/share/doc/coolwsd/README.vars
/usr/share/doc/coolwsd/metrics.txt
/usr/share/doc/coolwsd/protocol.txt
/usr/share/doc/coolwsd/reference.md
/usr/share/doc/coolwsd/THIRDPARTYLICENSES
/usr/share/man/man1/coolwsd.1.gz
/usr/share/man/man1/coolforkit.1.gz
/usr/share/man/man1/coolconvert.1.gz
/usr/share/man/man1/coolconfig.1.gz
/usr/share/man/man1/coolstress.1.gz
/usr/share/man/man1/coolwsd-systemplate-setup.1.gz
/usr/share/man/man1/coolmount.1.gz
/usr/lib/systemd/system/coolwsd.service
%config(noreplace) /etc/pam.d/coolwsd
%config(noreplace) %attr(640, cool, root) /etc/coolwsd/coolwsd.xml
%config /etc/coolwsd/coolkitconfig.xcu
%config(noreplace) /etc/nginx/snippets/coolwsd.conf
%config(noreplace) /etc/apache2/conf-available/coolwsd.conf
%config(noreplace) /etc/httpd/conf/coolwsd.conf
%doc README.md
%pre
getent group cool >/dev/null || groupadd -r cool
getent passwd cool >/dev/null || useradd -g cool -r cool -d /opt/cool -s /bin/bash
%post
setcap cap_fowner,cap_chown,cap_sys_chroot=ep /usr/bin/coolforkit
setcap cap_sys_admin=ep /usr/bin/coolmount
if [ -f /etc/loolwsd/loolwsd.xml ]; then /usr/bin/coolconfig migrateconfig --write; fi
# compatibility with older systemd versions
SYSTEMD_VERSION=$(busctl --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Version | grep -Eo [0-9]{3} | head -n 1)
if [[ "$SYSTEMD_VERSION" -lt "228" ]]; then
sed -i "/^ProtectSystem/d" /usr/lib/systemd/system/coolwsd.service
fi
if [[ "$SYSTEMD_VERSION" -lt "231" ]]; then
sed -i "/^ReadWritePaths/d" /usr/lib/systemd/system/coolwsd.service
fi
if [[ "$SYSTEMD_VERSION" -lt "232" ]]; then
sed -i "/^ProtectControlGroups/d" /usr/lib/systemd/system/coolwsd.service
fi
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset coolwsd.service >/dev/null 2>&1 || :
fi
systemctl is-active -q coolwsd && COOLWSD_IS_ACTIVE=1 || COOLWSD_IS_ACTIVE=0
if [ $COOLWSD_IS_ACTIVE == "1" ]; then systemctl stop coolwsd; fi
# Figure out where LOKit is installed, let's hope it is not a mount point
# Create a directory for coolwsd on the same file system
lokitroot=/opt/collaboraoffice
coolparent=`cd ${lokitroot} && cd .. && /bin/pwd`
rm -rf ${coolparent}/cool
mkdir -p ${coolparent}/cool/child-roots
chown cool:cool ${coolparent}/cool
chown cool:cool ${coolparent}/cool/child-roots
fc-cache ${lokitroot}/share/fonts/truetype
coolwsd-systemplate-setup ${coolparent}/cool/systemplate ${lokitroot} >/dev/null 2>&1
coolconfig generate-proof-key >/dev/null 2>&1
if [ $COOLWSD_IS_ACTIVE == "1" ]; then systemctl start coolwsd; fi
%preun
if [ $1 -eq 0 ]; then
systemctl --no-reload disable coolwsd.service > /dev/null 2>&1 || :
systemctl stop coolwsd.service > /dev/null 2>&1 || :
fi
%postun
if [ $1 -eq 0 ]; then
systemctl daemon-reload >/dev/null 2>&1 || :
fi
%changelog
* Mon Aug 03 2015 Mihai Varga
- added the cronjob
* Tue May 19 2015 Tor Lillqvist
- Initial RPM release