]> git.pld-linux.org Git - packages/gitlab-runner.git/blob - gitlab-ci-multi-runner.spec
rel 2; added initscripts
[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:        2
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.4
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:       curl
44 Requires:       git-core
45 Requires:       rc-scripts
46 Requires:       systemd-units >= 0.38
47 Requires:       tar
48 Suggests:       docker >= 1.8
49 Provides:       group(gitlab-runner)
50 Provides:       user(gitlab-runner)
51 ExclusiveArch:  %{ix86} %{x8664} %{arm}
52 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
53
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 %{?**};
57 %define import_path     gitlab.com/gitlab-org/gitlab-ci-multi-runner
58
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
66
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}
74
75 %{!?with_bindata:%patch0 -p1}
76 %patch1 -p5
77
78 %if %{with bindata}
79 install -d out/docker
80 ln -s %{SOURCE1} out/docker
81 ln -s %{SOURCE2} out/docker
82 # touch, otherwise make rules would download it nevertheless
83 touch out/docker/prebuilt-*.tar.xz
84 %endif
85
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
94 %build
95 export GOPATH=$(pwd)
96 cd src/%{import_path}
97 export PATH=$(pwd):$PATH
98
99 %if %{with bindata}
100 # build docker bindata. if you forget this, you get such error:
101 # executors/docker/executor_docker.go:180: undefined: Asset
102 %{__make} docker
103 %endif
104
105 %{__make} version | tee version.txt
106
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}"
109 %gobuild
110
111 # verify that version matches
112 ./gitlab-ci-multi-runner -v > v
113 v=$(awk '$1 == "Version:" {print $2}' v)
114 test "$v" = "%{version}"
115
116 %install
117 rm -rf $RPM_BUILD_ROOT
118 install -d $RPM_BUILD_ROOT{%{_sysconfdir}/gitlab-runner,%{_bindir},/etc/{rc.d/init.d,sysconfig},%{systemdunitdir},/var/lib/gitlab-runner/.gitlab-runner}
119
120 install -p src/%{import_path}/%{name} $RPM_BUILD_ROOT%{_bindir}/gitlab-runner
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}
124
125 # backward compat name for previous pld packaging
126 ln -s gitlab-runner $RPM_BUILD_ROOT%{_bindir}/gitlab-ci-multi-runner
127
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
133 %clean
134 rm -rf $RPM_BUILD_ROOT
135
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
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
158
159 %files
160 %defattr(644,root,root,755)
161 %doc README.md CHANGELOG.md
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
164 %dir %attr(750,root,root) %{_sysconfdir}/gitlab-runner
165 %attr(755,root,root) %{_bindir}/gitlab-ci-multi-runner
166 %attr(755,root,root) %{_bindir}/gitlab-runner
167 %{systemdunitdir}/gitlab-ci-multi-runner.service
168 %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner
169 %dir %attr(750,gitlab-runner,gitlab-runner) /var/lib/gitlab-runner/.gitlab-runner
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
This page took 0.059945 seconds and 3 git commands to generate.