]>
Commit | Line | Data |
---|---|---|
72cef35a ER |
1 | # |
2 | # Conditional build: | |
3 | %bcond_with bindata # embed docker images to binary (upstream compatible) | |
4 | ||
3e1b3fba | 5 | # the revision for images |
ec0a53a6 ER |
6 | # $ git fetch https://gitlab.com/gitlab-org/gitlab-ci-multi-runner refs/tags/v1.6.0 |
7 | # $ git rev-list -n 1 --abbrev-commit FETCH_HEAD | |
8 | #define revision 76fdacd | |
9 | # No changes to image, so don't refetch it | |
10 | %define revision 1.5.2 | |
c5c6476d ER |
11 | Summary: The official GitLab CI runner written in Go |
12 | Name: gitlab-ci-multi-runner | |
636bc11f | 13 | Version: 1.7.1 |
2635dbaf | 14 | Release: 2 |
b306b97b | 15 | License: MIT |
c5c6476d ER |
16 | Group: Development/Building |
17 | Source0: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/repository/archive.tar.gz?ref=v%{version}&/%{name}-%{version}.tar.gz | |
636bc11f | 18 | # Source0-md5: ffc78abf7e8aa4aef2778aea14d5e6a0 |
7ad949a0 | 19 | Source1: https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/master/docker/prebuilt-x86_64.tar.xz |
52f287d2 | 20 | # Source1-md5: 0d89c7578a0b5d22a4ae85dcb7d5b4f5 |
7ad949a0 | 21 | Source2: https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/master/docker/prebuilt-arm.tar.xz |
52f287d2 | 22 | # Source2-md5: c0533c581624dcb33095f08f06e6a00b |
af21cb3e ER |
23 | Source3: %{name}.init |
24 | Source4: %{name}.sysconfig | |
25 | Source5: %{name}.service | |
72cef35a | 26 | Patch0: nodim_gz.patch |
c4affa20 | 27 | Patch1: branch-preserver.patch |
c5c6476d ER |
28 | URL: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner |
29 | BuildRequires: git-core | |
72cef35a | 30 | %{?with_bindata:BuildRequires: go-bindata >= 3.0.7-1.a0ff2567} |
f81cac35 | 31 | BuildRequires: golang >= 1.4 |
98c01f80 ER |
32 | BuildRequires: rpmbuild(macros) >= 1.647 |
33 | Requires(post,preun): /sbin/chkconfig | |
34 | Requires(post,preun,postun): systemd-units >= 38 | |
fbac930f ER |
35 | Requires(postun): /usr/sbin/groupdel |
36 | Requires(postun): /usr/sbin/userdel | |
37 | Requires(pre): /bin/id | |
38 | Requires(pre): /usr/bin/getgid | |
39 | Requires(pre): /usr/sbin/groupadd | |
40 | Requires(pre): /usr/sbin/useradd | |
d20ff300 | 41 | Requires: bash |
c5c6476d ER |
42 | Requires: ca-certificates |
43 | Requires: curl | |
44 | Requires: git-core | |
98c01f80 ER |
45 | Requires: rc-scripts |
46 | Requires: systemd-units >= 0.38 | |
c5c6476d | 47 | Requires: tar |
ff1d3f82 | 48 | Suggests: docker >= 1.8 |
fbac930f ER |
49 | Provides: group(gitlab-runner) |
50 | Provides: user(gitlab-runner) | |
4ffe1735 | 51 | ExclusiveArch: %{ix86} %{x8664} %{arm} |
c5c6476d ER |
52 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
53 | ||
4ffe1735 ER |
54 | # go stuff |
55 | %define _enable_debug_packages 0 | |
56 | %define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; | |
7ad949a0 | 57 | %define import_path gitlab.com/gitlab-org/gitlab-ci-multi-runner |
4ffe1735 | 58 | |
c5c6476d ER |
59 | %description |
60 | This is the official GitLab Runner written in Go. It runs tests and | |
61 | sends the results to GitLab. GitLab CI is the open-source continuous | |
62 | integration service included with GitLab that coordinates the testing. | |
63 | ||
64 | %prep | |
65 | %setup -qc | |
c5c6476d | 66 | |
7ad949a0 ER |
67 | # for doc |
68 | mv gitlab-ci-multi-runner-*/*.md . | |
69 | ||
70 | # don't you love go? | |
71 | install -d src/$(dirname %{import_path}) | |
72 | mv gitlab-ci-multi-runner-* src/%{import_path} | |
73 | cd src/%{import_path} | |
bf2084d5 | 74 | |
72cef35a | 75 | %{!?with_bindata:%patch0 -p1} |
c4affa20 | 76 | %patch1 -p5 |
72cef35a ER |
77 | |
78 | %if %{with bindata} | |
79 | install -d out/docker | |
d16d4f3d ER |
80 | ln -s %{SOURCE1} out/docker |
81 | ln -s %{SOURCE2} out/docker | |
6ada5ccc | 82 | # touch, otherwise make rules would download it nevertheless |
7ad949a0 | 83 | touch out/docker/prebuilt-*.tar.xz |
72cef35a | 84 | %endif |
4ffe1735 | 85 | |
a0a05733 ER |
86 | # avoid docker being used even if executable found |
87 | cat <<'EOF' > docker | |
88 | #!/bin/sh | |
89 | echo >&2 "No docker" | |
90 | exit 1 | |
91 | EOF | |
92 | chmod a+rx docker | |
93 | ||
c5c6476d | 94 | %build |
7ad949a0 ER |
95 | export GOPATH=$(pwd) |
96 | cd src/%{import_path} | |
a0a05733 | 97 | export PATH=$(pwd):$PATH |
bf2084d5 | 98 | |
72cef35a | 99 | %if %{with bindata} |
7ad949a0 ER |
100 | # build docker bindata. if you forget this, you get such error: |
101 | # executors/docker/executor_docker.go:180: undefined: Asset | |
4ffe1735 | 102 | %{__make} docker |
72cef35a ER |
103 | %endif |
104 | ||
69a70248 | 105 | %{__make} version | tee version.txt |
d16d4f3d | 106 | |
7ad949a0 ER |
107 | CN=gitlab.com/gitlab-org/gitlab-ci-multi-runner/common |
108 | LDFLAGS="-X $CN.NAME=gitlab-ci-multi-runner -X $CN.VERSION=%{version} -X $CN.REVISION=%{revision}" | |
4ffe1735 | 109 | %gobuild |
c5c6476d | 110 | |
f81cac35 | 111 | # verify that version matches |
7ad949a0 | 112 | ./gitlab-ci-multi-runner -v > v |
f81cac35 ER |
113 | v=$(awk '$1 == "Version:" {print $2}' v) |
114 | test "$v" = "%{version}" | |
69a70248 | 115 | |
c5c6476d ER |
116 | %install |
117 | rm -rf $RPM_BUILD_ROOT | |
af21cb3e | 118 | install -d $RPM_BUILD_ROOT{%{_sysconfdir}/gitlab-runner,%{_bindir},/etc/{rc.d/init.d,sysconfig},%{systemdunitdir},/var/lib/gitlab-runner/.gitlab-runner} |
770719bc | 119 | |
7ad949a0 | 120 | install -p src/%{import_path}/%{name} $RPM_BUILD_ROOT%{_bindir}/gitlab-runner |
af21cb3e ER |
121 | install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name} |
122 | cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/%{name} | |
123 | cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdunitdir} | |
fbac930f | 124 | |
c2bf33c4 ER |
125 | # backward compat name for previous pld packaging |
126 | ln -s gitlab-runner $RPM_BUILD_ROOT%{_bindir}/gitlab-ci-multi-runner | |
c5c6476d | 127 | |
72cef35a ER |
128 | %if %{without bindata} |
129 | cp -p %{SOURCE1} $RPM_BUILD_ROOT/var/lib/gitlab-runner | |
130 | cp -p %{SOURCE2} $RPM_BUILD_ROOT/var/lib/gitlab-runner | |
131 | %endif | |
132 | ||
c5c6476d ER |
133 | %clean |
134 | rm -rf $RPM_BUILD_ROOT | |
135 | ||
fbac930f ER |
136 | %pre |
137 | %groupadd -g 330 gitlab-runner | |
138 | %useradd -u 330 -d /var/lib/gitlab-runner -g gitlab-runner -c "GitLab Runner" gitlab-runner | |
139 | ||
140 | %postun | |
141 | if [ "$1" = "0" ]; then | |
142 | %userremove gitlab-runner | |
143 | %groupremove gitlab-runner | |
144 | fi | |
98c01f80 ER |
145 | %systemd_reload |
146 | ||
147 | %post | |
148 | /sbin/chkconfig --add %{name} | |
149 | %service %{name} restart | |
150 | %systemd_post %{name}.service | |
151 | ||
152 | %preun | |
153 | if [ "$1" = "0" ]; then | |
154 | %service -q %{name} stop | |
155 | /sbin/chkconfig --del %{name} | |
156 | fi | |
157 | %systemd_preun %{name}.service | |
fbac930f | 158 | |
c5c6476d ER |
159 | %files |
160 | %defattr(644,root,root,755) | |
161 | %doc README.md CHANGELOG.md | |
af21cb3e ER |
162 | %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/gitlab-ci-multi-runner |
163 | %attr(754,root,root) /etc/rc.d/init.d/gitlab-ci-multi-runner | |
770719bc | 164 | %dir %attr(750,root,root) %{_sysconfdir}/gitlab-runner |
4ffe1735 | 165 | %attr(755,root,root) %{_bindir}/gitlab-ci-multi-runner |
c2bf33c4 | 166 | %attr(755,root,root) %{_bindir}/gitlab-runner |
af21cb3e | 167 | %{systemdunitdir}/gitlab-ci-multi-runner.service |
fbac930f | 168 | %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner |
dd56a935 | 169 | %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner/.gitlab-runner |
72cef35a ER |
170 | |
171 | %if %{without bindata} | |
172 | /var/lib/gitlab-runner/prebuilt-arm.tar.xz | |
173 | /var/lib/gitlab-runner/prebuilt-x86_64.tar.xz | |
174 | %endif |