3 %bcond_with prebuilt # use prebuilt binary
5 %define helper_revision 05161b14
6 Summary: The official GitLab CI runner written in Go
11 Group: Development/Building
12 Source0: https://gitlab.com/gitlab-org/gitlab-runner/-/archive/v%{version}/gitlab-runner-v%{version}.tar.bz2
13 # Source0-md5: a249bfae11074f3922a6c1f72fa5fa9d
15 Source1: https://gitlab-runner-downloads.s3.amazonaws.com/v%{version}/binaries/gitlab-runner-linux-amd64
16 # Source1-md5: 2fc56f01f932a14a807e37195d08bcf2
19 Source4: %{name}.sysconfig
20 Source5: %{name}.service
21 Patch0: nodim_gz.patch
22 Patch1: branch-preserver.patch
23 URL: https://gitlab.com/gitlab-org/gitlab-runner
24 BuildRequires: git-core
25 BuildRequires: golang >= 1.9.4
26 BuildRequires: rpmbuild(macros) >= 1.647
27 Requires(post,preun): /sbin/chkconfig
28 Requires(post,preun,postun): systemd-units >= 38
29 Requires(postun): /usr/sbin/groupdel
30 Requires(postun): /usr/sbin/userdel
31 Requires(pre): /bin/id
32 Requires(pre): /usr/bin/getgid
33 Requires(pre): /usr/sbin/groupadd
34 Requires(pre): /usr/sbin/useradd
36 Requires: ca-certificates
39 Requires: systemd-units >= 0.38
41 Suggests: docker >= 1.8
42 Suggests: gitlab-runner-image-arm
43 Suggests: gitlab-runner-image-x86_64
44 Provides: group(gitlab-runner)
45 Provides: user(gitlab-runner)
46 Obsoletes: gitlab-ci-multi-runner < 10.0
47 ExclusiveArch: %{ix86} %{x8664} %{arm}
48 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
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 %{?debug:-x} %{?**};
53 %define import_path gitlab.com/gitlab-org/gitlab-runner
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.
64 mv gitlab-runner-*/*.md .
67 install -d src/$(dirname %{import_path})
68 mv gitlab-runner-* src/%{import_path}
76 # avoid docker being used even if executable found
87 export PATH=$(pwd):$PATH
89 %if %{without prebuilt}
90 %{__make} version | tee version.txt
92 CN=gitlab.com/gitlab-org/gitlab-runner/common
93 DT=$(date -u +%%Y-%%m-%%dT%%H:%%M:%%S%%:z)
94 LDFLAGS="-X $CN.VERSION=%{version} -X $CN.REVISION=%{helper_revision} -X $CN.BRANCH=v%{version} -X $CN.BUILT=$DT"
97 install -p %{SOURCE1} gitlab-runner
100 # verify that version matches
101 ./gitlab-runner -v > v
102 v=$(awk '$1 == "Version:" {print $2}' v)
103 test "$v" = "%{version}"
106 rm -rf $RPM_BUILD_ROOT
107 install -d $RPM_BUILD_ROOT{%{_sysconfdir}/gitlab-runner,%{_bindir},/etc/{rc.d/init.d,sysconfig},%{systemdunitdir},/var/lib/gitlab-runner/.gitlab-runner}
109 install -p src/%{import_path}/%{name} $RPM_BUILD_ROOT%{_bindir}/gitlab-runner
110 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
111 cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
112 cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdunitdir}
115 rm -rf $RPM_BUILD_ROOT
118 %groupadd -g 330 gitlab-runner
119 %useradd -u 330 -d /var/lib/gitlab-runner -g gitlab-runner -c "GitLab Runner" gitlab-runner
122 if [ "$1" = "0" ]; then
123 %userremove gitlab-runner
124 %groupremove gitlab-runner
129 /sbin/chkconfig --add %{name}
130 %service %{name} restart
131 %systemd_post %{name}.service
134 if [ "$1" = "0" ]; then
135 %service -q %{name} stop
136 /sbin/chkconfig --del %{name}
138 %systemd_preun %{name}.service
141 %defattr(644,root,root,755)
142 %doc README.md CHANGELOG.md
143 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/gitlab-runner
144 %attr(754,root,root) /etc/rc.d/init.d/gitlab-runner
145 %dir %attr(750,root,root) %{_sysconfdir}/gitlab-runner
146 %attr(755,root,root) %{_bindir}/gitlab-runner
147 %{systemdunitdir}/gitlab-runner.service
148 %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner
149 %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner/.gitlab-runner