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 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
113 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
114 RUBYOPT=--enable-gems \
115 bundle install %{_smp_mflags} \
118 --without development test aws %{!?with_krb5:kerberos}
120 # install newer rugged to fix diff view showing garbage
121 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
123 test -d vendor/bundle/ruby/gems/rugged-$v || \
124 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
127 # use modified config so it doesn't croak
128 cp -p config/gitlab.yml{,.production}
129 sed -i -e '/secret_file:/d' config/gitlab.yml
130 sed -i -e 's#/home/git/repositories/#./#' config/gitlab.yml
131 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
132 mv -f config/gitlab.yml{.production,}
134 # avoid bogus ruby dep
135 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
137 # remove secrets, log and cache that assets compile initialized
138 rm .gitlab_shell_secret
139 rm config/secrets.yml
140 rm log/production.log
143 %if %{with gem_cache}
144 install -d "$cachedir"
145 cp -aul vendor/bundle/* "$cachedir"
149 rm -rf $RPM_BUILD_ROOT
151 $RPM_BUILD_ROOT%{homedir}/public/{assets,uploads} \
152 $RPM_BUILD_ROOT%{homedir}/satellites \
153 $RPM_BUILD_ROOT%{homedir}/tmp/{cache/assets,sessions,backups} \
154 $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
155 $RPM_BUILD_ROOT%{_docdir}/gitlab \
156 $RPM_BUILD_ROOT%{_localstatedir}/{run,log}/gitlab
158 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
159 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
161 rm -f $RPM_BUILD_ROOT/VERSION
164 cp -a$l . $RPM_BUILD_ROOT%{homedir}
166 # cleanup unneccessary cruft (gem build files, etc)
167 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{homedir}
169 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
172 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
173 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
174 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-$ov
175 mv $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
177 # rpm cruft from repackaging
178 rm -f $RPM_BUILD_ROOT%{homedir}/debug*.list
181 chmod -R u+w $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
182 rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test
185 rmdir $RPM_BUILD_ROOT%{homedir}/{log,tmp/{pids,sockets}}
186 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/pids
187 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{homedir}/tmp/sockets
188 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{homedir}/log
190 # move $source to $target leaving symlink in original path
192 local source=$1 target=$2
193 mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
194 ln -s $target $RPM_BUILD_ROOT$source
197 # Install config files
198 for f in gitlab.yml unicorn.rb database.yml; do
199 move_symlink %{homedir}/config/$f %{_sysconfdir}/gitlab/$f
202 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
203 ln -s %{_sysconfdir}/.gitconfig $RPM_BUILD_ROOT%{homedir}/.gitconfig
205 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
207 # relocate to /etc as it's updated runtime, see 77cff54
208 move_symlink %{homedir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
210 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
211 $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
213 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
214 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
215 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
216 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
218 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
219 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
220 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
221 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
222 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
223 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
226 rm -rf $RPM_BUILD_ROOT
229 if [ "$1" = "2" ]; then
230 # Looks like an RPM upgrade
235 /sbin/chkconfig --add gitlab-sidekiq
236 /sbin/chkconfig --add gitlab-unicorn
237 %service gitlab-sidekiq restart
238 %service gitlab-unicorn restart
239 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
241 %banner -e -o %{name} << EOF
243 Create and configure database in %{_sysconfdir}/gitlab/database.yml
246 # gitlab-rake gitlab:setup
251 if [ "$1" = "0" ]; then
252 # Looks like an RPM upgrade
257 if [ "$1" = "0" ]; then
258 %service -q gitlab-sidekiq stop
259 %service -q gitlab-unicorn stop
260 /sbin/chkconfig --del gitlab-sidekiq
261 /sbin/chkconfig --del gitlab-unicorn
263 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
266 if [ $1 -eq 0 ]; then
273 %defattr(644,root,root,755)
275 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
276 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
277 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
278 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
279 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
280 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
281 %config(noreplace) %verify(not md5 mtime size) /etc/httpd/webapps.d/gitlab.conf
282 /etc/logrotate.d/gitlab.logrotate
283 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
284 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
285 %attr(755,root,root) %{_sbindir}/gitlab-rake
286 %attr(755,root,root) %{_sbindir}/gitlab-ctl
287 %{systemdunitdir}/gitlab-sidekiq.service
288 %{systemdunitdir}/gitlab-unicorn.service
289 %{systemdunitdir}/gitlab.target
290 %{systemdtmpfilesdir}/gitlab.conf
293 %{homedir}/.gitconfig
296 %attr(-,root,root) %{homedir}/bin/*
301 %{homedir}/generator_templates
304 %dir %{homedir}/public
306 %{homedir}/public/*.*
307 %attr(-,%{uname},%{gname}) %{homedir}/public/uploads
308 %attr(-,%{uname},%{gname}) %{homedir}/public/assets
309 %dir %attr(755,%{uname},%{gname}) %{homedir}/satellites
311 %dir %attr(755,%{uname},%{gname}) %{homedir}/tmp
312 %attr(-,%{uname},%{gname}) %{homedir}/tmp/backups
313 %attr(-,%{uname},%{gname}) %{homedir}/tmp/cache
314 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sessions
315 %attr(-,%{uname},%{gname}) %{homedir}/tmp/sockets
316 %attr(-,%{uname},%{gname}) %{homedir}/tmp/pids
318 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared
319 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts
320 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp
321 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/cache
322 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/artifacts/tmp/uploads
323 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/lfs-objects
324 %dir %attr(750,%{uname},%{gname}) %{homedir}/shared/registry
326 %dir %attr(755,%{uname},%{gname}) %{homedir}/.bundle
327 %attr(-,%{uname},%{gname}) %{homedir}/.bundle/config
328 %attr(-,%{uname},%{gname}) %{homedir}/.ruby-version
329 %attr(-,%{uname},%{gname}) %{homedir}/CHANGELOG
330 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_WORKHORSE_VERSION
331 %attr(-,%{uname},%{gname}) %{homedir}/GITLAB_SHELL_VERSION
332 %attr(-,%{uname},%{gname}) %{homedir}/Gemfile*
333 %attr(-,%{uname},%{gname}) %{homedir}/LICENSE
334 %attr(-,%{uname},%{gname}) %{homedir}/*.md
335 %attr(-,%{uname},%{gname}) %{homedir}/Rakefile
336 %attr(-,%{uname},%{gname}) %{homedir}/VERSION
337 %attr(-,%{uname},%{gname}) %{homedir}/config.ru
340 %dir %attr(771,root,%{gname}) %{_localstatedir}/log/gitlab
341 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
343 %defattr(-,root,root,-)
344 %dir %{homedir}/vendor
348 %defattr(644,root,root,755)