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 Patch2: revert-5281.patch
41 URL: https://www.gitlab.com/gitlab-ce/
43 BuildRequires: gmp-devel
44 BuildRequires: libgit2-devel
45 BuildRequires: libicu-devel
46 BuildRequires: libstdc++-devel
47 BuildRequires: libxml2-devel
48 BuildRequires: mysql-devel
49 BuildRequires: postgresql-devel
50 BuildRequires: rpm-rubyprov
51 BuildRequires: rpmbuild(macros) >= 1.647
52 BuildRequires: ruby-bundler
53 BuildRequires: ruby-devel >= 1:2.1.0
54 BuildRequires: zlib-devel
55 Requires(post,preun): /sbin/chkconfig
57 Requires: git-core >= 2.7.4
58 Requires: gitlab-shell >= 3.4.0
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 homedir %{_localstatedir}/lib/gitlab
75 GitLab Community Edition (CE) is open source software to collaborate
76 on code. Create projects and repositories, manage access and do code
77 reviews. GitLab CE is on-premises software that you can install and
78 use on your server(s).
81 Summary: Manual for GitLab
82 Summary(fr.UTF-8): Documentation pour GitLab
83 Summary(it.UTF-8): Documentazione di GitLab
84 Summary(pl.UTF-8): Podręcznik dla GitLab
86 # noarch subpackages only when building with rpm5
87 %if "%{_rpmversion}" >= "5"
92 Documentation for GitLab.
95 %setup -qn gitlabhq-%{version}
96 mv config/gitlab.yml.example config/gitlab.yml
97 mv config/unicorn.rb.example config/unicorn.rb
103 mv config/database.yml.mysql config/database.yml
105 find -name .gitkeep | xargs rm
108 %if %{with gem_cache}
109 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
110 install -d vendor/bundle
111 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
114 bundle install %{_smp_mflags} \
117 --without development test aws %{!?with_krb5:kerberos}
119 # install newer rugged to fix diff view showing garbage
120 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
122 test -d vendor/bundle/ruby/gems/rugged-$v || \
123 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
126 # use modified config so it doesn't croak
127 cp -p config/gitlab.yml{,.production}
128 sed -i -e '/secret_file:/d' config/gitlab.yml
129 sed -i -e 's#/home/git/repositories/#./#' config/gitlab.yml
130 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
131 mv -f config/gitlab.yml{.production,}
133 # avoid bogus ruby dep
134 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
136 # remove secrets, log and cache that assets compile initialized
137 rm .gitlab_shell_secret
138 rm config/secrets.yml
139 rm log/production.log
142 %if %{with gem_cache}
143 install -d "$cachedir"
144 cp -aul vendor/bundle/* "$cachedir"
148 rm -rf $RPM_BUILD_ROOT
150 $RPM_BUILD_ROOT%{homedir}/public/{assets,uploads} \
151 $RPM_BUILD_ROOT%{homedir}/satellites \
152 $RPM_BUILD_ROOT%{homedir}/tmp/{cache/assets,sessions,backups} \
153 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
154 $RPM_BUILD_ROOT%{_docdir}/gitlab \
155 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
157 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
158 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
160 rm -f $RPM_BUILD_ROOT/VERSION
163 cp -a$l . $RPM_BUILD_ROOT%{homedir}
165 # cleanup unneccessary cruft (gem build files, etc)
166 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{homedir}
168 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
171 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
172 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
173 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-$ov
174 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
176 # rpm cruft from repackaging
177 rm -f $RPM_BUILD_ROOT%{homedir}/debug*.list
180 chmod -R u+w $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
181 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
184 rmdir $RPM_BUILD_ROOT%{homedir}/{log,tmp/{pids,sockets}}
185 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/pids
186 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/sockets
187 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{homedir}/log
189 # move $source to $target leaving symlink in original path
191 local source=$1 target=$2
192 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
193 ln -s $target $RPM_BUILD_ROOT$source
196 # Install config files
197 for f in gitlab.yml unicorn.rb database.yml; do
198 move_symlink %{homedir}/config/$f %{_sysconfdir}/gitlab/$f
201 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
202 ln -s %{_sysconfdir}/.gitconfig $RPM_BUILD_ROOT%{homedir}/.gitconfig
204 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
206 # relocate to /etc as it's updated runtime, see 77cff54
207 move_symlink %{homedir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
209 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
210 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
212 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
213 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
214 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
215 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
217 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
218 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
219 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
220 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
221 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
222 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
225 rm -rf $RPM_BUILD_ROOT
228 if [ "$1" = "2" ]; then
229 # Looks like an RPM upgrade
234 /sbin/chkconfig --add gitlab-sidekiq
235 /sbin/chkconfig --add gitlab-unicorn
236 %service gitlab-sidekiq restart
237 %service gitlab-unicorn restart
238 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
240 %banner -e -o %{name} << EOF
242 Create and configure database in %{_sysconfdir}/gitlab/database.yml
245 # gitlab-rake gitlab:setup
250 if [ "$1" = "0" ]; then
251 # Looks like an RPM upgrade
256 if [ "$1" = "0" ]; then
257 %service -q gitlab-sidekiq stop
258 %service -q gitlab-unicorn stop
259 /sbin/chkconfig --del gitlab-sidekiq
260 /sbin/chkconfig --del gitlab-unicorn
262 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
265 if [ $1 -eq 0 ]; then
272 %defattr(644,root,root,755)
274 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
275 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
276 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
277 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
278 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
279 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
280 %config(noreplace) %verify(not md5 mtime size) /etc/httpd/webapps.d/gitlab.conf
281 /etc/logrotate.d/gitlab.logrotate
282 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
283 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
284 %attr(755,root,root) %{_sbindir}/gitlab-rake
285 %attr(755,root,root) %{_sbindir}/gitlab-ctl
286 %{systemdunitdir}/gitlab-sidekiq.service
287 %{systemdunitdir}/gitlab-unicorn.service
288 %{systemdunitdir}/gitlab.target
289 %{systemdtmpfilesdir}/gitlab.conf
292 %{homedir}/.gitconfig
295 %attr(-,root,root) %{homedir}/bin/*
300 %{homedir}/generator_templates
303 %dir %{homedir}/public
305 %{homedir}/public/*.*
306 %attr(-,%{uname},%{gname}) %{homedir}/public/uploads
307 %attr(-,%{uname},%{gname}) %{homedir}/public/assets
308 %dir %attr(755,%{uname},%{gname}) %{homedir}/satellites
310 %dir %attr(755,%{uname},%{gname}) %{homedir}/tmp
311 %attr(-,%{uname},%{gname}) %{homedir}/tmp/backups
312 %attr(-,%{uname},%{gname}) %{homedir}/tmp/cache
313 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sessions
314 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sockets
315 %attr(-,%{uname},%{gname}) %{homedir}/tmp/pids
317 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared
318 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts
319 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp
320 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/cache
321 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/uploads
322 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/lfs-objects
323 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/registry
325 %dir %attr(755,%{uname},%{gname}) %{homedir}/.bundle
326 %attr(-,%{uname},%{gname}) %{homedir}/.bundle/config
327 %attr(-,%{uname},%{gname}) %{homedir}/.ruby-version
328 %attr(-,%{uname},%{gname}) %{homedir}/CHANGELOG
329 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_WORKHORSE_VERSION
330 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_SHELL_VERSION
331 %attr(-,%{uname},%{gname}) %{homedir}/Gemfile*
332 %attr(-,%{uname},%{gname}) %{homedir}/LICENSE
333 %attr(-,%{uname},%{gname}) %{homedir}/*.md
334 %attr(-,%{uname},%{gname}) %{homedir}/Rakefile
335 %attr(-,%{uname},%{gname}) %{homedir}/VERSION
336 %attr(-,%{uname},%{gname}) %{homedir}/config.ru
339 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
340 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
342 %defattr(-,root,root,-)
343 %dir %{homedir}/vendor
347 %defattr(644,root,root,755)