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 5.3.1
18 %define workhorse_version 2.3.0
19 %define pages_version 0.5.0
20 %define gitaly_version 0.21.2
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
44 URL: https://www.gitlab.com/gitlab-ce/
46 BuildRequires: gmp-devel
47 BuildRequires: libgit2-devel
48 BuildRequires: libicu-devel
49 BuildRequires: libstdc++-devel
50 BuildRequires: libxml2-devel
51 BuildRequires: mysql-devel
52 BuildRequires: postgresql-devel
53 BuildRequires: rpm-rubyprov
54 BuildRequires: rpmbuild(macros) >= 1.647
55 BuildRequires: ruby-bundler
56 BuildRequires: ruby-devel >= 1:2.3.0
57 BuildRequires: yarn >= 0.17.0
58 BuildRequires: zlib-devel
59 Requires(post,preun): /sbin/chkconfig
60 Requires: git-core >= 2.7.4
61 Requires: gitlab-common >= 8.12-2
62 Requires: gitlab-shell >= %{shell_version}
63 Requires: gitlab-workhorse >= %{workhorse_version}
66 Requires: ruby-bundler
67 Requires: systemd-units >= 0.38
70 Suggests: redis-server
71 Obsoletes: gitlab <= 8.1.4
72 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
74 %define _noautoreqfiles redcloth_scan.jar primitives.jar
78 %define appdir %{_prefix}/lib/gitlab
79 %define vardir %{_localstatedir}/lib/gitlab
80 %define cachedir %{_localstatedir}/cache/gitlab
81 %define _webapps /etc/webapps
82 %define _webapp gitlab
85 GitLab Community Edition (CE) is open source software to collaborate
86 on code. Create projects and repositories, manage access and do code
87 reviews. GitLab CE is on-premises software that you can install and
88 use on your server(s).
91 Summary: Manual for GitLab
92 Summary(fr.UTF-8): Documentation pour GitLab
93 Summary(it.UTF-8): Documentazione di GitLab
94 Summary(pl.UTF-8): Podręcznik dla GitLab
96 # noarch subpackages only when building with rpm5
97 %if "%{_rpmversion}" >= "5"
102 Documentation for GitLab.
106 mv gitlab-ce-v%{version}-*/{.??*,*} .
107 mv config/gitlab.yml.example config/gitlab.yml
108 mv config/unicorn.rb.example config/unicorn.rb
112 mv config/database.yml.mysql config/database.yml
114 find -name .gitkeep | xargs rm
117 v=$(cat GITLAB_SHELL_VERSION)
118 test "$v" = "%{shell_version}"
119 v=$(cat GITLAB_WORKHORSE_VERSION)
120 test "$v" = "%{workhorse_version}"
121 v=$(cat GITLAB_PAGES_VERSION)
122 test "$v" = "%{pages_version}"
123 v=$(cat GITALY_SERVER_VERSION)
124 test "$v" = "%{gitaly_version}"
126 %if %{with gem_cache}
127 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
128 install -d vendor/bundle
129 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
132 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
133 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
134 RUBYOPT=--enable-gems \
135 bundle install %{_smp_mflags} \
138 --without development test aws %{!?with_krb5:kerberos}
140 # install webpack deps, used later by rake webpack:compile:
141 # node_modules/.bin/webpack --config config/webpack.config.js --bail
142 # see vendor/bundle/ruby/gems/webpack-rails-0.9.9/lib/tasks/webpack.rake
143 test -d node_modules || \
144 yarn install --pure-lockfile
147 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.17.5+ce.0/config/software/gitlab-rails.rb
148 # use modified config so it doesn't croak
149 cp -p config/gitlab.yml{,.production}
150 sed -i -e '/secret_file:/d' config/gitlab.yml
151 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
152 bundle exec rake RAILS_ENV=production gitlab:assets:clean gitlab:assets:compile USE_DB=false
153 mv -f config/gitlab.yml{.production,}
155 # avoid bogus ruby dep
156 chmod a-x vendor/bundle/ruby/%{ruby_version}/gems/unicorn-*/bin/unicorn*
158 # remove secrets, log and cache that assets compile initialized
159 rm .gitlab_shell_secret
160 cp -f config/secrets.yml{.example,}
161 rm log/production.log
164 %if %{with gem_cache}
165 install -d "$cachedir"
166 cp -aul vendor/bundle/* "$cachedir"
170 rm -rf $RPM_BUILD_ROOT
172 $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
173 $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
174 $RPM_BUILD_ROOT%{appdir}/shared/tmp/project_exports \
175 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
176 $RPM_BUILD_ROOT%{_webapps}/%{_webapp} \
177 $RPM_BUILD_ROOT%{_docdir}/gitlab \
178 $RPM_BUILD_ROOT%{vardir}/public \
179 $RPM_BUILD_ROOT%{cachedir}/tmp \
180 $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
182 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
183 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
185 rm -f $RPM_BUILD_ROOT/VERSION
188 cp -a$l . $RPM_BUILD_ROOT%{appdir}
190 # cleanup unneccessary cruft (gem build files, etc)
191 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
193 # rpm cruft from repackaging
194 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
197 mv $RPM_BUILD_ROOT%{appdir}/tmp/sockets/* $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
198 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
199 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
200 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
201 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
203 # move $source to $target leaving symlink in original path
205 local source=$1 target=$2
206 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
207 ln -s $target $RPM_BUILD_ROOT$source
210 # Install config files
211 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
212 move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
214 move_symlink %{appdir}/.gitlab_workhorse_secret %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
216 cp -p %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
217 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
219 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
221 # relocate to /etc as it's updated runtime, see 77cff54
222 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
224 for a in builds shared tmp public/{uploads,assets}; do
225 move_symlink %{appdir}/$a %{vardir}/$a
228 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
229 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
231 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
232 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
234 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
235 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
236 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
237 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
239 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
240 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
241 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab
242 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
243 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
244 install -p %{SOURCE10} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rails
245 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
248 rm -rf $RPM_BUILD_ROOT
251 if [ "$1" = "2" ]; then
252 # Looks like an RPM upgrade
257 /sbin/chkconfig --add gitlab-sidekiq
258 /sbin/chkconfig --add gitlab-unicorn
259 %service gitlab-sidekiq restart
260 %service gitlab-unicorn restart
261 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
263 %banner -e -o %{name} << EOF
265 Create and configure database in %{_sysconfdir}/gitlab/database.yml
268 # gitlab-rake gitlab:setup
273 if [ "$1" = "0" ]; then
274 # Looks like an RPM upgrade
279 if [ "$1" = "0" ]; then
280 %service -q gitlab-sidekiq stop
281 %service -q gitlab-unicorn stop
282 /sbin/chkconfig --del gitlab-sidekiq
283 /sbin/chkconfig --del gitlab-unicorn
285 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
288 if [ $1 -eq 0 ]; then
294 %triggerin -- apache < 2.2.0, apache-base
295 %webapp_register httpd %{_webapp}
297 %triggerun -- apache < 2.2.0, apache-base
298 %webapp_unregister httpd %{_webapp}
301 %defattr(644,root,root,755)
303 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
304 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
305 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
306 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
307 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
308 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
309 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
311 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
312 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
314 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
315 %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/gitlab
316 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
317 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
318 %attr(755,root,root) %{_sbindir}/gitlab-ctl
319 %attr(755,root,root) %{_sbindir}/gitlab-rails
320 %attr(755,root,root) %{_sbindir}/gitlab-rake
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}/GITALY_SERVER_VERSION
335 %{appdir}/GITLAB_PAGES_VERSION
336 %{appdir}/GITLAB_SHELL_VERSION
337 %{appdir}/GITLAB_WORKHORSE_VERSION
350 %{appdir}/generator_templates
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
375 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/pages
376 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/tmp
377 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/tmp/project_exports
379 %dir %attr(750,root,%{gname}) %{cachedir}
380 %attr(-,%{uname},%{gname}) %{cachedir}/cache
381 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
383 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
385 %defattr(-,root,root,-)
386 %dir %{appdir}/vendor
390 %defattr(644,root,root,755)