A new user interface for you! Read more...

File gerrit.spec of Package gerrit

#
# spec file for package gerrit
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#


%define is_rc   0
%define gerrit_home /srv/gerrit
%define gerrit_site_home %{gerrit_home}/site/
%if 0%{?suse_version}
%define gl_sysconfdir %{_localstatedir}/adm/fillup-templates/sysconfig.
%else
%define gl_sysconfdir %{_sysconfdir}/sysconfig/
%endif
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}

Name:           gerrit
Version:        2.11.5
Release:        0
%define vertag  %{version}

Summary:        Gerrit is a web based code review system
License:        Apache License 2.0 
Group:          System Environment/Daemons

Url:            https://code.google.com/p/gerrit 
Source0:        https://gerrit-releases.storage.googleapis.com/gerrit-%{vertag}.war
Source1:        init.d-%{name}
Source2:        sysconfig-%{name}
Source4:        gerrit.logrotate
NoSource:       0
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Requires:       java >= 1.7.0
Requires:       jpackage-utils
Requires:       logrotate
Requires:       git
Requires:       mysql-connector-java >= 5.0

%if 0%{?suse_version}
Requires(pre):  shadow
%else
Requires(post): chkconfig initscripts
Requires(pre):  chkconfig initscripts
Requires(pre):  shadow-utils
%endif

%description
Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system.

Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.

Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer. This functionality enables a more centralized usage of Git. 

%prep
#%setup -q 
cp %{S:0} %{name}.war
%build

%install
# sles is a bit nagging about version of bytecode so lets make it quiet :)
export NO_BRP_CHECK_BYTECODE_VERSION=true

%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/bin
(cd %{buildroot}%{gerrit_site_home} ; ln -s %{_sysconfdir}/gerrit etc)
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/cache
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/data
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/lib
(cd %{buildroot}%{gerrit_site_home} ; ln -s %{_localstatedir}/log/gerrit/ logs)
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/plugins
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/static
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_site_home}/tmp
%{__mkdir} -p -m 755 %{buildroot}%{gerrit_home}/.gerritcodereview

%{__install} -p -m 755 %{name}.war %{buildroot}%{gerrit_site_home}/bin/
# config
%{__mkdir} -p %{buildroot}%{_sysconfdir}/gerrit
%{__mkdir} -p %{buildroot}%{_sysconfdir}/gerrit/mail

# logs
%{__mkdir} -p %{buildroot}%{_localstatedir}/log/gerrit/

# sysconfig and init
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__mkdir} -p %{buildroot}%{_sysconfdir}/init.d
%{__install} -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/%{name}
%{__install} -Dm 644 %{SOURCE2} %{buildroot}%{gl_sysconfdir}%{name}
%{__mkdir} -p %{buildroot}%_sbindir
%if 0%{?suse_version}
(cd %{buildroot}%_sbindir ; ln -s %{_sysconfdir}/init.d/%{name} rc%{name})
%endif
%{__install} -Dm 644 %{SOURCE4}  %{buildroot}%{_sysconfdir}/logrotate.d/%name

%{__mkdir} -p %{buildroot}/var/run/gerrit

%pre
# create gerrit group
if ! getent group gerrit >/dev/null; then
        groupadd -r gerrit
fi

# create gerrit user
if ! getent passwd gerrit >/dev/null; then
        useradd -r -g gerrit -d %{gerrit_home} \
            -s /bin/bash -c "Gerrit Code Review" gerrit
fi

%post
%if 0%{?suse_version}
%fillup_and_insserv
%restart_on_update
%else
/sbin/chkconfig --add gerrit
%endif
if [ -L %{_javadir}/mysql-connector-java.jar ]; then 
  if [ ! -L %{gerrit_site_home}/lib/mysql-connector-java.jar ] && [ ! -f %{gerrit_site_home}/lib/mysql-connector-java.jar ]; then
    cd %{gerrit_site_home}/lib; ln -s %{_javadir}/mysql-connector-java.jar %{gerrit_site_home}/lib/mysql-connector-java.jar 
  fi
fi


%preun
%if 0%{?suse_version}
%stop_on_removal
%else
if [ $1 -eq 0 ]; then
  /sbin/service gerrit stop >/dev/null 2>&1
  /sbin/chkconfig --del gerrit
fi
%endif

%postun
%if 0%{?suse_version}
%insserv_cleanup
%restart_on_update
%endif

%files
%defattr(-,root,root,-)
#%doc COPYING build_date README.markdown
%dir %attr(-,gerrit,gerrit) %{gerrit_home} 
%dir %attr(-,gerrit,gerrit) %{gerrit_home}/.gerritcodereview 
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/bin
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/data
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/etc
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/cache
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/data
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/lib
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/logs
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/plugins
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/static
%dir %attr(-,gerrit,gerrit) %{gerrit_site_home}/tmp
%dir %{_sysconfdir}/gerrit
%dir %attr(-,gerrit,gerrit) %{_sysconfdir}/gerrit/mail
%dir %attr(-,gerrit,gerrit) %{_localstatedir}/log/gerrit
%{_sysconfdir}/init.d/gerrit
%config(noreplace) %{gl_sysconfdir}gerrit
%config(noreplace) %{_sysconfdir}/logrotate.d/%name
#%doc README.markdown
%{gerrit_site_home}/bin/gerrit.war
%dir %attr(-,gerrit,gerrit) %{_localstatedir}/run/gerrit
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif

%changelog