Files
rpms/fedora/SPECS/phabricator.spec

279 lines
9.0 KiB
RPMSpec
Raw Normal View History

%global git_short_version_hash b2ab18f8f3
%global git_full_version_hash b2ab18f8f3d0cbab55b92da7a5fcbc0e148a4c99
Summary: An open software engineering platform
Name: phabricator
2020-12-20 10:42:39 +01:00
Version: 0.git%{git_short_version_hash}
Release: 1%{?dist}
License: ASL 2.0
Group: Applications/Productivity
URL: http://www.phabricator.org/
Source0: https://github.com/phacility/%{name}/archive/%{git_full_version_hash}.tar.gz#/%{name}-%{git_full_version_hash}.tar.gz
Source1: aphlict.service
Source2: phd.service
Source3: sshd-phab.service
Source4: phabricator.tmpfiles.conf
Source5: sshd_config_phab
Source6: phabricator.sysconfig
Source7: aphlict.config.json
Source8: phabricator.config.json
2020-12-20 13:02:42 +01:00
Source9: httpd-phabricator.conf
Source998: README.fedora
Source999: README.rhel
Patch1: 0001-No-matching-commits-to-users-on-displayname.patch
2020-12-20 10:42:39 +01:00
Requires: arcanist
Requires: git-core
Requires: httpd
Requires: nodejs
Requires: nodejs-ws
Requires: php(language) >= 5
Requires: php-curl
Requires: php-iconv
Requires: php-pecl-mailparse
Requires: python3-pygments
Requires: sudo
Requires(post): systemd-units
Requires(postun): systemd-units
Requires(preun): coreutils
Requires(preun): systemd-units
BuildRequires: systemd
BuildArch: noarch
%description
Phabricator is a collection of open source web applications that help
software companies build better software.
%prep
%setup -q -n %{name}-%{git_full_version_hash}
# Shipping is sorted in %files
cp -a %{SOURCE998} .
cp -a %{SOURCE999} .
# externals that do not seem to be used at all
rm -rf \
externals/httpful/ \
externals/restful/
%patch1 -p1
grep -rlE '/usr/local/bin|bin/env' . | xargs sed -i -e ' 1 {
s,/usr/local/bin/php,%{_bindir}/php,
s,/usr/bin/env .*php,%{_bindir}/php,
}'
sed -r -i \
-e 's|/var/log/aphlict.log|/var/log/%{name}/aphlict.log|g' \
-e 's|/var/tmp/aphlict/pid/aphlict.pid|/var/run/%{name}/aphlict.pid|g' \
conf/aphlict/aphlict.default.json
%build
# Nothing to do here
%install
rm -rf %{buildroot}
install -d %{buildroot}%{_libexecdir}/%{name}
install -d %{buildroot}%{_datadir}/%{name}
install -d %{buildroot}%{_sysconfdir}/%{name}/
install -d %{buildroot}%{_sysconfdir}/ssh/
install -d %{buildroot}%{_sysconfdir}/sysconfig/
install -d %{buildroot}%{_sysconfdir}/tmpfiles.d/
install -d %{buildroot}%{_var}/lib/%{name}
install -d %{buildroot}%{_var}/lib/%{name}/files
install -d %{buildroot}%{_var}/lib/%{name}/repos
install -d %{buildroot}%{_var}/log/%{name}
install -d %{buildroot}%{_unitdir}
cp -a \
bin/ \
conf/ \
externals/ \
resources/ \
scripts/ \
src/ \
support/ \
webroot/ \
%{buildroot}%{_datadir}/%{name}/.
# Hidden and zero-length, but needed in git / sources
rm -rf %{buildroot}%{_datadir}/%{name}/conf/keys/.keep
mv \
%{buildroot}%{_datadir}/%{name}/resources/sshd/phabricator-ssh-hook.sh \
%{buildroot}%{_libexecdir}/%{name}/ssh-hook
chmod a+x %{buildroot}%{_libexecdir}/%{name}/ssh-hook
sed -r -i \
-e 's|^VCSUSER=.*$|VCSUSER="git"|g' \
-e 's|^ROOT=.*$|ROOT="/usr/share/%{name}"|g' \
%{buildroot}%{_libexecdir}/%{name}/ssh-hook
install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/aphlict.service
install -p -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/phd.service
install -p -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/sshd-phab.service
install -p -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
install -p -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/ssh/sshd_config_phab
install -p -m 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
2020-12-20 13:02:42 +01:00
install -D -p -m 644 %{SOURCE9} %{buildroot}%{_sysconfdir}/httpd/vhosts.d/%{name}.conf
pushd %{buildroot}%{_datadir}/%{name}/conf/aphlict/
mv aphlict.default.json ../../../../..%{_sysconfdir}/%{name}/aphlict.config.json
ln -s ../../../../..%{_sysconfdir}/%{name}/aphlict.config.json aphlict.default.json
popd
install -p -m 640 %{SOURCE7} %{buildroot}%{_sysconfdir}/%{name}/aphlict.config.json
pushd %{buildroot}%{_datadir}/%{name}/conf/local/
ln -s ../../../../..%{_sysconfdir}/%{name}/%{name}.config.json local.json
popd
install -p -m 640 %{SOURCE8} %{buildroot}%{_sysconfdir}/%{name}/%{name}.config.json
##install -d %{buildroot}%{_sysconfdir}/sudoers.d/
# Very probably not allowed
##cat > %{buildroot}%{_sysconfdir}/sudoers.d/apache << EOF
##apache ALL=(phabricator) SETENV: NOPASSWD: /usr/libexec/git-core/git-http-backend
##EOF
# Very probably not allowed
##cat > %{buildroot}%{_sysconfdir}/sudoers.d/git << EOF
##git ALL=(phabricator) SETENV: NOPASSWD: /usr/bin/git-upload-pack, /usr/bin/git-receive-pack
##EOF
%clean
rm -rf %{buildroot}
%pretrans
if [ -f %{_datadir}/%{name}/conf/local/local.json ]; then
if [ ! -L %{_datadir}/%{name}/conf/local/local.json ]; then
mkdir -p %{_sysconfdir}/%{name}
chown phabricator:apache %{_sysconfdir}/%{name}
chmod 750 %{_sysconfdir}/%{name}
mv %{_datadir}/%{name}/conf/local/local.json \
%{_sysconfdir}/%{name}/%{name}.config.json
chmod 640 %{_sysconfdir}/%{name}/%{name}.config.json
chown phabricator:apache %{_sysconfdir}/%{name}/%{name}.config.json
ln -s ../../../../..%{_sysconfdir}/%{name}/%{name}.config.json \
%{_datadir}/%{name}/conf/local/local.json
fi
fi
if [ -f %{_datadir}/%{name}/conf/aphlict/aphlict.default.json ]; then
if [ ! -L %{_datadir}/%{name}/conf/aphlict/aphlict.default.json ]; then
mkdir -p %{_sysconfdir}/%{name}
chown phabricator:apache %{_sysconfdir}/%{name}
chmod 750 %{_sysconfdir}/%{name}
mv %{_datadir}/%{name}/conf/aphlict/aphlict.default.json \
%{_sysconfdir}/%{name}/aphlict.config.json
chmod 640 %{_sysconfdir}/%{name}/aphlict.config.json
chown phabricator:apache %{_sysconfdir}/%{name}/aphlict.config.json
ln -s ../../../../..%{_sysconfdir}/%{name}/aphlict.config.json \
%{_sysconfdir}/%{name}/aphlict.config.json
fi
fi
%pre
getent group phabricator >/dev/null || \
groupadd -r phabricator >/dev/null 2>&1 || :
getent passwd phabricator >/dev/null || \
useradd -r -g phabricator -d /var/lib/phabricator -s /sbin/nologin \
-c "Phabricator Service User" phabricator >/dev/null 2>&1 || :
# Very probably inappropriate
#getent passwd git >/dev/null || \
# useradd -r -d "/var/lib/git" -s /bin/bash \
# -c "Git Service User" git >/dev/null 2>&1 || :
#
#passwd -d git >/dev/null 2>&1 || :
#passwd -uf git >/dev/null 2>&1 || :
# Not possible without the former segment
#getent group phabricator | grep -q git || \
# gpasswd -a git phabricator >/dev/null 2>&1 || :
# Necessary for apache and phabricator to both have access to git repositories
getent group phabricator | grep -q apache || \
gpasswd -a apache phabricator >/dev/null 2>&1 || :
# Only execute on upgrade, not install/uninstall
if [ $1 -gt 1 -a -f /etc/sysconfig/%{name} ]; then
. /etc/sysconfig/%{name} || exit 0
if [ "${AUTO_DUMP_STORAGE}" == "1" ]; then
%{_datadir}/%{name}/bin/storage dump | \
gzip -c > %{_var}/lib/%{name}/pre-%{version}-%{release}.sql.gz || :
fi
fi
%post
# Very probably not allowed
#sed -i -e '/requiretty/d' /etc/sudoers >/dev/null 2>&1 || :
%systemd_post httpd.service
%systemd_post aphlict.service
%systemd_post phd.service
# Only execute on upgrade
if [ $1 -gt 1 -a -f /etc/sysconfig/%{name} ]; then
. /etc/sysconfig/%{name} || exit 0
if [ "${AUTO_UPGRADE_STORAGE}" == "1" ]; then
%{_datadir}/%{name}/bin/storage upgrade --force > \
%{_var}/log/%{name}/upgrade-%{version}-%{release}.log 2>&1 || :
fi
fi
%preun
%systemd_preun httpd.service
%systemd_preun aphlict.service
%systemd_preun phd.service
%postun
%systemd_postun_with_restart httpd.service
%systemd_postun_with_restart aphlict.service
%systemd_postun_with_restart phd.service
%files
%{!?_licensedir:%global license %doc}
%license LICENSE
%if 0%{?fedora}
%doc README.fedora
%else
%doc README.rhel
%endif
%doc README.md
%doc NOTICE
%{_datadir}/%{name}
%{_libexecdir}/%{name}
#%%config(noreplace) %{_sysconfdir}/sudoers.d/apache
#%%config(noreplace) %{_sysconfdir}/sudoers.d/git
%attr(0755, phabricator, apache) %dir %{_sysconfdir}/%{name}/
%config(noreplace) %attr(0644, phabricator, apache) %{_sysconfdir}/%{name}/aphlict.config.json
%config(noreplace) %attr(0644, phabricator, apache) %{_sysconfdir}/%{name}/%{name}.config.json
%config(noreplace) %{_sysconfdir}/ssh/sshd_config_phab
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
2020-12-20 13:02:42 +01:00
%config(noreplace) %{_sysconfdir}/httpd/vhosts.d/%{name}.conf
%{_sysconfdir}/tmpfiles.d/%{name}.conf
%{_unitdir}/aphlict.service
%{_unitdir}/phd.service
%{_unitdir}/sshd-phab.service
%attr(0775, phabricator, phabricator) %{_var}/lib/%{name}
%attr(0775, phabricator, phabricator) %{_var}/log/%{name}
%changelog
2020-12-20 13:02:42 +01:00
* Sun Dec 20 2020 Daniel Steiner <daniel.steiner@dsteiner.ch>
- Initial build for Fedora 33.