]>
Commit | Line | Data |
---|---|---|
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 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.7.5 | |
20 | Release: 0.9 | |
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 | Patch0: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3774.patch | |
26 | URL: https://www.gitlab.com/gitlab-ce/ | |
27 | Source1: gitlab.target | |
28 | Source2: gitlab-sidekiq.service | |
29 | Source3: gitlab-unicorn.service | |
30 | Source4: gitlab.logrotate | |
31 | Source5: gitlab.tmpfiles.d | |
32 | Source6: gitlab-apache-conf | |
33 | BuildRequires: cmake | |
34 | BuildRequires: gmp-devel | |
35 | BuildRequires: libgit2-devel | |
36 | BuildRequires: libicu-devel | |
37 | BuildRequires: libstdc++-devel | |
38 | BuildRequires: libxml2-devel | |
39 | BuildRequires: mysql-devel | |
40 | BuildRequires: postgresql-devel | |
41 | BuildRequires: rpm-rubyprov | |
42 | BuildRequires: ruby-bundler | |
43 | BuildRequires: ruby-devel >= 1:2.1.0 | |
44 | BuildRequires: zlib-devel | |
45 | Obsoletes: gitlab <= 8.1.4 | |
46 | Requires(pre): gitlab-shell | |
47 | Requires: apache-base | |
48 | Requires: git-core >= 2.7.4 | |
49 | Requires: nodejs | |
50 | Requires: ruby-bundler | |
51 | Suggests: mysql | |
52 | Suggests: redis-server | |
53 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
54 | ||
55 | %define _noautoreqfiles redcloth_scan.jar primitives.jar | |
56 | ||
57 | %define gitlab_uid 65434 | |
58 | %define gitlab_gid 65434 | |
59 | ||
60 | %define homedir %{_localstatedir}/lib/gitlab | |
61 | ||
62 | %description | |
63 | GitLab Community Edition (CE) is open source software to collaborate | |
64 | on code. Create projects and repositories, manage access and do code | |
65 | reviews. GitLab CE is on-premises software that you can install and | |
66 | use on your server(s). | |
67 | ||
68 | %prep | |
69 | %setup -qn gitlabhq-%{version} | |
70 | %patch0 -p1 | |
71 | ||
72 | # Patching config files: | |
73 | sed -e "s|# user: git|user: gitlab|" \ | |
74 | -e "s|/home/git/repositories|%{homedir}/repositories|" \ | |
75 | -e "s|/home/git/gitlab-satellites|%{homedir}/satellites|" \ | |
76 | -e "s|/home/git/gitlab-shell|/usr/share/gitlab-shell|" \ | |
77 | config/gitlab.yml.example > config/gitlab.yml | |
78 | sed -e "s|/home/git/gitlab/tmp/.*/|/run/gitlab/|g" \ | |
79 | -e "s|/home/git/gitlab|%{homedir}|g" \ | |
80 | -e "s|/usr/share/gitlab/log|%{homedir}/log|g" \ | |
81 | -e "s|timeout 30|timeout 300|" \ | |
82 | config/unicorn.rb.example > config/unicorn.rb | |
83 | sed -e "s|username: git|username: gitlab|" \ | |
84 | config/database.yml.mysql > config/database.yml | |
85 | ||
86 | rm .flayignore | |
87 | rm .gitignore | |
88 | rm .csscomb.json | |
89 | find -name .gitkeep | xargs rm | |
90 | ||
91 | %build | |
92 | %if %{with gem_cache} | |
93 | cachedir="%{_specdir}/cache/%{version}.%{_arch}" | |
94 | install -d vendor/bundle | |
95 | test -d "$cachedir" && cp -aul "$cachedir"/* vendor/bundle | |
96 | %endif | |
97 | ||
98 | bundle install %{_smp_mflags} \ | |
99 | --verbose \ | |
100 | --deployment \ | |
101 | --without development test aws %{!?with_krb5:kerberos} | |
102 | ||
103 | # avoid bogus ruby dep | |
104 | chmod a-x vendor/bundle/ruby/gems/unicorn-*/bin/unicorn* | |
105 | ||
106 | %if %{with gem_cache} | |
107 | install -d "$cachedir" | |
108 | cp -aul vendor/bundle/* "$cachedir" | |
109 | %endif | |
110 | ||
111 | %install | |
112 | rm -rf $RPM_BUILD_ROOT | |
113 | install -d \ | |
114 | $RPM_BUILD_ROOT%{homedir}/www \ | |
115 | $RPM_BUILD_ROOT%{homedir}/public/uploads \ | |
116 | $RPM_BUILD_ROOT%{_sysconfdir}/gitlab \ | |
117 | $RPM_BUILD_ROOT%{_docdir}/gitlab \ | |
118 | $RPM_BUILD_ROOT%{homedir}/satellites | |
119 | ||
120 | # test if we can hardlink -- %{_builddir} and $RPM_BUILD_ROOT on same partition | |
121 | if cp -al VERSION $RPM_BUILD_ROOT/VERSION 2>/dev/null; then | |
122 | l=l | |
123 | rm -f $RPM_BUILD_ROOT/VERSION | |
124 | fi | |
125 | ||
126 | cp -a$l . $RPM_BUILD_ROOT%{homedir} | |
127 | ||
128 | # rpm cruft from repackaging | |
129 | rm -f $RPM_BUILD_ROOT%{homedir}/debug*.list | |
130 | ||
131 | # nuke tests | |
132 | chmod -R u+w $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test | |
133 | rm -r $RPM_BUILD_ROOT%{homedir}/vendor/bundle/ruby/gems/*/test | |
134 | ||
135 | # Creating links | |
136 | ln -fs /run/gitlab $RPM_BUILD_ROOT%{homedir}/pids | |
137 | ln -fs /run/gitlab $RPM_BUILD_ROOT%{homedir}/sockets | |
138 | rmdir $RPM_BUILD_ROOT%{homedir}/log | |
139 | ln -fs %{_localstatedir}/log/gitlab $RPM_BUILD_ROOT%{homedir}/log | |
140 | install -d $RPM_BUILD_ROOT%{_localstatedir}/log/gitlab | |
141 | ||
142 | move_config() { | |
143 | local source=$1 target=$2 | |
144 | mv $RPM_BUILD_ROOT$source $RPM_BUILD_ROOT$target | |
145 | ln -s $target $RPM_BUILD_ROOT$source | |
146 | } | |
147 | ||
148 | # Install config files | |
149 | for f in gitlab.yml unicorn.rb database.yml; do | |
150 | move_config %{homedir}/config/$f %{_sysconfdir}/gitlab/$f | |
151 | done | |
152 | ||
153 | install -d $RPM_BUILD_ROOT{%{systemdunitdir},%{systemdtmpfilesdir}} \ | |
154 | $RPM_BUILD_ROOT/etc/{logrotate.d,httpd/webapps.d} | |
155 | ||
156 | # Install systemd service files | |
157 | cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target | |
158 | cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service | |
159 | cp -p %{SOURCE3} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service | |
160 | cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf | |
161 | cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate | |
162 | cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf | |
163 | ||
164 | %clean | |
165 | rm -rf "$RPM_BUILD_ROOT" | |
166 | ||
167 | %pre | |
168 | if [ $1 -ge 1 ]; then | |
169 | %groupadd gitlab -g %{gitlab_gid} | |
170 | %useradd -u %{gitlab_uid} -c 'Gitlab user' -d %{homedir} -g gitlab -s /bin/bash gitlab | |
171 | fi | |
172 | ||
173 | %post | |
174 | if [ $1 -ge 1 ]; then | |
175 | systemctl -q daemon-reload | |
176 | systemd-tmpfiles --create %{systemdtmpfilesdir}/gitlab.conf | |
177 | [ -e %{_localstatedir}/lock/subsys/httpd ] && service httpd reload || : | |
178 | fi | |
179 | if [ $1 -eq 1 ]; then | |
180 | systemctl -q enable gitlab-unicorn | |
181 | systemctl -q enable gitlab-sidekiq | |
182 | systemctl -q enable gitlab.target | |
183 | systemctl -q start gitlab-unicorn | |
184 | systemctl -q start gitlab-sidekiq | |
185 | systemctl -q start gitlab.target | |
186 | sudo -u gitlab -H git config --global user.name "GitLab" | |
187 | sudo -u gitlab -H git config --global user.email "gitlab@localhost" | |
188 | sudo -u gitlab -H git config --global core.autocrlf input | |
189 | echo "Create and configure database in /etc/gitlab/database.yml" | |
190 | echo "Then run 'sudo -u gitlab bundle exec rake gitlab:setup RAILS_ENV=production'" | |
191 | echo | |
192 | else | |
193 | systemctl -q try-restart gitlab-unicorn || : | |
194 | systemctl -q try-start gitlab-sidekiq || : | |
195 | fi | |
196 | ||
197 | %postun | |
198 | if [ $1 -eq 0 ]; then | |
199 | %userremove gitlab | |
200 | %groupremove gitlab | |
201 | fi | |
202 | ||
203 | %files | |
204 | %defattr(644,root,root,755) | |
205 | %doc LICENSE | |
206 | %dir %{_sysconfdir}/gitlab | |
207 | %config(noreplace) %{_sysconfdir}/gitlab/database.yml | |
208 | %config(noreplace) %{_sysconfdir}/gitlab/gitlab.yml | |
209 | %config(noreplace) %{_sysconfdir}/gitlab/unicorn.rb | |
210 | %config(noreplace) %{_sysconfdir}/httpd/webapps.d/gitlab.conf | |
211 | /etc/logrotate.d/gitlab.logrotate | |
212 | %{systemdunitdir}/gitlab-sidekiq.service | |
213 | %{systemdunitdir}/gitlab-unicorn.service | |
214 | %{systemdunitdir}/gitlab.target | |
215 | %{systemdtmpfilesdir}/gitlab.conf | |
216 | %dir %attr(755,gitlab,gitlab) %{homedir} | |
217 | %dir %attr(755,gitlab,gitlab) %{homedir}/app | |
218 | %attr(-,gitlab,gitlab) %{homedir}/app/* | |
219 | %dir %attr(755,gitlab,gitlab) %{homedir}/bin | |
220 | %attr(-,gitlab,gitlab) %{homedir}/bin/* | |
221 | %dir %attr(755,gitlab,gitlab) %{homedir}/builds | |
222 | %dir %attr(755,gitlab,gitlab) %{homedir}/config | |
223 | %attr(-,gitlab,gitlab) %{homedir}/config/* | |
224 | %dir %attr(755,gitlab,gitlab) %{homedir}/db | |
225 | %attr(-,gitlab,gitlab) %{homedir}/db/* | |
226 | %dir %attr(755,gitlab,gitlab) %{homedir}/doc | |
227 | %attr(-,gitlab,gitlab) %{homedir}/doc/* | |
228 | %dir %attr(755,gitlab,gitlab) %{homedir}/docker | |
229 | %attr(-,gitlab,gitlab) %{homedir}/docker/* | |
230 | %dir %attr(755,gitlab,gitlab) %{homedir}/features | |
231 | %attr(-,gitlab,gitlab) %{homedir}/features/* | |
232 | %dir %attr(755,gitlab,gitlab) %{homedir}/lib | |
233 | %attr(-,gitlab,gitlab) %{homedir}/lib/* | |
234 | %dir %attr(755,gitlab,gitlab) %{homedir}/pids | |
235 | %dir %attr(755,gitlab,gitlab) %{homedir}/public | |
236 | %attr(-,gitlab,gitlab) %{homedir}/public/* | |
237 | %dir %attr(755,gitlab,gitlab) %{homedir}/satellites | |
238 | %dir %attr(755,gitlab,gitlab) %{homedir}/scripts | |
239 | %attr(-,gitlab,gitlab) %{homedir}/scripts/* | |
240 | %dir %attr(755,gitlab,gitlab) %{homedir}/sockets | |
241 | %dir %attr(755,gitlab,gitlab) %{homedir}/spec | |
242 | %attr(-,gitlab,gitlab) %{homedir}/spec/* | |
243 | %dir %attr(755,gitlab,gitlab) %{homedir}/tmp | |
244 | %attr(-,gitlab,gitlab) %{homedir}/tmp/* | |
245 | %dir %attr(755,gitlab,gitlab) %{homedir}/www | |
246 | ||
247 | %dir %attr(755,gitlab,gitlab) %{homedir}/.bundle | |
248 | %attr(-,gitlab,gitlab) %{homedir}/.bundle/config | |
249 | %attr(-,gitlab,gitlab) %{homedir}/.foreman | |
250 | %attr(-,gitlab,gitlab) %{homedir}/docker-compose.yml | |
251 | %attr(-,gitlab,gitlab) %{homedir}/.gitattributes | |
252 | %attr(-,gitlab,gitlab) %{homedir}/.*.yml | |
253 | %attr(-,gitlab,gitlab) %{homedir}/.rspec | |
254 | %attr(-,gitlab,gitlab) %{homedir}/.ruby-version | |
255 | %attr(-,gitlab,gitlab) %{homedir}/.simplecov | |
256 | %attr(-,gitlab,gitlab) %{homedir}/CHANGELOG | |
257 | %attr(-,gitlab,gitlab) %{homedir}/GITLAB_WORKHORSE_VERSION | |
258 | %attr(-,gitlab,gitlab) %{homedir}/GITLAB_SHELL_VERSION | |
259 | %attr(-,gitlab,gitlab) %{homedir}/Gemfile* | |
260 | %attr(-,gitlab,gitlab) %{homedir}/LICENSE | |
261 | %attr(-,gitlab,gitlab) %{homedir}/*.md | |
262 | %attr(-,gitlab,gitlab) %{homedir}/Procfile | |
263 | %attr(-,gitlab,gitlab) %{homedir}/Rakefile | |
264 | %attr(-,gitlab,gitlab) %{homedir}/VERSION | |
265 | %attr(-,gitlab,gitlab) %{homedir}/config.ru | |
266 | %attr(-,gitlab,gitlab) %{homedir}/fixtures | |
267 | ||
268 | %{homedir}/log | |
269 | %dir %attr(771,root,gitlab) /var/log/gitlab | |
270 | ||
271 | %defattr(-,root,root,-) | |
272 | %dir %{homedir}/vendor | |
273 | %{homedir}/vendor/* |