]> git.pld-linux.org Git - packages/gitlab-ce.git/blob - gitlab-ce.spec
up to 8.14.1
[packages/gitlab-ce.git] / gitlab-ce.spec
1 # NOTE:
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.
6 #
7 # install notes: https://gitlab.com/gitlab-org/gitlab-ce/blob/v8.6.6/doc/install/installation.md
8 #
9 # TODO
10 # - [timfel-krb5-auth] doesn't build with heimdal (https://github.com/timfel/krb5-auth/issues/8)
11 #
12 #
13 # Conditional build:
14 %bcond_with     krb5            # build with kerberos support
15 %bcond_without  gem_cache       # use local cache to speedup gem installation
16
17 %define shell_version 4.0.0
18 %define workhorse_version 1.0.0
19 Summary:        A Web interface to create projects and repositories, manage access and do code reviews
20 Name:           gitlab-ce
21 Version:        8.14.1
22 Release:        0.81
23 License:        MIT
24 Group:          Applications/WWW
25 # md5 deliberately omitted until this package is useful
26 Source0:        https://gitlab.com/gitlab-org/gitlab-ce/repository/archive.tar.bz2?ref=v%{version}&/%{name}-%{version}.tar.bz2
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
34 Source8:        apache.conf
35 Source9:        gitlab-rake.sh
36 Source10:       gitconfig
37 Source11:       gitlab-ctl.sh
38 Source12:       clean-vendor.sh
39 Source13:       nginx.conf
40 Patch0:         3774.patch
41 Patch1:         pld.patch
42 Patch2:         post_receive-any-email.patch
43 URL:            https://www.gitlab.com/gitlab-ce/
44 BuildRequires:  cmake
45 BuildRequires:  gmp-devel
46 BuildRequires:  libgit2-devel
47 BuildRequires:  libicu-devel
48 BuildRequires:  libstdc++-devel
49 BuildRequires:  libxml2-devel
50 BuildRequires:  mysql-devel
51 BuildRequires:  postgresql-devel
52 BuildRequires:  rpm-rubyprov
53 BuildRequires:  rpmbuild(macros) >= 1.647
54 BuildRequires:  ruby-bundler
55 BuildRequires:  ruby-devel >= 1:2.1.0
56 BuildRequires:  zlib-devel
57 Requires(post,preun):   /sbin/chkconfig
58 Requires:       git-core >= 2.7.4
59 Requires:       gitlab-common >= 8.12-2
60 Requires:       gitlab-shell >= %{shell_version}
61 Requires:       gitlab-workhorse >= %{workhorse_version}
62 Requires:       nodejs
63 Requires:       rc-scripts
64 Requires:       ruby-bundler
65 Requires:       systemd-units >= 0.38
66 Requires:       webapps
67 Suggests:       mysql
68 Suggests:       redis-server
69 Obsoletes:      gitlab <= 8.1.4
70 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
71
72 %define _noautoreqfiles redcloth_scan.jar primitives.jar
73
74 %define uname    git
75 %define gname    git
76 %define appdir   %{_prefix}/lib/gitlab
77 %define vardir   %{_localstatedir}/lib/gitlab
78 %define cachedir %{_localstatedir}/cache/gitlab
79 %define _webapps /etc/webapps
80 %define _webapp  gitlab
81
82 %description
83 GitLab Community Edition (CE) is open source software to collaborate
84 on code. Create projects and repositories, manage access and do code
85 reviews. GitLab CE is on-premises software that you can install and
86 use on your server(s).
87
88 %package doc
89 Summary:        Manual for GitLab
90 Summary(fr.UTF-8):      Documentation pour GitLab
91 Summary(it.UTF-8):      Documentazione di GitLab
92 Summary(pl.UTF-8):      PodrÄ™cznik dla GitLab
93 Group:          Documentation
94 # noarch subpackages only when building with rpm5
95 %if "%{_rpmversion}" >= "5"
96 BuildArch:      noarch
97 %endif
98
99 %description doc
100 Documentation for GitLab.
101
102 %prep
103 %setup -qc
104 mv gitlab-ce-v%{version}-*/{.??*,*} .
105 mv config/gitlab.yml.example config/gitlab.yml
106 mv config/unicorn.rb.example config/unicorn.rb
107 #%patch0 -p1
108 %patch1 -p1
109 %patch2 -p1
110
111 # use mysql for now
112 mv config/database.yml.mysql config/database.yml
113
114 find -name .gitkeep | xargs rm
115
116 v=$(cat GITLAB_SHELL_VERSION)
117 test "$v" = "%{shell_version}"
118 v=$(cat GITLAB_WORKHORSE_VERSION)
119 test "$v" = "%{workhorse_version}"
120
121 %build
122 %if %{with gem_cache}
123 cachedir="%{_specdir}/cache/%{version}.%{_arch}"
124 install -d vendor/bundle
125 test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle
126 %endif
127
128 # enable-gems to workaround https://github.com/ruby-prof/ruby-prof/pull/191
129 # until https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6026 is merged
130 RUBYOPT=--enable-gems \
131 bundle install %{_smp_mflags} \
132         --verbose \
133         --deployment \
134         --without development test aws %{!?with_krb5:kerberos}
135
136 # install newer rugged to fix diff view showing garbage
137 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14972
138 v=0.25.0b7
139 test -d vendor/bundle/ruby/gems/rugged-$v || \
140 bundle exec gem install -v $v rugged --no-rdoc --no-ri --verbose
141
142 # precompile assets
143 # use modified config so it doesn't croak
144 cp -p config/gitlab.yml{,.production}
145 sed -i -e '/secret_file:/d' config/gitlab.yml
146 sed -i -e 's#/var/lib/gitlab/repositories/#./#' config/gitlab.yml
147 bundle exec rake RAILS_ENV=production assets:clean assets:precompile USE_DB=false
148 mv -f config/gitlab.yml{.production,}
149
150 # avoid bogus ruby dep
151 chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn*
152
153 # remove secrets, log and cache that assets compile initialized
154 rm .gitlab_shell_secret
155 cp -f config/secrets.yml{.example,}
156 rm log/production.log
157 rm -r tmp/cache/*
158
159 %if %{with gem_cache}
160 install -d "$cachedir"
161 cp -aul vendor/bundle/* "$cachedir"
162 %endif
163
164 %install
165 rm -rf $RPM_BUILD_ROOT
166 install -d \
167         $RPM_BUILD_ROOT%{appdir}/public/{assets,uploads} \
168         $RPM_BUILD_ROOT%{appdir}/satellites \
169         $RPM_BUILD_ROOT%{appdir}/tmp/{cache/assets,sessions,backups} \
170         $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \
171         $RPM_BUILD_ROOT%{_webapps}/%{_webapp} \
172         $RPM_BUILD_ROOT%{_docdir}/gitlab \
173         $RPM_BUILD_ROOT%{vardir}/public \
174         $RPM_BUILD_ROOT%{cachedir}/tmp \
175         $RPM_BUILD_ROOT%{_localstatedir}/run/gitlab
176
177 # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition
178 if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then
179         l=l
180         rm -f $RPM_BUILD_ROOT/VERSION
181 fi
182
183 cp -a$l . $RPM_BUILD_ROOT%{appdir}
184
185 # cleanup unneccessary cruft (gem build files, etc)
186 sh -x %{SOURCE12} $RPM_BUILD_ROOT%{appdir}
187
188 # replace the contents, yet leave it believe it has proper version installed (for gem dependencies)
189 v=0.25.0b7
190 ov=0.24.0
191 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-$ov
192 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/extensions/%{_arch}-linux/rugged-{$v,$ov}
193 rm -r $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-$ov
194 mv $RPM_BUILD_ROOT%{appdir}/vendor/bundle/ruby/gems/rugged-{$v,$ov}
195
196 # rpm cruft from repackaging
197 rm -f $RPM_BUILD_ROOT%{appdir}/debug*.list
198
199 # Creating links
200 rmdir $RPM_BUILD_ROOT%{appdir}/{log,tmp/{pids,sockets}}
201 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/pids
202 ln -s %{_localstatedir}/run/gitlab $RPM_BUILD_ROOT%{appdir}/tmp/sockets
203 ln -s %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{appdir}/log
204
205 # move $source to $target leaving symlink in original path
206 move_symlink() {
207         local source=$1 target=$2
208         mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target
209         ln -s $target $RPM_BUILD_ROOT$source
210 }
211
212 # Install config files
213 for f in gitlab.yml unicorn.rb database.yml secrets.yml; do
214         move_symlink %{appdir}/config/$f %{_sysconfdir}/gitlab/$f
215 done
216 move_symlink %{appdir}/.gitlab_workhorse_secret %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
217
218 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/.gitconfig
219 ln -s %{_sysconfdir}/gitlab/.gitconfig $RPM_BUILD_ROOT%{vardir}/.gitconfig
220
221 touch $RPM_BUILD_ROOT%{_sysconfdir}/gitlab/skip-auto-migrations
222
223 # relocate to /etc as it's updated runtime, see 77cff54
224 move_symlink %{appdir}/db/schema.rb %{_sysconfdir}/gitlab/schema.rb
225
226 for a in satellites builds shared tmp public/{uploads,assets}; do
227         move_symlink %{appdir}/$a %{vardir}/$a
228 done
229
230 move_symlink %{vardir}/tmp/cache %{cachedir}/cache
231 move_symlink %{vardir}/shared/artifacts/tmp/cache %{cachedir}/artifacts
232
233 install -d $RPM_BUILD_ROOT{%{_sbindir},%{systemdunitdir},%{systemdtmpfilesdir}} \
234         $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
235
236 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
237 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
238 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
239 install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
240
241 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
242 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
243 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab
244 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
245 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
246 install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
247
248 %clean
249 rm -rf $RPM_BUILD_ROOT
250
251 %pre
252 if [ "$1" = "2" ]; then
253         # Looks like an RPM upgrade
254         gitlab-ctl preinst
255 fi
256
257 %post
258 /sbin/chkconfig --add gitlab-sidekiq
259 /sbin/chkconfig --add gitlab-unicorn
260 %service gitlab-sidekiq restart
261 %service gitlab-unicorn restart
262 %systemd_post gitlab-sidekiq.service gitlab-unicorn.service
263
264 %banner -e -o %{name} << EOF
265
266 Create and configure database in %{_sysconfdir}/gitlab/database.yml
267
268 Then run:
269   # gitlab-rake gitlab:setup
270
271 EOF
272
273 %posttrans
274 if [ "$1" = "0" ]; then
275         # Looks like an RPM upgrade
276         gitlab-ctl posttrans
277 fi
278
279 %preun
280 if [ "$1" = "0" ]; then
281         %service -q gitlab-sidekiq stop
282         %service -q gitlab-unicorn stop
283         /sbin/chkconfig --del gitlab-sidekiq
284         /sbin/chkconfig --del gitlab-unicorn
285 fi
286 %systemd_preun gitlab-sidekiq.service gitlab-unicorn.service
287
288 %postun
289 if [ $1 -eq 0 ]; then
290         %userremove gitlab
291         %groupremove gitlab
292 fi
293 %systemd_reload
294
295 %triggerin -- apache < 2.2.0, apache-base
296 %webapp_register httpd %{_webapp}
297
298 %triggerun -- apache < 2.2.0, apache-base
299 %webapp_unregister httpd %{_webapp}
300
301 %files
302 %defattr(644,root,root,755)
303 %doc LICENSE
304 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/database.yml
305 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/gitlab.yml
306 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/gitlab/unicorn.rb
307 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/schema.rb
308 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/secrets.yml
309 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitconfig
310 %config(noreplace) %verify(not md5 mtime size) %attr(640,%{uname},%{gname}) %{_sysconfdir}/gitlab/.gitlab_workhorse_secret
311
312 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
313 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
314
315 %ghost %{_sysconfdir}/gitlab/skip-auto-migrations
316 /etc/logrotate.d/gitlab
317 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
318 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
319 %attr(755,root,root) %{_sbindir}/gitlab-rake
320 %attr(755,root,root) %{_sbindir}/gitlab-ctl
321 %{systemdunitdir}/gitlab-sidekiq.service
322 %{systemdunitdir}/gitlab-unicorn.service
323 %{systemdunitdir}/gitlab.target
324 %{systemdtmpfilesdir}/gitlab.conf
325
326 %dir %{appdir}
327 %dir %{appdir}/bin
328 %attr(-,root,root) %{appdir}/bin/*
329 # files
330 %{appdir}/*.md
331 %{appdir}/.bundle
332 %{appdir}/.gitlab_workhorse_secret
333 %{appdir}/.ruby-version
334 %{appdir}/GITLAB_SHELL_VERSION
335 %{appdir}/GITLAB_WORKHORSE_VERSION
336 %{appdir}/Gemfile*
337 %{appdir}/LICENSE
338 %{appdir}/Rakefile
339 %{appdir}/VERSION
340 %{appdir}/config.ru
341
342 # dirs
343 %{appdir}/app
344 %{appdir}/builds
345 %{appdir}/config
346 %{appdir}/db
347 %{appdir}/fixtures
348 %{appdir}/generator_templates
349 %{appdir}/lib
350 %{appdir}/log
351 %{appdir}/public
352 %{appdir}/shared
353 %{appdir}/tmp
354 %{appdir}/satellites
355
356 %{vardir}/.gitconfig
357 %dir %attr(755,%{uname},%{gname}) %{vardir}/satellites
358 %dir %attr(755,%{uname},%{gname}) %{vardir}/builds
359 %dir %{vardir}/public
360 %attr(-,%{uname},%{gname}) %{vardir}/public/uploads
361 %attr(-,%{uname},%{gname}) %{vardir}/public/assets
362 %dir %attr(755,%{uname},%{gname}) %{vardir}/tmp
363 %attr(-,%{uname},%{gname}) %{vardir}/tmp/backups
364 %{vardir}/tmp/cache
365 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sessions
366 %attr(-,%{uname},%{gname}) %{vardir}/tmp/sockets
367 %attr(-,%{uname},%{gname}) %{vardir}/tmp/pids
368 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared
369 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts
370 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp
371 %{vardir}/shared/artifacts/tmp/cache
372 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/artifacts/tmp/uploads
373 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/lfs-objects
374 %dir %attr(750,%{uname},%{gname}) %{vardir}/shared/registry
375
376 %dir %attr(750,root,%{gname}) %{cachedir}
377 %attr(-,%{uname},%{gname}) %{cachedir}/cache
378 %dir %attr(750,%{uname},%{gname}) %{cachedir}/artifacts
379
380 %dir %attr(771,root,%{gname}) %{_localstatedir}/run/gitlab
381
382 %defattr(-,root,root,-)
383 %dir %{appdir}/vendor
384 %{appdir}/vendor/*
385
386 %files doc
387 %defattr(644,root,root,755)
388 %{appdir}/doc
This page took 0.119134 seconds and 3 git commands to generate.