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