File gitorious.spec of Package gitorious

Name:           gitorious
Version:        0.9
Release:        1
License:        AGPLv3
Source0:        gitorious.tar.bz2
Source1:        gitorious-git-daemon.init
Source2:        gitorious-poller.init
Source3:        gitorious-ultrasphinx.init
Source4:        sysconfig.gitorious
Source5:        gitorious-setup-1st-time
Source6:        logo-cube-text.png
Group:          Development/Tools/Version Control
Summary:        Web based code collaboration
PreReq:         %insserv_prereq %fillup_prereq
BuildRequires:  sed
Requires:       logrotate

PreReq:         apache2-prefork
Requires:       rubygem-passenger

Requires:       activemq

Requires:       aspell
Recommends:     aspell-en
Requires:       git
Requires:       git-core
Requires:       ImageMagick
Requires:       libcurl4
Requires:       mysql
Requires:       ruby-mysql
Requires:       rubygem-archive-tar-minitar
Requires:       rubygem-chronic
Requires:       rubygem-daemons
Requires:       rubygem-diff-lcs
Requires:       rubygem-echoe
Requires:       rubygem-fastthread
Requires:       rubygem-geoip
Requires:       rubygem-highline
Requires:       rubygem-json
Requires:       rubygem-mime-types
Requires:       rubygem-nokogiri
Requires:       rubygem-oauth
Requires:       rubygem-rack
Requires:       rubygem-rake
Requires:       rubygem-rdiscount
Requires:       rubygem-RedCloth
Requires:       rubygem-ruby-hmac
Requires:       rubygem-ruby-openid
Requires:       rubygem-ruby-yadis

Requires:       rubygem-stomp
Requires:       rubygem-rmagick

Requires:       memcached

Requires:       sphinx
BuildRequires:  sphinx

Prereq:         rubygem-rails-2_3 >= 2.3.3
BuildRequires:  rubygem-rails-2_3 >= 2.3.3
# we need hostname to configure, and dd for generating random string
BuildRequires:  net-tools coreutils gawk
# required by rpm build to check symbols in JsTestDriver-1.0b.jar
BuildRequires:  fastjar

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Gitorious aims to provide a great way of doing distributed opensource code collaboration.

%prep
%setup -q -n gitorious

%build

%install

# clean crap
find . -name "*.*~" | xargs rm
find . -name "*.bak" | xargs rm
find -name ".git*" | xargs rm

# more crap
sed -i 's,/usr/local/bin/ruby,/usr/bin/env ruby,g' vendor/plugins/ultrasphinx/test/integration/app/public/dispatch.*
sed -i 's,/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby,/usr/bin/env ruby,g' public/dispatch.*

# move the files to a FHS std location
mkdir -p %{buildroot}/srv/www/gitorious
cp -R * %{buildroot}/srv/www/gitorious

# remove the jar file for testing as the build service does not like it
rm -f %{buildroot}/srv/www/gitorious/test/javascripts/JsTestDriver.jar

# replace the standard logo
rm -f %{buildroot}/srv/www/gitorious/public/images/logo-cube-text.png
cp %{SOURCE6} %{buildroot}/srv/www/gitorious/public/images

# add the init files
mkdir -p %{buildroot}/etc/init.d
%{__install} -m 755 %{SOURCE1} %{buildroot}/etc/init.d/gitorious-git-daemon
%{__install} -m 755 %{SOURCE2} %{buildroot}/etc/init.d/gitorious-poller
%{__install} -m 755 %{SOURCE3} %{buildroot}/etc/init.d/gitorious-ultrasphinx

%{__mkdir_p} %{buildroot}/%{_sbindir}
ln -sf %{_sysconfdir}/init.d/gitorious-git-daemon %{buildroot}/%{_sbindir}/rcgitorious-git-daemon
ln -sf %{_sysconfdir}/init.d/gitorious-poller %{buildroot}/%{_sbindir}/rcgitorious-poller
ln -sf %{_sysconfdir}/init.d/gitorious-ultrasphinx %{buildroot}/%{_sbindir}/rcgitorious-ultrasphinx

# fix sphinx binaries
%{__mkdir_p} %{buildroot}%{_bindir}
%{__ln_s} %{_bindir}/sphinx-searchd %{buildroot}%{_bindir}/searchd
%{__ln_s} %{_bindir}/sphinx-indexer %{buildroot}%{_bindir}/indexer

# make the gitorious client available in the path
%{__ln_s} /srv/www/gitorious/script/gitorious %{buildroot}%{_bindir}/gitorious

%{__mkdir_p} %{buildroot}%{_localstatedir}/adm/fillup-templates
%{__install} -m 644 %{SOURCE4}  %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.gitorious

# create the repositories directory
%{__mkdir_p} %{buildroot}/srv/git

# configure the instance
cat > %{buildroot}/srv/www/gitorious/config/gitorious.yml <<EOF
production:
  cookie_secret:
  repository_base_path: "/srv/git"
  extra_html_head_data:
  system_message:
  gitorious_client_port: 3000
  gitorious_client_host: localhost
  gitorious_host:
  gitorious_user: git
  exception_notification_emails:
  mangle_email_addresses: false
  public_mode: true
  locale: en
  archive_cache_dir: "/var/cache/gitorious/tarballs"
  archive_work_dir: "/var/tmp/gitorious/tarballs"
  only_site_admins_can_create_projects: false
  hide_http_clone_urls: false
  is_gitorious_dot_org: false
EOF

cat > %{buildroot}/srv/www/gitorious/config/broker.yml <<EOF
production:
    adapter: stomp
EOF

# install the first time configuration tool
%{__mkdir_p} %{buildroot}%{_bindir}
%{__install} -m 755 %{SOURCE5} %{buildroot}%{_bindir}/gitorious-setup-1st-time

%clean
rm -rf %buildroot

%pre
/usr/sbin/useradd -d /srv/git --system -c "git daemon" -s /bin/bash git &>/dev/null ||:

%post
%fillup_only
#%{insserv gitorious-git-daemon}
#%{insserv gitorious-poller}
#%{insserv gitorious-ultrasphinx}

%preun
%stop_on_removal gitorious-git-daemon gitorious-poller gitorious-ultrasphinx

%postun
%restart_on_update gitorious-git-daemon gitorious-poller gitorious-ultrasphinx
%insserv_cleanup

%files
%defattr(-,root,root)
%doc TODO.txt HACKING LICENSE AUTHORS README
%attr(-,git,root) /srv/www/gitorious
%config(noreplace) /srv/www/gitorious/config/gitorious.yml
%config(noreplace) /srv/www/gitorious/config/broker.yml
%{_bindir}/gitorious-setup-1st-time
%dir %attr(-,git,root) /srv/git
%{_sbindir}/rcgitorious-*
%{_bindir}/indexer
%{_bindir}/searchd
%{_bindir}/gitorious
%{_sysconfdir}/init.d/gitorious-*
%{_localstatedir}/adm/fillup-templates/sysconfig.gitorious

%changelog