]>
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 |
af21cb3e | 14 | Release: 1.1 |
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 |
fbac930f ER |
32 | BuildRequires: rpmbuild(macros) >= 1.202 |
33 | Requires(postun): /usr/sbin/groupdel | |
34 | Requires(postun): /usr/sbin/userdel | |
35 | Requires(pre): /bin/id | |
36 | Requires(pre): /usr/bin/getgid | |
37 | Requires(pre): /usr/sbin/groupadd | |
38 | Requires(pre): /usr/sbin/useradd | |
d20ff300 | 39 | Requires: bash |
c5c6476d ER |
40 | Requires: ca-certificates |
41 | Requires: curl | |
42 | Requires: git-core | |
43 | Requires: tar | |
ff1d3f82 | 44 | Suggests: docker >= 1.8 |
fbac930f ER |
45 | Provides: group(gitlab-runner) |
46 | Provides: user(gitlab-runner) | |
4ffe1735 | 47 | ExclusiveArch: %{ix86} %{x8664} %{arm} |
c5c6476d ER |
48 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
49 | ||
4ffe1735 ER |
50 | # go stuff |
51 | %define _enable_debug_packages 0 | |
52 | %define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; | |
7ad949a0 | 53 | %define import_path gitlab.com/gitlab-org/gitlab-ci-multi-runner |
4ffe1735 | 54 | |
c5c6476d ER |
55 | %description |
56 | This is the official GitLab Runner written in Go. It runs tests and | |
57 | sends the results to GitLab. GitLab CI is the open-source continuous | |
58 | integration service included with GitLab that coordinates the testing. | |
59 | ||
60 | %prep | |
61 | %setup -qc | |
c5c6476d | 62 | |
7ad949a0 ER |
63 | # for doc |
64 | mv gitlab-ci-multi-runner-*/*.md . | |
65 | ||
66 | # don't you love go? | |
67 | install -d src/$(dirname %{import_path}) | |
68 | mv gitlab-ci-multi-runner-* src/%{import_path} | |
69 | cd src/%{import_path} | |
bf2084d5 | 70 | |
72cef35a | 71 | %{!?with_bindata:%patch0 -p1} |
c4affa20 | 72 | %patch1 -p5 |
72cef35a ER |
73 | |
74 | %if %{with bindata} | |
75 | install -d out/docker | |
d16d4f3d ER |
76 | ln -s %{SOURCE1} out/docker |
77 | ln -s %{SOURCE2} out/docker | |
6ada5ccc | 78 | # touch, otherwise make rules would download it nevertheless |
7ad949a0 | 79 | touch out/docker/prebuilt-*.tar.xz |
72cef35a | 80 | %endif |
4ffe1735 | 81 | |
a0a05733 ER |
82 | # avoid docker being used even if executable found |
83 | cat <<'EOF' > docker | |
84 | #!/bin/sh | |
85 | echo >&2 "No docker" | |
86 | exit 1 | |
87 | EOF | |
88 | chmod a+rx docker | |
89 | ||
c5c6476d | 90 | %build |
7ad949a0 ER |
91 | export GOPATH=$(pwd) |
92 | cd src/%{import_path} | |
a0a05733 | 93 | export PATH=$(pwd):$PATH |
bf2084d5 | 94 | |
72cef35a | 95 | %if %{with bindata} |
7ad949a0 ER |
96 | # build docker bindata. if you forget this, you get such error: |
97 | # executors/docker/executor_docker.go:180: undefined: Asset | |
4ffe1735 | 98 | %{__make} docker |
72cef35a ER |
99 | %endif |
100 | ||
69a70248 | 101 | %{__make} version | tee version.txt |
d16d4f3d | 102 | |
7ad949a0 ER |
103 | CN=gitlab.com/gitlab-org/gitlab-ci-multi-runner/common |
104 | LDFLAGS="-X $CN.NAME=gitlab-ci-multi-runner -X $CN.VERSION=%{version} -X $CN.REVISION=%{revision}" | |
4ffe1735 | 105 | %gobuild |
c5c6476d | 106 | |
f81cac35 | 107 | # verify that version matches |
7ad949a0 | 108 | ./gitlab-ci-multi-runner -v > v |
f81cac35 ER |
109 | v=$(awk '$1 == "Version:" {print $2}' v) |
110 | test "$v" = "%{version}" | |
69a70248 | 111 | |
c5c6476d ER |
112 | %install |
113 | rm -rf $RPM_BUILD_ROOT | |
af21cb3e | 114 | install -d $RPM_BUILD_ROOT{%{_sysconfdir}/gitlab-runner,%{_bindir},/etc/{rc.d/init.d,sysconfig},%{systemdunitdir},/var/lib/gitlab-runner/.gitlab-runner} |
770719bc | 115 | |
7ad949a0 | 116 | install -p src/%{import_path}/%{name} $RPM_BUILD_ROOT%{_bindir}/gitlab-runner |
af21cb3e ER |
117 | install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name} |
118 | cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/%{name} | |
119 | cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdunitdir} | |
fbac930f | 120 | |
c2bf33c4 ER |
121 | # backward compat name for previous pld packaging |
122 | ln -s gitlab-runner $RPM_BUILD_ROOT%{_bindir}/gitlab-ci-multi-runner | |
c5c6476d | 123 | |
72cef35a ER |
124 | %if %{without bindata} |
125 | cp -p %{SOURCE1} $RPM_BUILD_ROOT/var/lib/gitlab-runner | |
126 | cp -p %{SOURCE2} $RPM_BUILD_ROOT/var/lib/gitlab-runner | |
127 | %endif | |
128 | ||
c5c6476d ER |
129 | %clean |
130 | rm -rf $RPM_BUILD_ROOT | |
131 | ||
fbac930f ER |
132 | %pre |
133 | %groupadd -g 330 gitlab-runner | |
134 | %useradd -u 330 -d /var/lib/gitlab-runner -g gitlab-runner -c "GitLab Runner" gitlab-runner | |
135 | ||
136 | %postun | |
137 | if [ "$1" = "0" ]; then | |
138 | %userremove gitlab-runner | |
139 | %groupremove gitlab-runner | |
140 | fi | |
141 | ||
c5c6476d ER |
142 | %files |
143 | %defattr(644,root,root,755) | |
144 | %doc README.md CHANGELOG.md | |
af21cb3e ER |
145 | %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/gitlab-ci-multi-runner |
146 | %attr(754,root,root) /etc/rc.d/init.d/gitlab-ci-multi-runner | |
770719bc | 147 | %dir %attr(750,root,root) %{_sysconfdir}/gitlab-runner |
4ffe1735 | 148 | %attr(755,root,root) %{_bindir}/gitlab-ci-multi-runner |
c2bf33c4 | 149 | %attr(755,root,root) %{_bindir}/gitlab-runner |
af21cb3e | 150 | %{systemdunitdir}/gitlab-ci-multi-runner.service |
fbac930f | 151 | %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner |
dd56a935 | 152 | %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner/.gitlab-runner |
72cef35a ER |
153 | |
154 | %if %{without bindata} | |
155 | /var/lib/gitlab-runner/prebuilt-arm.tar.xz | |
156 | /var/lib/gitlab-runner/prebuilt-x86_64.tar.xz | |
157 | %endif |