File humhub.spec of Package humhub
#
# spec file for package humhub
#
# Copyright (c) 2021 SUSE LCC
#
# 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/
#
%if 0%{?suse_version}
%define ap_usr wwwrun
%define ap_grp www
%else
%define ap_usr nobody
%define ap_grp nogroup
%endif
%define ap_sysconfdir %(apxs -q SYSCONFDIR)
%define installdir /usr/share/php/%{name}
Name: humhub
Version: 1.17.3
Release: 0
Summary: Open Source Social Network
License: AGPL-3.0-or-later
Group: Productivity/Networking/Web/Utilities
Url: https://www.humhub.com/
Source: %{name}-%{version}.tar.xz
#
# zypper install php-composer
# cd humhub
# composer install --no-dev --no-scripts --ignore-platform-reqs
# => check "scripts" section in composer.json
# export version=%%{version}; tar -cvJf ../humhub-${version}-vendor.tar.xz protected/vendor/
#
Source1: %{name}-%{version}-vendor.tar.xz
Source2: humhub-apache.conf
Source3: humhub-cron.service
Source4: humhub-cron.timer
Source5: humhub-queue.service
Source6: humhub-queue.timer
Source10: humhub-rpmlintrc
Recommends: php-APCu
Recommends: php-ldap
Recommends: php-memcached
Requires: mod_php_any >= 8.1
Requires: php-curl
Requires: php-exif
Requires: php-fileinfo
Requires: php-gd
Requires: php-intl
Requires: php-mbstring
Requires: php-mysql
Requires: php-pdo
Requires: php-zip
BuildRequires: apache2-devel
BuildRequires: fdupes
BuildRequires: logrotate
BuildRequires: mariadb
BuildRequires: pkgconfig(systemd)
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%if 0%{?suse_version} >= 1500
Requires(pre): user(%ap_usr)
Requires(pre): group(%ap_grp)
%else
Requires(pre): aaa_base
%endif
Requires(pre): php >= 8
%description
HumHub is a feature rich and highly flexible OpenSource Social Network Kit
written in PHP.
It's perfect for individual:
* Social Intranets
* Enterprise Social Networks
* Private Social Networks
%prep
%setup -q -a1
# remove unwanted files
for file in \
.doctor-rst.yaml \
.editorconfig \
.eslintrc \
.eslintrc.js \
.eslintrc.json \
.gitattributes \
.gitkeep \
.htaccess \
.keep \
.laminas-ci.json \
.npmignore \
.php_cs \
.php-cs-fixer.dist.php \
.php_cs.dist \
.phpstorm.meta.php \
.prettierrc.json \
.prettierrc.yml \
.rake_t_cache \
.requirements.txt \
.sami.php \
.scrutinizer.yml \
.travis.yml \
.travis.sh \
.travis.install.sh \
.tool-versions \
.jshintrc \
.stylelintrc \
.doctrine-project.json \
.DS_Store \
.phpcs.xml.dist \
.pullapprove.yml\
; do
find . -type f -name "$file" -delete
done
find . -type f "(" -name "*.c" -o -name "*.h" -o -name "*.js.orig" -o -name "yii.bat" -o -name ".gitignore" -o -name ".coveralls.yml" -o -name ".prettierignore" -o -name ".eslintignore" -o -name ".tm_properties" -o -name ".zuul.yml" -o -name ".nycrc" -o -name ".codoopts" -o -name ".jscsrc" -o -name ".jshintignore" ")" -delete
for dir in .git .github .idea .laminas-ci .phive .phpdoc .psalm .travis; do
find . -type d -name "$dir" -prune -exec rm -rf {} + || :
done
# env-script-interpreter
find . -type f -exec sed -i -e 's|\/usr\/bin\/env php|\/usr\/bin\/php|g' {} +
%build
# nothing to build
%install
install -d -m0755 %{buildroot}/%{installdir}
# copy src from build to buildroot
cp -dR * %{buildroot}/%{installdir}/
rm %{buildroot}/%{installdir}/*.md
rm %{buildroot}/%{installdir}/LICENSE*
cp -fa .htaccess.dist %{buildroot}/%{installdir}/
# create missing directories
mkdir -p %{buildroot}%{installdir}/uploads/icon %{buildroot}%{installdir}/uploads/logo_image %{buildroot}/var/log/%{name} %{buildroot}%{_sysconfdir}/%{name}
# install apache config
mkdir -p %{buildroot}/%{ap_sysconfdir}/conf.d
sed -e 's|__humhub_web__|%{installdir}|g' \
-e 's|__humhub_conf__|%{_sysconfdir}/%{name}|g' \
-e 's|__humhub_log__|/var/log/%{name}|g' \
%{SOURCE2} > %{buildroot}/%{ap_sysconfdir}/conf.d/%{name}.conf
# cron timer
install -D -m 644 %{SOURCE4} %{buildroot}/%{_unitdir}/humhub-cron.timer
install -D -m 644 %{SOURCE6} %{buildroot}/%{_unitdir}/humhub-queue.timer
# cron job
sed -e 's|__humhub_web__|%{installdir}|g' \
%{SOURCE3} > %{buildroot}/%{_unitdir}/humhub-cron.service
sed -e 's|__humhub_web__|%{installdir}|g' \
%{SOURCE5} > %{buildroot}/%{_unitdir}/humhub-queue.service
# reduce size, run fdupes
%fdupes %{buildroot}/%{installdir}
%check
#
%pre
%service_add_pre humhub-cron.timer humhub-queue.timer
%post
if [ $1 -gt 1 ]; then
echo "Please consider running the following update commands for %{name}:"
echo "su %ap_usr -s /bin/sh -c \"%{_bindir}/php %{installdir}/protected/yii migrate/up --include-module-migrations=1 --interactive=0\""
echo "su %ap_usr -s /bin/sh -c \"%{_bindir}/php %{installdir}/protected/yii cache/flush-all --interactive=0\""
# FIXME: this updates all modules from the marketplace via Internet
# if the modules are available via RPM packages and installed *before* the main package,
# the following command should be obsolete.
# This is turn would allow to have %%{installdir}/protected/modules root:root
echo "su %ap_usr -s /bin/sh -c \"%{_bindir}/php %{installdir}/protected/yii module/update-all --interactive=0\""
fi
%service_add_post humhub-cron.timer humhub-queue.timer
%preun
%service_del_preun humhub-cron.timer humhub-queue.timer
%postun
%service_del_postun humhub-cron.timer humhub-queue.timer
%files
%defattr(0644,root,root,0755)
%license LICENSE*
%doc *.md
%dir %{_sysconfdir}/%{name}
%dir %{_datadir}/php
%dir %{installdir}
%dir %{installdir}/uploads
%dir %{installdir}/protected
%config(noreplace) %{ap_sysconfdir}/conf.d/%{name}.conf
%{_unitdir}/humhub-cron.timer
%{_unitdir}/humhub-cron.service
%{_unitdir}/humhub-queue.timer
%{_unitdir}/humhub-queue.service
%attr(0755,root,root) %{installdir}/protected/yii
%{installdir}/protected/config/README.md
%{installdir}/uploads/index.html
%{installdir}/static
%{installdir}/themes
%{installdir}/protected/humhub
%{installdir}/protected/vendor
%{installdir}/*json
%{installdir}/*.js
%{installdir}/*.php
%{installdir}/.htaccess.dist
%{installdir}/*.txt
%{installdir}/*.lock
%defattr(0640,%ap_usr,%ap_grp,0750)
%dir %{installdir}/protected/runtime
%dir %{installdir}/assets
%dir %{installdir}/protected/config
%config(noreplace) %{installdir}/protected/config/*.php
%dir %{installdir}/protected/modules
%dir %{installdir}/uploads/file
%dir /var/log/%{name}
%{installdir}/uploads/file/*
%dir %{installdir}/uploads/icon
%dir %{installdir}/uploads/logo_image
%dir %{installdir}/uploads/profile_image
%{installdir}/uploads/profile_image/*
%changelog