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