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 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
33 Source9: gitlab-rake.sh
35 Source11: gitlab-ctl.sh
36 Source12: clean-vendor.sh
40 URL: https://www.gitlab.com/gitlab-ce/
42 BuildRequires: gmp-devel
43 BuildRequires: libgit2-devel
44 BuildRequires: libicu-devel
45 BuildRequires: libstdc++-devel
46 BuildRequires: libxml2-devel
47 BuildRequires: mysql-devel
48 BuildRequires: postgresql-devel
49 BuildRequires: rpm-rubyprov
50 BuildRequires: rpmbuild(macros) >= 1.647
51 BuildRequires: ruby-bundler
52 BuildRequires: ruby-devel >= 1:2.1.0
53 BuildRequires: zlib-devel
54 Requires(post,preun): /sbin/chkconfig
56 Requires: git-core >= 2.7.4
57 Requires: gitlab-shell >= 3.4.0
58 Requires: gitlab-workhorse >= 0.7.11
61 Requires: ruby-bundler
62 Requires: systemd-units >= 0.38
64 Suggests: redis-server
65 Obsoletes: gitlab <= 8.1.4
66 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
68 %define _noautoreqfiles redcloth_scan.jar primitives.jar
72 %define appdir %{_prefix}/lib/gitlab
73 %define vardir %{_localstatedir}/lib/gitlab
74 %define cachedir %{_localstatedir}/cache/gitlab
77 GitLab Community Edition (CE) is open source software to collaborate
78 on code. Create projects and repositories, manage access and do code
79 reviews. GitLab CE is on-premises software that you can install and
80 use on your server(s).
83 Summary: Manual for GitLab
84 Summary(fr.UTF-8): Documentation pour GitLab
85 Summary(it.UTF-8): Documentazione di GitLab
86 Summary(pl.UTF-8): Podręcznik dla GitLab
88 # noarch subpackages only when building with rpm5
89 %if "%{_rpmversion}" >= "5"
94 Documentation for GitLab.
97 %setup -qn gitlabhq-%{version}
98 mv config/gitlab.yml.example config/gitlab.yml
99 mv config/unicorn.rb.example config/unicorn.rb
104 mv config/database.yml.mysql config/database.yml
106 find -name .gitkeep | xargs rm
109 %if %{with gem_cache}
110 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
111 install -d vendor/bundle
112 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
115 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
116 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
117 RUBYOPT=--enable-gems \
118 bundle install %{_smp_mflags} \
121 --without development test aws %{!?with_krb5:kerberos}
123 # install newer rugged to fix diff view showing garbage
124 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
126 test -d vendor/bundle/ruby/gems/rugged-$v || \
127 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
130 # use modified config so it doesn't croak
131 cp -p config/gitlab.yml{,.production}
132 sed -i -e '/secret_file:/d' config/gitlab.yml
133 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
134 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
135 mv -f config/gitlab.yml{.production,}
137 # avoid bogus ruby dep
138 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
140 # remove secrets, log and cache that assets compile initialized
141 rm .gitlab_shell_secret
142 cp -f config/secrets.yml{.example,}
143 rm log/production.log
146 %if %{with gem_cache}
147 install -d "$cachedir"
148 cp -aul vendor/bundle/* "$cachedir"
152 rm -rf $RPM_BUILD_ROOT
154 $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
155 $RPM_BUILD_ROOT%{appdir}/satellites \
156 $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
157 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
158 $RPM_BUILD_ROOT%{_docdir}/gitlab \
159 $RPM_BUILD_ROOT%{vardir}/public \
160 $RPM_BUILD_ROOT%{cachedir}/tmp \
161 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
163 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
164 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
166 rm -f $RPM_BUILD_ROOT/VERSION
169 cp -a$l . $RPM_BUILD_ROOT%{appdir}
171 # cleanup unneccessary cruft (gem build files, etc)
172 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
174 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
177 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
178 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
179 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-$ov
180 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
182 # rpm cruft from repackaging
183 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
186 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
187 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
188 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
189 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
191 # move $source to $target leaving symlink in original path
193 local source=$1 target=$2
194 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
195 ln -s $target $RPM_BUILD_ROOT$source
198 # Install config files
199 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
200 move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
203 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
204 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
206 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
208 # relocate to /etc as it's updated runtime, see 77cff54
209 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
211 for a in satellites builds shared tmp public/{uploads,assets}; do
212 move_symlink %{appdir}/$a %{vardir}/$a
215 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
216 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
218 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
219 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
221 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
222 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
223 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
224 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
226 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
227 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
228 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
229 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
230 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
231 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
234 rm -rf $RPM_BUILD_ROOT
237 if [ "$1" = "2" ]; then
238 # Looks like an RPM upgrade
243 /sbin/chkconfig --add gitlab-sidekiq
244 /sbin/chkconfig --add gitlab-unicorn
245 %service gitlab-sidekiq restart
246 %service gitlab-unicorn restart
247 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
249 %banner -e -o %{name} << EOF
251 Create and configure database in %{_sysconfdir}/gitlab/database.yml
254 # gitlab-rake gitlab:setup
259 if [ "$1" = "0" ]; then
260 # Looks like an RPM upgrade
265 if [ "$1" = "0" ]; then
266 %service -q gitlab-sidekiq stop
267 %service -q gitlab-unicorn stop
268 /sbin/chkconfig --del gitlab-sidekiq
269 /sbin/chkconfig --del gitlab-unicorn
271 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
274 if [ $1 -eq 0 ]; then
281 %defattr(644,root,root,755)
283 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
284 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
285 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
286 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
287 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
288 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
289 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
290 %config(noreplace) %verify(not md5 mtime size) /etc/httpd/webapps.d/gitlab.conf
291 /etc/logrotate.d/gitlab.logrotate
292 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
293 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
294 %attr(755,root,root) %{_sbindir}/gitlab-rake
295 %attr(755,root,root) %{_sbindir}/gitlab-ctl
296 %{systemdunitdir}/gitlab-sidekiq.service
297 %{systemdunitdir}/gitlab-unicorn.service
298 %{systemdunitdir}/gitlab.target
299 %{systemdtmpfilesdir}/gitlab.conf
303 %attr(-,root,root) %{appdir}/bin/*
307 %{appdir}/.ruby-version
309 %{appdir}/GITLAB_SHELL_VERSION
310 %{appdir}/GITLAB_WORKHORSE_VERSION
323 %{appdir}/generator_templates
333 %dir %attr(755,%{uname},%{gname}) %{vardir}/satellites
334 %dir %attr(755,%{uname},%{gname}) %{vardir}/builds
335 %dir %{vardir}/public
336 %attr(-,%{uname},%{gname}) %{vardir}/public/uploads
337 %attr(-,%{uname},%{gname}) %{vardir}/public/assets
338 %dir %attr(755,%{uname},%{gname}) %{vardir}/tmp
339 %attr(-,%{uname},%{gname}) %{vardir}/tmp/backups
341 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sessions
342 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sockets
343 %attr(-,%{uname},%{gname}) %{vardir}/tmp/pids
344 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared
345 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts
346 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp
347 %{vardir}/shared/artifacts/tmp/cache
348 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp/uploads
349 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/lfs-objects
350 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/registry
352 %dir %attr(750,root,%{gname}) %{cachedir}
353 %attr(-,%{uname},%{gname}) %{cachedir}/cache
354 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
356 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
357 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
359 %defattr(-,root,root,-)
360 %dir %{appdir}/vendor
364 %defattr(644,root,root,755)