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