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 3.6.0
18 %define workhorse_version 0.8.2
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://github.com/gitlabhq/gitlabhq/archive/v%{version}/%{name}-%{version}.tar.gz
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 URL: https://www.gitlab.com/gitlab-ce/
44 BuildRequires: gmp-devel
45 BuildRequires: libgit2-devel
46 BuildRequires: libicu-devel
47 BuildRequires: libstdc++-devel
48 BuildRequires: libxml2-devel
49 BuildRequires: mysql-devel
50 BuildRequires: postgresql-devel
51 BuildRequires: rpm-rubyprov
52 BuildRequires: rpmbuild(macros) >= 1.647
53 BuildRequires: ruby-bundler
54 BuildRequires: ruby-devel >= 1:2.1.0
55 BuildRequires: zlib-devel
56 Requires(post,preun): /sbin/chkconfig
58 Requires: git-core >= 2.7.4
59 Requires: gitlab-common >= 8.12
60 Requires: gitlab-shell >= %{shell_version}
61 Requires: gitlab-workhorse >= %{workhorse_version}
64 Requires: ruby-bundler
65 Requires: systemd-units >= 0.38
67 Suggests: redis-server
68 Obsoletes: gitlab <= 8.1.4
69 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
71 %define _noautoreqfiles redcloth_scan.jar primitives.jar
75 %define appdir %{_prefix}/lib/gitlab
76 %define vardir %{_localstatedir}/lib/gitlab
77 %define cachedir %{_localstatedir}/cache/gitlab
80 GitLab Community Edition (CE) is open source software to collaborate
81 on code. Create projects and repositories, manage access and do code
82 reviews. GitLab CE is on-premises software that you can install and
83 use on your server(s).
86 Summary: Manual for GitLab
87 Summary(fr.UTF-8): Documentation pour GitLab
88 Summary(it.UTF-8): Documentazione di GitLab
89 Summary(pl.UTF-8): Podręcznik dla GitLab
91 # noarch subpackages only when building with rpm5
92 %if "%{_rpmversion}" >= "5"
97 Documentation for GitLab.
100 %setup -qn gitlabhq-%{version}
101 mv config/gitlab.yml.example config/gitlab.yml
102 mv config/unicorn.rb.example config/unicorn.rb
107 mv config/database.yml.mysql config/database.yml
109 find -name .gitkeep | xargs rm
112 v=$(cat GITLAB_SHELL_VERSION)
113 test "$v" = "%{shell_version}"
114 v=$(cat GITLAB_WORKHORSE_VERSION)
115 test "$v" = "%{workhorse_version}"
117 %if %{with gem_cache}
118 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
119 install -d vendor/bundle
120 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
123 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
124 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
125 RUBYOPT=--enable-gems \
126 bundle install %{_smp_mflags} \
129 --without development test aws %{!?with_krb5:kerberos}
131 # install newer rugged to fix diff view showing garbage
132 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
134 test -d vendor/bundle/ruby/gems/rugged-$v || \
135 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
138 # use modified config so it doesn't croak
139 cp -p config/gitlab.yml{,.production}
140 sed -i -e '/secret_file:/d' config/gitlab.yml
141 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
142 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
143 mv -f config/gitlab.yml{.production,}
145 # avoid bogus ruby dep
146 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
148 # remove secrets, log and cache that assets compile initialized
149 rm .gitlab_shell_secret
150 cp -f config/secrets.yml{.example,}
151 rm log/production.log
154 %if %{with gem_cache}
155 install -d "$cachedir"
156 cp -aul vendor/bundle/* "$cachedir"
160 rm -rf $RPM_BUILD_ROOT
162 $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
163 $RPM_BUILD_ROOT%{appdir}/satellites \
164 $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
165 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
166 $RPM_BUILD_ROOT%{_docdir}/gitlab \
167 $RPM_BUILD_ROOT%{vardir}/public \
168 $RPM_BUILD_ROOT%{cachedir}/tmp \
169 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
171 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
172 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
174 rm -f $RPM_BUILD_ROOT/VERSION
177 cp -a$l . $RPM_BUILD_ROOT%{appdir}
179 # cleanup unneccessary cruft (gem build files, etc)
180 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
182 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
185 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
186 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
187 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-$ov
188 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
190 # rpm cruft from repackaging
191 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
194 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
195 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
196 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
197 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
199 # move $source to $target leaving symlink in original path
201 local source=$1 target=$2
202 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
203 ln -s $target $RPM_BUILD_ROOT$source
206 # Install config files
207 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
208 move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
210 move_symlink %{appdir}/.gitlab_workhorse_secret %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
212 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
213 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
215 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
217 # relocate to /etc as it's updated runtime, see 77cff54
218 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
220 for a in satellites builds shared tmp public/{uploads,assets}; do
221 move_symlink %{appdir}/$a %{vardir}/$a
224 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
225 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
227 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
228 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
230 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
231 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
232 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
233 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
235 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
236 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
237 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
238 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
239 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
240 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
243 rm -rf $RPM_BUILD_ROOT
246 if [ "$1" = "2" ]; then
247 # Looks like an RPM upgrade
252 /sbin/chkconfig --add gitlab-sidekiq
253 /sbin/chkconfig --add gitlab-unicorn
254 %service gitlab-sidekiq restart
255 %service gitlab-unicorn restart
256 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
258 %banner -e -o %{name} << EOF
260 Create and configure database in %{_sysconfdir}/gitlab/database.yml
263 # gitlab-rake gitlab:setup
268 if [ "$1" = "0" ]; then
269 # Looks like an RPM upgrade
274 if [ "$1" = "0" ]; then
275 %service -q gitlab-sidekiq stop
276 %service -q gitlab-unicorn stop
277 /sbin/chkconfig --del gitlab-sidekiq
278 /sbin/chkconfig --del gitlab-unicorn
280 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
283 if [ $1 -eq 0 ]; then
290 %defattr(644,root,root,755)
292 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
293 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
294 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
295 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
296 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
297 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
298 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
300 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
301 %config(noreplace) %verify(not md5 mtime size) /etc/httpd/webapps.d/gitlab.conf
302 /etc/logrotate.d/gitlab.logrotate
303 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
304 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
305 %attr(755,root,root) %{_sbindir}/gitlab-rake
306 %attr(755,root,root) %{_sbindir}/gitlab-ctl
307 %{systemdunitdir}/gitlab-sidekiq.service
308 %{systemdunitdir}/gitlab-unicorn.service
309 %{systemdunitdir}/gitlab.target
310 %{systemdtmpfilesdir}/gitlab.conf
314 %attr(-,root,root) %{appdir}/bin/*
318 %{appdir}/.gitlab_workhorse_secret
319 %{appdir}/.ruby-version
321 %{appdir}/GITLAB_SHELL_VERSION
322 %{appdir}/GITLAB_WORKHORSE_VERSION
335 %{appdir}/generator_templates
344 %dir %attr(755,%{uname},%{gname}) %{vardir}/satellites
345 %dir %attr(755,%{uname},%{gname}) %{vardir}/builds
346 %dir %{vardir}/public
347 %attr(-,%{uname},%{gname}) %{vardir}/public/uploads
348 %attr(-,%{uname},%{gname}) %{vardir}/public/assets
349 %dir %attr(755,%{uname},%{gname}) %{vardir}/tmp
350 %attr(-,%{uname},%{gname}) %{vardir}/tmp/backups
352 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sessions
353 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sockets
354 %attr(-,%{uname},%{gname}) %{vardir}/tmp/pids
355 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared
356 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts
357 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp
358 %{vardir}/shared/artifacts/tmp/cache
359 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp/uploads
360 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/lfs-objects
361 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/registry
363 %dir %attr(750,root,%{gname}) %{cachedir}
364 %attr(-,%{uname},%{gname}) %{cachedir}/cache
365 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
367 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
368 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
370 %defattr(-,root,root,-)
371 %dir %{appdir}/vendor
375 %defattr(644,root,root,755)