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 cache to speedup gem installation
17 %define shell_version 4.0.0
18 %define workhorse_version 1.0.1
19 Summary: A Web interface to create projects and repositories, manage access and do code reviews
24 Group: Applications/WWW
25 # md5 deliberately omitted until this package is useful
26 Source0: https://gitlab.com/gitlab-org/gitlab-ce/repository/archive.tar.bz2?ref=v%{version}&/%{name}-%{version}.tar.bz2
27 Source1: gitlab.target
28 Source2: gitlab-sidekiq.service
29 Source3: gitlab-sidekiq.init
30 Source4: gitlab-unicorn.service
31 Source5: gitlab-unicorn.init
32 Source6: gitlab.logrotate
33 Source7: gitlab.tmpfiles.d
35 Source9: gitlab-rake.sh
37 Source11: gitlab-ctl.sh
38 Source12: clean-vendor.sh
42 Patch2: post_receive-any-email.patch
43 URL: https://www.gitlab.com/gitlab-ce/
45 BuildRequires: gmp-devel
46 BuildRequires: libgit2-devel
47 BuildRequires: libicu-devel
48 BuildRequires: libstdc++-devel
49 BuildRequires: libxml2-devel
50 BuildRequires: mysql-devel
51 BuildRequires: postgresql-devel
52 BuildRequires: rpm-rubyprov
53 BuildRequires: rpmbuild(macros) >= 1.647
54 BuildRequires: ruby-bundler
55 BuildRequires: ruby-devel >= 1:2.1.0
56 BuildRequires: zlib-devel
57 Requires(post,preun): /sbin/chkconfig
58 Requires: git-core >= 2.7.4
59 Requires: gitlab-common >= 8.12-2
60 Requires: gitlab-shell >= %{shell_version}
61 Requires: gitlab-workhorse >= %{workhorse_version}
64 Requires: ruby-bundler
65 Requires: systemd-units >= 0.38
68 Suggests: redis-server
69 Obsoletes: gitlab <= 8.1.4
70 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
72 %define _noautoreqfiles redcloth_scan.jar primitives.jar
76 %define appdir %{_prefix}/lib/gitlab
77 %define vardir %{_localstatedir}/lib/gitlab
78 %define cachedir %{_localstatedir}/cache/gitlab
79 %define _webapps /etc/webapps
80 %define _webapp gitlab
83 GitLab Community Edition (CE) is open source software to collaborate
84 on code. Create projects and repositories, manage access and do code
85 reviews. GitLab CE is on-premises software that you can install and
86 use on your server(s).
89 Summary: Manual for GitLab
90 Summary(fr.UTF-8): Documentation pour GitLab
91 Summary(it.UTF-8): Documentazione di GitLab
92 Summary(pl.UTF-8): Podręcznik dla GitLab
94 # noarch subpackages only when building with rpm5
95 %if "%{_rpmversion}" >= "5"
100 Documentation for GitLab.
104 mv gitlab-ce-v%{version}-*/{.??*,*} .
105 mv config/gitlab.yml.example config/gitlab.yml
106 mv config/unicorn.rb.example config/unicorn.rb
112 mv config/database.yml.mysql config/database.yml
114 find -name .gitkeep | xargs rm
116 v=$(cat GITLAB_SHELL_VERSION)
117 test "$v" = "%{shell_version}"
118 v=$(cat GITLAB_WORKHORSE_VERSION)
119 test "$v" = "%{workhorse_version}"
122 %if %{with gem_cache}
123 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
124 install -d vendor/bundle
125 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
128 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
129 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
130 RUBYOPT=--enable-gems \
131 bundle install %{_smp_mflags} \
134 --without development test aws %{!?with_krb5:kerberos}
136 # install newer rugged to fix diff view showing garbage
137 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
139 test -d vendor/bundle/ruby/gems/rugged-$v || \
140 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
143 # use modified config so it doesn't croak
144 cp -p config/gitlab.yml{,.production}
145 sed -i -e '/secret_file:/d' config/gitlab.yml
146 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
147 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
148 mv -f config/gitlab.yml{.production,}
150 # avoid bogus ruby dep
151 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
153 # remove secrets, log and cache that assets compile initialized
154 rm .gitlab_shell_secret
155 cp -f config/secrets.yml{.example,}
156 rm log/production.log
159 %if %{with gem_cache}
160 install -d "$cachedir"
161 cp -aul vendor/bundle/* "$cachedir"
165 rm -rf $RPM_BUILD_ROOT
167 $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
168 $RPM_BUILD_ROOT%{appdir}/satellites \
169 $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
170 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
171 $RPM_BUILD_ROOT%{_webapps}/%{_webapp} \
172 $RPM_BUILD_ROOT%{_docdir}/gitlab \
173 $RPM_BUILD_ROOT%{vardir}/public \
174 $RPM_BUILD_ROOT%{cachedir}/tmp \
175 $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
177 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
178 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
180 rm -f $RPM_BUILD_ROOT/VERSION
183 cp -a$l . $RPM_BUILD_ROOT%{appdir}
185 # cleanup unneccessary cruft (gem build files, etc)
186 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
188 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
191 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
192 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
193 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-$ov
194 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
196 # rpm cruft from repackaging
197 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
200 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
201 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
202 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
203 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
205 # move $source to $target leaving symlink in original path
207 local source=$1 target=$2
208 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
209 ln -s $target $RPM_BUILD_ROOT$source
212 # Install config files
213 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
214 move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
216 move_symlink %{appdir}/.gitlab_workhorse_secret %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
218 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
219 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
221 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
223 # relocate to /etc as it's updated runtime, see 77cff54
224 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
226 for a in satellites builds shared tmp public/{uploads,assets}; do
227 move_symlink %{appdir}/$a %{vardir}/$a
230 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
231 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
233 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
234 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
236 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
237 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
238 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
239 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
241 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
242 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
243 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab
244 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
245 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
246 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
249 rm -rf $RPM_BUILD_ROOT
252 if [ "$1" = "2" ]; then
253 # Looks like an RPM upgrade
258 /sbin/chkconfig --add gitlab-sidekiq
259 /sbin/chkconfig --add gitlab-unicorn
260 %service gitlab-sidekiq restart
261 %service gitlab-unicorn restart
262 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
264 %banner -e -o %{name} << EOF
266 Create and configure database in %{_sysconfdir}/gitlab/database.yml
269 # gitlab-rake gitlab:setup
274 if [ "$1" = "0" ]; then
275 # Looks like an RPM upgrade
280 if [ "$1" = "0" ]; then
281 %service -q gitlab-sidekiq stop
282 %service -q gitlab-unicorn stop
283 /sbin/chkconfig --del gitlab-sidekiq
284 /sbin/chkconfig --del gitlab-unicorn
286 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
289 if [ $1 -eq 0 ]; then
295 %triggerin -- apache < 2.2.0, apache-base
296 %webapp_register httpd %{_webapp}
298 %triggerun -- apache < 2.2.0, apache-base
299 %webapp_unregister httpd %{_webapp}
302 %defattr(644,root,root,755)
304 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
305 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
306 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
307 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
308 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
309 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
310 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
312 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
313 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
315 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
316 /etc/logrotate.d/gitlab
317 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
318 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
319 %attr(755,root,root) %{_sbindir}/gitlab-rake
320 %attr(755,root,root) %{_sbindir}/gitlab-ctl
321 %{systemdunitdir}/gitlab-sidekiq.service
322 %{systemdunitdir}/gitlab-unicorn.service
323 %{systemdunitdir}/gitlab.target
324 %{systemdtmpfilesdir}/gitlab.conf
328 %attr(-,root,root) %{appdir}/bin/*
332 %{appdir}/.gitlab_workhorse_secret
333 %{appdir}/.ruby-version
334 %{appdir}/GITLAB_SHELL_VERSION
335 %{appdir}/GITLAB_WORKHORSE_VERSION
348 %{appdir}/generator_templates
357 %dir %attr(755,%{uname},%{gname}) %{vardir}/satellites
358 %dir %attr(755,%{uname},%{gname}) %{vardir}/builds
359 %dir %{vardir}/public
360 %attr(-,%{uname},%{gname}) %{vardir}/public/uploads
361 %attr(-,%{uname},%{gname}) %{vardir}/public/assets
362 %dir %attr(755,%{uname},%{gname}) %{vardir}/tmp
363 %attr(-,%{uname},%{gname}) %{vardir}/tmp/backups
365 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sessions
366 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sockets
367 %attr(-,%{uname},%{gname}) %{vardir}/tmp/pids
368 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared
369 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts
370 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp
371 %{vardir}/shared/artifacts/tmp/cache
372 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp/uploads
373 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/lfs-objects
374 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/registry
376 %dir %attr(750,root,%{gname}) %{cachedir}
377 %attr(-,%{uname},%{gname}) %{cachedir}/cache
378 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
380 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
382 %defattr(-,root,root,-)
383 %dir %{appdir}/vendor
387 %defattr(644,root,root,755)