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