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