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