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
60 Requires: ruby-bundler
61 Requires: systemd-units >= 0.38
63 Suggests: redis-server
64 Obsoletes: gitlab <= 8.1.4
65 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
67 %define _noautoreqfiles redcloth_scan.jar primitives.jar
71 %define homedir %{_localstatedir}/lib/gitlab
74 GitLab Community Edition (CE) is open source software to collaborate
75 on code. Create projects and repositories, manage access and do code
76 reviews. GitLab CE is on-premises software that you can install and
77 use on your server(s).
80 Summary: Manual for GitLab
81 Summary(fr.UTF-8): Documentation pour GitLab
82 Summary(it.UTF-8): Documentazione di GitLab
83 Summary(pl.UTF-8): Podręcznik dla GitLab
85 # noarch subpackages only when building with rpm5
86 %if "%{_rpmversion}" >= "5"
91 Documentation for GitLab.
94 %setup -qn gitlabhq-%{version}
95 mv config/gitlab.yml.example config/gitlab.yml
96 mv config/unicorn.rb.example config/unicorn.rb
101 mv config/database.yml.mysql config/database.yml
103 find -name .gitkeep | xargs rm
106 %if %{with gem_cache}
107 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
108 install -d vendor/bundle
109 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
112 bundle install %{_smp_mflags} \
115 --without development test aws %{!?with_krb5:kerberos}
117 # install newer rugged to fix diff view showing garbage
118 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
120 test -d vendor/bundle/ruby/gems/rugged-$v || \
121 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
124 # use modified config so it doesn't croak
125 cp -p config/gitlab.yml{,.production}
126 sed -i -e '/secret_file:/d' config/gitlab.yml
127 sed -i -e 's#/home/git/repositories/#./#' config/gitlab.yml
128 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
129 mv -f config/gitlab.yml{.production,}
131 # avoid bogus ruby dep
132 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
134 # remove secrets, log and cache that assets compile initialized
135 rm .gitlab_shell_secret
136 rm config/secrets.yml
137 rm log/production.log
140 %if %{with gem_cache}
141 install -d "$cachedir"
142 cp -aul vendor/bundle/* "$cachedir"
146 rm -rf $RPM_BUILD_ROOT
148 $RPM_BUILD_ROOT%{homedir}/public/{assets,uploads} \
149 $RPM_BUILD_ROOT%{homedir}/satellites \
150 $RPM_BUILD_ROOT%{homedir}/tmp/{cache/assets,sessions,backups} \
151 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
152 $RPM_BUILD_ROOT%{_docdir}/gitlab \
153 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
155 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
156 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
158 rm -f $RPM_BUILD_ROOT/VERSION
161 cp -a$l . $RPM_BUILD_ROOT%{homedir}
163 # cleanup unneccessary cruft (gem build files, etc)
164 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{homedir}
166 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
169 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
170 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
171 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-$ov
172 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
174 # rpm cruft from repackaging
175 rm -f $RPM_BUILD_ROOT%{homedir}/debug*.list
178 chmod -R u+w $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
179 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
182 rmdir $RPM_BUILD_ROOT%{homedir}/{log,tmp/{pids,sockets}}
183 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/pids
184 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/sockets
185 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{homedir}/log
187 # move $source to $target leaving symlink in original path
189 local source=$1 target=$2
190 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
191 ln -s $target $RPM_BUILD_ROOT$source
194 # Install config files
195 for f in gitlab.yml unicorn.rb database.yml; do
196 move_symlink %{homedir}/config/$f %{_sysconfdir}/gitlab/$f
199 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
200 ln -s %{_sysconfdir}/.gitconfig $RPM_BUILD_ROOT%{homedir}/.gitconfig
202 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
204 # relocate to /etc as it's updated runtime, see 77cff54
205 move_symlink %{homedir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
207 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
208 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
210 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
211 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
212 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
213 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
215 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
216 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
217 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
218 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
219 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
220 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
223 rm -rf $RPM_BUILD_ROOT
226 if [ "$1" = "2" ]; then
227 # Looks like an RPM upgrade
232 /sbin/chkconfig --add gitlab-sidekiq
233 /sbin/chkconfig --add gitlab-unicorn
234 %service gitlab-sidekiq restart
235 %service gitlab-unicorn restart
236 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
238 %banner -e -o %{name} << EOF
240 Create and configure database in %{_sysconfdir}/gitlab/database.yml
243 # gitlab-rake gitlab:setup
248 if [ "$1" = "0" ]; then
249 # Looks like an RPM upgrade
254 if [ "$1" = "0" ]; then
255 %service -q gitlab-sidekiq stop
256 %service -q gitlab-unicorn stop
257 /sbin/chkconfig --del gitlab-sidekiq
258 /sbin/chkconfig --del gitlab-unicorn
260 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
263 if [ $1 -eq 0 ]; then
270 %defattr(644,root,root,755)
272 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
273 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
274 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
275 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
276 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
277 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
278 %config(noreplace) %verify(not md5 mtime size) /etc/httpd/webapps.d/gitlab.conf
279 /etc/logrotate.d/gitlab.logrotate
280 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
281 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
282 %attr(755,root,root) %{_sbindir}/gitlab-rake
283 %attr(755,root,root) %{_sbindir}/gitlab-ctl
284 %{systemdunitdir}/gitlab-sidekiq.service
285 %{systemdunitdir}/gitlab-unicorn.service
286 %{systemdunitdir}/gitlab.target
287 %{systemdtmpfilesdir}/gitlab.conf
290 %{homedir}/.gitconfig
293 %attr(-,root,root) %{homedir}/bin/*
298 %{homedir}/generator_templates
301 %dir %{homedir}/public
303 %{homedir}/public/*.*
304 %attr(-,%{uname},%{gname}) %{homedir}/public/uploads
305 %attr(-,%{uname},%{gname}) %{homedir}/public/assets
306 %dir %attr(755,%{uname},%{gname}) %{homedir}/satellites
308 %dir %attr(755,%{uname},%{gname}) %{homedir}/tmp
309 %attr(-,%{uname},%{gname}) %{homedir}/tmp/backups
310 %attr(-,%{uname},%{gname}) %{homedir}/tmp/cache
311 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sessions
312 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sockets
313 %attr(-,%{uname},%{gname}) %{homedir}/tmp/pids
315 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared
316 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts
317 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp
318 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/cache
319 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/uploads
320 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/lfs-objects
321 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/registry
323 %dir %attr(755,%{uname},%{gname}) %{homedir}/.bundle
324 %attr(-,%{uname},%{gname}) %{homedir}/.bundle/config
325 %attr(-,%{uname},%{gname}) %{homedir}/.ruby-version
326 %attr(-,%{uname},%{gname}) %{homedir}/CHANGELOG
327 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_WORKHORSE_VERSION
328 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_SHELL_VERSION
329 %attr(-,%{uname},%{gname}) %{homedir}/Gemfile*
330 %attr(-,%{uname},%{gname}) %{homedir}/LICENSE
331 %attr(-,%{uname},%{gname}) %{homedir}/*.md
332 %attr(-,%{uname},%{gname}) %{homedir}/Rakefile
333 %attr(-,%{uname},%{gname}) %{homedir}/VERSION
334 %attr(-,%{uname},%{gname}) %{homedir}/config.ru
337 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
338 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
340 %defattr(-,root,root,-)
341 %dir %{homedir}/vendor
345 %defattr(644,root,root,755)