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