LogoKolab Groupware OBS > Projects
Log In

View File phabricator.spec of Package phabricator (Project Infrastructure)

%global revision_date 20161211
%global git_short_version_hash 3cd0001
%global git_full_version_hash 3cd0001d8b95897d5efafa0c391a9e870fd35471

Summary:            An open software engineering platform
Name:               phabricator
Version:            0.%{revision_date}.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

Source998:          README.fedora
Source999:          README.rhel

# The following patches originate from a series of branches, one
# stacked on the other, finally using git format-patch to create
# these patches.
#
# The github repository lives at https://github.com/kanarip/phabricator,
#
# The removal of the corresponding externals/ directories for the bundled
# software is intentionally **NOT** removed through a git patch -- it bloats
# the patch and is more difficult to maintain.

# packaging/stable/0001-unbundle-figlet
Patch0001:          0001-Unbundle-figlet.patch

# packaging/stable/0002-unbundle-cowsay
Patch0002:          0002-Unbundle-cowsay.patch

# packaging/stable/0003-unbundle-wordlist
Patch0003:          0003-Unbundle-wordlist.patch

# packaging/stable/0004-unbundle-amazon-ses
Patch0004:          0004-Unbundle-Amazon-SES.patch

# packaging/stable/0005-unbundle-pear-figlet
Patch0005:          0005-Unbundle-pear-figlet.patch

# packaging/stable/0006-unbundle-phpmailer
Patch0006:          0006-Unbundle-phpmailer.patch

# packaging/stable/0007-unbundle-stripe
Patch0007:          0007-Unbundle-stripe.patch

# packaging/stable/0008-unbundle-wepay
Patch0008:          0008-Unbundle-wepay.patch

# packaging/stable/0009-unbundle-twilio
Patch0009:          0009-Unbundle-twilio.patch

# packaging/stable/0010-version-info
Patch0010:          0010-No-version-information-can-be-obtained-using-git-use.patch

# feature/stable/0001-create-accounts-inbound-email
Patch0011:          0011-Create-user-account-on-inbound-email.patch

# feature/stable/0002-no-requiring-top-replies
Patch0012:          0012-Do-not-require-top-replies-only.patch

# feature/stable/0003-no-display-name-matching
Patch0013:          0013-No-matching-commits-to-users-on-displayname.patch

# feature/stable/0004-pht-title
Patch0014:          0014-Allow-the-title-to-be-overriden.patch

# feature/stable/0005-revert-obsolete-buildApplicationPage-removal
Patch0015:          0015-Revert-Removed-unused-buildApplicationPage-method-fr.patch

# Unvendorized system dependencies
Requires:           cowsay
Requires:           figlet
Requires:           php-PHPMailer

Requires:           arcanist >= 0.20160909
Requires:           arcanist <= 0.20170314
Requires:           git-core
Requires:           httpd
Requires:           nodejs
Requires:           nodejs-ws
Requires:           phabricator(libphutil) >= 0.20160909
Requires:           phabricator(libphutil) <= 0.20170314
Requires:           php(language) >= 5
# See:
# * https://pagure.io/phabphourphedora/issue/7
# * https://secure.phabricator.com/T9640#184099
# * https://secure.phabricator.com/T11270
Requires:           php(language) < 7
Requires:           php-curl
Requires:           php-iconv
Requires:           php-pecl-mailparse
Requires:           python-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/

%patch0001 -p1
rm -rf externals/figlet

%patch0002 -p1
rm -rf externals/cowsay

%patch0003 -p1
rm -rf externals/wordlist

%patch0004 -p1
rm -rf externals/amazon-ses

%patch0005 -p1
rm -rf externals/pear-figlet

%patch0006 -p1
rm -rf externals/phpmailer

%patch0007 -p1
rm -rf externals/stripe-php

%patch0008 -p1
rm -rf externals/wepay

%patch0009 -p1
rm -rf externals/twilio-php

# features (arguably)
%patch0010 -p1
%patch0011 -p1
%patch0012 -p1
%patch0013 -p1
%patch0014 -p1
%patch0015 -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}

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(0750, phabricator, apache) %dir %{_sysconfdir}/%{name}/
%config(noreplace) %attr(0640, phabricator, apache) %{_sysconfdir}/%{name}/aphlict.config.json
%config(noreplace) %attr(0640, phabricator, apache) %{_sysconfdir}/%{name}/%{name}.config.json
%config(noreplace) %{_sysconfdir}/ssh/sshd_config_phab
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_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
* Mon Dec 12 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161211.git3cd0001-1
- Promote Week #49 2016

* Sun Dec 04 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161203.gitad65d93-5
- Rebuild

* Sun Dec 04 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161203.gitad65d93-4
- Rebuild

* Sun Dec 04 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161203.gitad65d93-3
- Rebuild

* Sat Dec 03 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161203.gitad65d93-2
- Rebuild

* Sat Dec 03 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161203.gitad65d93-1
- Promote Week #48 2016

* Sat Dec 03 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-7
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-6
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-5
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-4
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-3
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-2
- Rebuild

* Thu Dec 01 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.20161126.gitcfcc3b8-1
- Rebuild

* Tue Nov 29 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20161126.gitcfcc3b8-1
- Promote Week #47 2016

* Sat Nov 05 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20161028.gitbd256e9-1
- Promote Week #43

* Mon Oct  3 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20161001.git8dbc3f1-1
- Promote week #40

* Thu Sep  8 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20160906.git6725f37-1
- Promote week #36

* Thu Aug 25 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20160821.gitb88348a-3
- Add sshd config, service and libexec hook

* Tue Aug 23 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20160821.gitb88348a-2
- Promote week #34
- Allow the title of the home page to go through pht()

* Tue Aug  9 2016 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 20160806.git435f756-1
- Further develop the packaging over the work from Tim Flink <tflink@fedoraproject.org>