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 7.1.2
18 %define workhorse_version 4.1.0
19 %define pages_version 0.8.1
20 %define gitaly_version 0.96.1
21 Summary: A Web interface to create projects and repositories, manage access and do code reviews
26 Group: Applications/WWW
27 # md5 deliberately omitted until this package is useful
28 Source0: https://gitlab.com/gitlab-org/gitlab-ce/repository/archive.tar.bz2?ref=v%{version}&/%{name}-%{version}.tar.bz2
29 Source1: gitlab.target
30 Source2: gitlab-sidekiq.service
31 Source3: gitlab-sidekiq.init
32 Source4: gitlab-unicorn.service
33 Source5: gitlab-unicorn.init
34 Source6: gitlab.logrotate
35 Source7: gitlab.tmpfiles.d
37 Source9: gitlab-rake.sh
38 Source10: gitlab-rails.sh
39 Source11: gitlab-ctl.sh
40 Source12: clean-vendor.sh
43 Source15: find-lang.sh
45 URL: https://www.gitlab.com/gitlab-ce/
47 BuildRequires: gmp-devel
48 BuildRequires: libgit2-devel
49 BuildRequires: libicu-devel
50 BuildRequires: libstdc++-devel
51 BuildRequires: libxml2-devel
52 BuildRequires: mysql-devel
53 BuildRequires: postgresql-devel
54 BuildRequires: rpm-rubyprov
55 BuildRequires: rpmbuild(macros) >= 1.647
56 BuildRequires: ruby-bundler
57 BuildRequires: ruby-devel >= 1:2.3.5-4
58 BuildRequires: ruby-rubygems >= 2.6.9
59 BuildRequires: yarn >= 1.1.0
60 BuildRequires: zlib-devel
61 Requires(post,preun): /sbin/chkconfig
62 Requires: git-core >= 2.7.4
63 Requires: gitlab-common >= 8.12-2
64 Requires: gitlab-shell >= %{shell_version}
65 Requires: gitlab-workhorse >= %{workhorse_version}
68 Requires: ruby-bundler
69 Requires: systemd-units >= 0.38
72 Suggests: redis-server
73 Obsoletes: gitlab <= 8.1.4
74 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
76 %define find_lang sh %{SOURCE15} %{buildroot}
78 %define _noautoreqfiles redcloth_scan.jar primitives.jar
82 %define appdir %{_prefix}/lib/gitlab
83 %define vardir %{_localstatedir}/lib/gitlab
84 %define cachedir %{_localstatedir}/cache/gitlab
85 %define _webapps /etc/webapps
86 %define _webapp gitlab
89 GitLab Community Edition (CE) is open source software to collaborate
90 on code. Create projects and repositories, manage access and do code
91 reviews. GitLab CE is on-premises software that you can install and
92 use on your server(s).
95 Summary: Manual for GitLab
96 Summary(fr.UTF-8): Documentation pour GitLab
97 Summary(it.UTF-8): Documentazione di GitLab
98 Summary(pl.UTF-8): Podręcznik dla GitLab
100 # noarch subpackages only when building with rpm5
104 Documentation for GitLab.
108 mv gitlab-ce-v%{version}-*/{.??*,*} .
109 mv config/gitlab.yml.example config/gitlab.yml
110 mv config/unicorn.rb.example config/unicorn.rb
114 mv config/database.yml.mysql config/database.yml
116 find -name .gitkeep | xargs rm
119 v=$(cat GITLAB_SHELL_VERSION)
120 test "$v" = "%{shell_version}"
121 v=$(cat GITLAB_WORKHORSE_VERSION)
122 test "$v" = "%{workhorse_version}"
123 v=$(cat GITLAB_PAGES_VERSION)
124 test "$v" = "%{pages_version}"
125 v=$(cat GITALY_SERVER_VERSION)
126 test "$v" = "%{gitaly_version}"
128 %if %{with gem_cache}
129 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
130 install -d vendor/bundle
131 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
134 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
135 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
136 RUBYOPT=--enable-gems \
137 bundle install %{_smp_mflags} \
140 --without development test aws %{!?with_krb5:kerberos}
142 # install webpack deps, used later by rake webpack:compile:
143 # node_modules/.bin/webpack --config config/webpack.config.js --bail
144 # see vendor/bundle/ruby/gems/webpack-rails-0.9.9/lib/tasks/webpack.rake
145 test -d node_modules || \
146 yarn install --pure-lockfile
149 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.17.5+ce.0/config/software/gitlab-rails.rb
150 # use modified config so it doesn't croak
151 cp -p config/gitlab.yml{,.production}
152 sed -i -e '/secret_file:/d' config/gitlab.yml
153 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
154 bundle exec rake RAILS_ENV=production gitlab:assets:clean gitlab:assets:compile USE_DB=false
155 mv -f config/gitlab.yml{.production,}
157 # avoid bogus ruby dep
158 chmod a-x vendor/bundle/ruby/%{ruby_version}/gems/unicorn-*/bin/unicorn*
160 # remove secrets, log and cache that assets compile initialized
161 rm .gitlab_shell_secret
162 cp -f config/secrets.yml{.example,}
163 rm log/production.log
166 %if %{with gem_cache}
167 install -d "$cachedir"
168 cp -aul vendor/bundle/* "$cachedir"
172 rm -rf $RPM_BUILD_ROOT
174 $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
175 $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
176 $RPM_BUILD_ROOT%{appdir}/shared/tmp/project_exports \
177 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
178 $RPM_BUILD_ROOT%{_webapps}/%{_webapp} \
179 $RPM_BUILD_ROOT%{_docdir}/gitlab \
180 $RPM_BUILD_ROOT%{vardir}/public \
181 $RPM_BUILD_ROOT%{cachedir}/tmp \
182 $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
184 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
185 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
187 rm -f $RPM_BUILD_ROOT/VERSION
190 cp -a$l . $RPM_BUILD_ROOT%{appdir}
192 # cleanup unneccessary cruft (gem build files, etc)
193 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
195 %find_lang %{name}.lang
197 # rpm cruft from repackaging
198 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
199 rm -f $RPM_BUILD_ROOT%{appdir}/%{name}.lang
202 mv $RPM_BUILD_ROOT%{appdir}/tmp/sockets/* $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
203 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
204 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
205 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
206 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
208 # move $source to $target leaving symlink in original path
210 local source=$1 target=$2
211 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
212 ln -s $target $RPM_BUILD_ROOT$source
215 # Install config files
216 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
217 move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
219 move_symlink %{appdir}/.gitlab_workhorse_secret %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
221 cp -p %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
222 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
224 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
226 # relocate to /etc as it's updated runtime, see 77cff54
227 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
229 for a in builds shared tmp public/{uploads,assets}; do
230 move_symlink %{appdir}/$a %{vardir}/$a
233 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
234 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
236 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
237 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
239 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
240 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
241 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
242 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
244 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
245 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
246 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab
247 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
248 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
249 install -p %{SOURCE10} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rails
250 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
253 rm -rf $RPM_BUILD_ROOT
256 if [ "$1" = "2" ]; then
257 # Looks like an RPM upgrade
262 /sbin/chkconfig --add gitlab-sidekiq
263 /sbin/chkconfig --add gitlab-unicorn
264 %service gitlab-sidekiq restart
265 %service gitlab-unicorn restart
266 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
268 %banner -e -o %{name} << EOF
270 Create and configure database in %{_sysconfdir}/gitlab/database.yml
273 # gitlab-rake gitlab:setup
278 if [ "$1" = "0" ]; then
279 # Looks like an RPM upgrade
284 if [ "$1" = "0" ]; then
285 %service -q gitlab-sidekiq stop
286 %service -q gitlab-unicorn stop
287 /sbin/chkconfig --del gitlab-sidekiq
288 /sbin/chkconfig --del gitlab-unicorn
290 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
293 if [ $1 -eq 0 ]; then
299 %triggerin -- apache < 2.2.0, apache-base
300 %webapp_register httpd %{_webapp}
302 %triggerun -- apache < 2.2.0, apache-base
303 %webapp_unregister httpd %{_webapp}
305 %files -f %{name}.lang
306 %defattr(644,root,root,755)
308 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
309 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
310 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
311 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
312 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
313 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
314 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
316 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
317 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
319 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
320 %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/gitlab
321 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
322 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
323 %attr(755,root,root) %{_sbindir}/gitlab-ctl
324 %attr(755,root,root) %{_sbindir}/gitlab-rails
325 %attr(755,root,root) %{_sbindir}/gitlab-rake
326 %{systemdunitdir}/gitlab-sidekiq.service
327 %{systemdunitdir}/gitlab-unicorn.service
328 %{systemdunitdir}/gitlab.target
329 %{systemdtmpfilesdir}/gitlab.conf
333 %attr(-,root,root) %{appdir}/bin/*
337 %{appdir}/.gitlab_workhorse_secret
338 %{appdir}/.ruby-version
339 %{appdir}/GITALY_SERVER_VERSION
340 %{appdir}/GITLAB_PAGES_VERSION
341 %{appdir}/GITLAB_SHELL_VERSION
342 %{appdir}/GITLAB_WORKHORSE_VERSION
355 %{appdir}/generator_templates
365 %dir %attr(755,%{uname},%{gname}) %{vardir}/builds
366 %dir %{vardir}/public
367 %attr(-,%{uname},%{gname}) %{vardir}/public/uploads
368 %attr(-,%{uname},%{gname}) %{vardir}/public/assets
369 %dir %attr(755,%{uname},%{gname}) %{vardir}/tmp
370 %attr(-,%{uname},%{gname}) %{vardir}/tmp/backups
372 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sessions
373 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sockets
374 %attr(-,%{uname},%{gname}) %{vardir}/tmp/pids
375 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared
376 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts
377 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp
378 %{vardir}/shared/artifacts/tmp/cache
379 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp/uploads
380 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/lfs-objects
381 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/registry
382 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/pages
383 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/tmp
384 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/tmp/project_exports
386 %dir %attr(750,root,%{gname}) %{cachedir}
387 %attr(-,%{uname},%{gname}) %{cachedir}/cache
388 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
390 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
392 %dir %{appdir}/locale
394 %defattr(-,root,root,-)
395 %dir %{appdir}/vendor
399 %defattr(644,root,root,755)