2 # This package uses Bundler to download and install all gems in deployment
3 # mode (i.e. into isolated directory inside application). That's not PLD Linux
4 # way how it should be done, but GitLab has too many dependencies that it will
5 # be too difficult to maintain them via distro packages.
7 # install notes: https://gitlab.com/gitlab-org/gitlab-ce/blob/v8.6.6/doc/install/installation.md
10 # - [timfel-krb5-auth] doesn't build with heimdal (https://github.com/timfel/krb5-auth/issues/8)
14 %bcond_with krb5 # build with kerberos support
15 %bcond_without gem_cache # use local to speedup gem installation
17 Summary: A Web interface to create projects and repositories, manage access and do code reviews
22 Group: Applications/WWW
23 # md5 deliberately omitted until this package is useful
24 Source0: https://github.com/gitlabhq/gitlabhq/archive/v%{version}/%{name}-%{version}.tar.gz
25 Source1: gitlab.target
26 Source2: gitlab-sidekiq.service
27 Source3: gitlab-sidekiq.init
28 Source4: gitlab-unicorn.service
29 Source5: gitlab-unicorn.init
30 Source6: gitlab.logrotate
31 Source7: gitlab.tmpfiles.d
32 Source8: gitlab-apache-conf
33 Source9: gitlab-rake.sh
35 Source11: gitlab-ctl.sh
38 Patch2: bug-14972.patch
39 URL: https://www.gitlab.com/gitlab-ce/
41 BuildRequires: gmp-devel
42 BuildRequires: libgit2-devel
43 BuildRequires: libicu-devel
44 BuildRequires: libstdc++-devel
45 BuildRequires: libxml2-devel
46 BuildRequires: mysql-devel
47 BuildRequires: postgresql-devel
48 BuildRequires: rpm-rubyprov
49 BuildRequires: rpmbuild(macros) >= 1.228
50 BuildRequires: ruby-bundler
51 BuildRequires: ruby-devel >= 1:2.1.0
52 BuildRequires: zlib-devel
53 Requires(post,preun): /sbin/chkconfig
55 Requires: git-core >= 2.7.4
56 Requires: gitlab-shell >= 2.7.2
59 Requires: ruby-bundler
61 Suggests: redis-server
62 Obsoletes: gitlab <= 8.1.4
63 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
65 %define _noautoreqfiles redcloth_scan.jar primitives.jar
69 %define homedir %{_localstatedir}/lib/gitlab
72 GitLab Community Edition (CE) is open source software to collaborate
73 on code. Create projects and repositories, manage access and do code
74 reviews. GitLab CE is on-premises software that you can install and
75 use on your server(s).
78 %setup -qn gitlabhq-%{version}
79 mv config/gitlab.yml.example config/gitlab.yml
80 mv config/unicorn.rb.example config/unicorn.rb
86 mv config/database.yml.mysql config/database.yml
88 find -name .gitkeep | xargs rm
91 rm -r lib/support/{deploy,init.d}
108 rm bin/pkgr_before_precompile.sh
109 rm docker-compose.yml
112 %if %{with gem_cache}
113 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
114 install -d vendor/bundle
115 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
118 bundle install %{_smp_mflags} \
121 --without development test aws %{!?with_krb5:kerberos}
123 cp -p config/gitlab.yml{,.production}
124 sed -i -e '/secret_file:/d' config/gitlab.yml
125 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
126 mv -f config/gitlab.yml{.production,}
128 # avoid bogus ruby dep
129 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
131 # remove secrets, log and cache that assets compile initialized
132 rm .gitlab_shell_secret
134 rm config/secrets.yml
135 rm log/production.log
138 %if %{with gem_cache}
139 install -d "$cachedir"
140 cp -aul vendor/bundle/* "$cachedir"
144 rm -rf $RPM_BUILD_ROOT
146 $RPM_BUILD_ROOT%{homedir}/www \
147 $RPM_BUILD_ROOT%{homedir}/public/{assets,uploads} \
148 $RPM_BUILD_ROOT%{homedir}/satellites \
149 $RPM_BUILD_ROOT%{homedir}/tmp/{cache/assets,sessions,backups} \
150 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
151 $RPM_BUILD_ROOT%{_docdir}/gitlab \
152 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
154 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
155 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
157 rm -f $RPM_BUILD_ROOT/VERSION
160 cp -a$l . $RPM_BUILD_ROOT%{homedir}
162 # rpm cruft from repackaging
163 rm -f $RPM_BUILD_ROOT%{homedir}/debug*.list
166 chmod -R u+w $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
167 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
170 rmdir $RPM_BUILD_ROOT%{homedir}/{log,tmp/{pids,sockets}}
171 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/pids
172 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/sockets
173 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{homedir}/log
176 local source=$1 target=$2
177 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
178 ln -s $target $RPM_BUILD_ROOT$source
181 # Install config files
182 for f in gitlab.yml unicorn.rb database.yml; do
183 move_config %{homedir}/config/$f %{_sysconfdir}/gitlab/$f
186 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
187 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
189 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
190 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
191 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
192 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
194 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
195 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
196 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
197 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
198 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{homedir}/.gitconfig
199 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
200 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
203 rm -rf "$RPM_BUILD_ROOT"
206 /sbin/chkconfig --add gitlab-sidekiq
207 /sbin/chkconfig --add gitlab-unicorn
208 %service gitlab-sidekiq restart
209 %service gitlab-unicorn restart
211 if [ $1 -ge 1 ]; then
212 systemctl -q daemon-reload
213 systemd-tmpfiles --create %{systemdtmpfilesdir}/gitlab.conf
214 [ -e %{_localstatedir}/lock/subsys/httpd ] && service httpd reload || :
216 if [ $1 -eq 1 ]; then
217 systemctl -q enable gitlab-unicorn
218 systemctl -q enable gitlab-sidekiq
219 systemctl -q enable gitlab.target
220 systemctl -q start gitlab-unicorn
221 systemctl -q start gitlab-sidekiq
222 systemctl -q start gitlab.target
223 echo "Create and configure database in /etc/gitlab/database.yml"
224 echo "Then run 'sudo -u gitlab bundle exec rake gitlab:setup RAILS_ENV=production'"
227 systemctl -q try-restart gitlab-unicorn || :
228 systemctl -q try-start gitlab-sidekiq || :
232 if [ "$1" = "0" ]; then
233 %service -q gitlab-sidekiq stop
234 %service -q gitlab-unicorn stop
235 /sbin/chkconfig --del gitlab-sidekiq
236 /sbin/chkconfig --del gitlab-unicorn
240 if [ $1 -eq 0 ]; then
246 %defattr(644,root,root,755)
248 %config(noreplace) %{_sysconfdir}/gitlab/database.yml
249 %config(noreplace) %{_sysconfdir}/gitlab/gitlab.yml
250 %config(noreplace) %{_sysconfdir}/gitlab/unicorn.rb
251 %config(noreplace) %{_sysconfdir}/httpd/webapps.d/gitlab.conf
252 /etc/logrotate.d/gitlab.logrotate
253 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
254 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
255 %attr(755,root,root) %{_sbindir}/gitlab-rake
256 %attr(755,root,root) %{_sbindir}/gitlab-ctl
257 %{systemdunitdir}/gitlab-sidekiq.service
258 %{systemdunitdir}/gitlab-unicorn.service
259 %{systemdunitdir}/gitlab.target
260 %{systemdtmpfilesdir}/gitlab.conf
261 %dir %attr(755,%{uname},%{gname}) %{homedir}
262 %dir %attr(640,%{uname},%{gname}) %{homedir}/.gitconfig
263 %dir %attr(755,%{uname},%{gname}) %{homedir}/app
264 %attr(-,%{uname},%{gname}) %{homedir}/app/*
265 %dir %attr(755,%{uname},%{gname}) %{homedir}/bin
266 %attr(-,%{uname},%{gname}) %{homedir}/bin/*
267 %dir %attr(755,%{uname},%{gname}) %{homedir}/builds
268 %dir %attr(755,%{uname},%{gname}) %{homedir}/config
269 %attr(-,%{uname},%{gname}) %{homedir}/config/*
270 %dir %attr(755,%{uname},%{gname}) %{homedir}/db
271 %attr(-,%{uname},%{gname}) %{homedir}/db/*
272 %dir %attr(755,%{uname},%{gname}) %{homedir}/doc
273 %attr(-,%{uname},%{gname}) %{homedir}/doc/*
274 %dir %attr(755,%{uname},%{gname}) %{homedir}/lib
275 %attr(-,%{uname},%{gname}) %{homedir}/lib/*
278 %{homedir}/generator_templates
280 %dir %{homedir}/public
282 %{homedir}/public/*.*
283 %attr(-,%{uname},%{gname}) %{homedir}/public/uploads
284 %attr(-,%{uname},%{gname}) %{homedir}/public/assets
285 %dir %attr(755,%{uname},%{gname}) %{homedir}/satellites
287 %dir %attr(755,%{uname},%{gname}) %{homedir}/tmp
288 %attr(-,%{uname},%{gname}) %{homedir}/tmp/backups
289 %attr(-,%{uname},%{gname}) %{homedir}/tmp/cache
290 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sessions
291 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sockets
292 %attr(-,%{uname},%{gname}) %{homedir}/tmp/pids
294 %dir %attr(755,%{uname},%{gname}) %{homedir}/www
296 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared
297 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts
298 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp
299 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/cache
300 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/uploads
301 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/lfs-objects
302 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/registry
304 %dir %attr(755,%{uname},%{gname}) %{homedir}/.bundle
305 %attr(-,%{uname},%{gname}) %{homedir}/.bundle/config
306 %attr(-,%{uname},%{gname}) %{homedir}/.ruby-version
307 %attr(-,%{uname},%{gname}) %{homedir}/CHANGELOG
308 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_WORKHORSE_VERSION
309 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_SHELL_VERSION
310 %attr(-,%{uname},%{gname}) %{homedir}/Gemfile*
311 %attr(-,%{uname},%{gname}) %{homedir}/LICENSE
312 %attr(-,%{uname},%{gname}) %{homedir}/*.md
313 %attr(-,%{uname},%{gname}) %{homedir}/Rakefile
314 %attr(-,%{uname},%{gname}) %{homedir}/VERSION
315 %attr(-,%{uname},%{gname}) %{homedir}/config.ru
318 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
319 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
321 %defattr(-,root,root,-)
322 %dir %{homedir}/vendor