-
Notifications
You must be signed in to change notification settings - Fork 5
/
barney.yaml
345 lines (314 loc) · 10.5 KB
/
barney.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
---
# yamllint disable rule:line-length
generators:
go: barney.ci/golang%generator
images:
internal/bootstrap/extract/sources:
units:
- files:
- from: .
paths:
- 'bootstrap/extract/extract.bash'
- 'bootstrap/extract/CHECKSUM'
internal/bootstrap/extract/floor:
entry:
mutables:
- /var/work
units:
- image: barney.ci/alpine%pkg/alpine-base
- image: barney.ci/alpine%pkg/bash
- image: barney.ci/alpine%pkg/wget
- image: barney.ci/alpine%network
- image: barney.ci/alpine%apk-finalizers
- image: .%internal/bootstrap/extract/sources
internal/bootstrap/extract:
no-create-mountpoints: true
description: |
Minimal bootstrapping environment used to bootstrap almalinux.
This needs to be based off of an rpm-based distro,
we're using CentOS-stream as a suitable tarball and CHECKSUM file
is readily available on the mirror. This is seldom changed and
any change here will update all eext snapshots.
We wipe out the dnf/yum repo configuration in the tarball.
entry:
share-net: true
mounts:
- source: /etc/resolv.conf
target: /etc/resolv.conf
options: ro,bind
mutables:
- /var/cache
- /var/lib/dnf
units:
- floor: .%internal/bootstrap/extract/floor
entry:
env:
DNF_HOST: ${eext-dnf-host.url:-https://artifactory.infra.corp.arista.io/artifactory}
sources: []
build: |
cd /var/work
bash /bootstrap/extract/extract.bash /bootstrap/extract/CHECKSUM
touch $DESTDIR/etc/resolv.conf
internal/bootstrap/eext-repos/sources:
units:
- files:
- from: .
match:
- 'bootstrap/eext-repos/*'
- 'pki/rpmkeys/alma9-b86b3716-gpg-pubkey.pem'
- 'pki/rpmkeys/epel9-3228467c-gpg-pubkey.pem'
internal/bootstrap/eext-repos/floor:
description: |
Alpine floor with the eext-repos src directory mapped in.
gettext provides envsubst used by generate-repo-file.bash called from generate.bash
rpm-dev provides rpmbuild used by generate.bash.
entry:
mutables:
- /var/work
- /var/tmp
units:
- image: barney.ci/alpine%pkg/alpine-base
- image: barney.ci/alpine%pkg/bash
- image: barney.ci/alpine%pkg/gettext
- image: barney.ci/alpine%pkg/rpm-dev
- image: barney.ci/alpine%apk-finalizers
- image: .%internal/bootstrap/eext-repos/sources
- sources: []
build: |
mkdir -p /dest/var/work
internal/bootstrap/eext-repos:
no-create-mountpoints: true
description: |
Setup curated frozen dnf repo list for build reproducibility.
There're two files, eext-repo-build.repo and eext-repo-devel.repo. These files are
installed in /eext-repos directory.
We also install the eext-repo-build.repo in /etc/yum.repos.d to be used for base image
bootstrap.
We also build an rpm each with the contents being the repo file,
and instructions to install at /etc/yum.repos.d.
The RPMs are named eext-repos-build and eext-repos-devel with approiate architecture
and .rpm extensions. They are installed in /RPMS.
units:
- floor: .%internal/bootstrap/eext-repos/floor
entry:
env:
DNF_HOST: ${eext-dnf-host.url:-https://artifactory.infra.corp.arista.io/artifactory}
sources: []
build: |
cd /var/work
# First argument is collaterals dir, further args are pem files
bash /bootstrap/eext-repos/generate.bash /bootstrap/eext-repos /pki/rpmkeys/alma9-b86b3716-gpg-pubkey.pem /pki/rpmkeys/epel9-3228467c-gpg-pubkey.pem
internal/bootstrap/install-rpms/sources/common:
no-create-mountpoints: true
description: |
install-rpms script and common rpms list
units:
- files:
- from: .
paths:
- 'bootstrap/install-rpms/install-rpms.bash'
- 'bootstrap/install-rpms/rpms-common'
internal/bootstrap/install-rpms/sources/build:
no-create-mountpoints: true
description: |
build specific rpms list
units:
- files:
- from: .
paths:
- 'bootstrap/install-rpms/rpms-build'
internal/bootstrap/install-rpms/sources/devel:
no-create-mountpoints: true
description: |
devel/test specific rpms list
units:
- files:
- from: .
paths:
- 'bootstrap/install-rpms/rpms-devel'
internal/bootstrap/dnf-dirs:
no-create-mountpoints: true
description: |
Setup empty directories needed by dnf
units:
- sources: []
build: |
mkdir -p /dest/var/lib/dnf
chmod 755 /dest/var/lib/dnf
internal/bootstrap-build:
description: |
Final bootstrap layer used as floor for build images
units:
- image: .%internal/bootstrap/dnf-dirs
- image: .%internal/bootstrap/extract
- image: .%internal/bootstrap/eext-repos
- image: .%internal/bootstrap/install-rpms/sources/common
- image: .%internal/bootstrap/install-rpms/sources/build
internal/bootstrap-devel:
description: |
Final bootstrap layer used as floor for devel images
units:
- image: .%internal/bootstrap/dnf-dirs
- image: .%internal/bootstrap/extract
- image: .%internal/bootstrap/eext-repos
- image: .%internal/bootstrap/install-rpms/sources/common
- image: .%internal/bootstrap/install-rpms/sources/devel
base-image-build:
units:
- floor: .%internal/bootstrap-build
sources: []
build: |
echo "install rpms"
bash /bootstrap/install-rpms/install-rpms.bash \
/bootstrap/install-rpms/rpms-common \
/bootstrap/install-rpms/rpms-build
base-image-devel:
units:
- floor: .%internal/bootstrap-devel
sources: []
build: |
bash /bootstrap/install-rpms/install-rpms.bash \
/bootstrap/install-rpms/rpms-common \
/bootstrap/install-rpms/rpms-devel
go-buildfloor:
description: |
Build floor for the eext go binary.
This buildfloor is used to manually run go build instead of using
the go generator to avoid adding the repo commit hash into the
snapshot hash.
TODO: We cannot use .%go/modules here as one of the image units
because that also maps in all the sources to run go mod tidy.
As a workaround, we're turning on the network and foregoing any
benefits from the go generator's cache.
units:
- image: barney.ci/golang%dev
- image: barney.ci/alpine%network
entry:
mutables:
- /go/pkg/mod
go-sources:
description: |
Image with source files need to build the eext static binary.
units:
- files:
- from: .
match:
- 'go.mod'
- 'go.sum'
- 'main.go'
- 'cmd/*.go'
- 'dnfconfig/*.go'
- 'impl/*.go'
- 'manifest/*.go'
- 'srcconfig/*.go'
- 'util/*.go'
go-binaries:
description: |
We avoid using the go generator directly for two reasons:
1. We want redhat style directory permissions of 0555
2. We want to present a filtered view of sources, mapping in only
the go sources. This makes sure we use a content hash of the go sources
and not the SHA of the repo to generate the snapshot hash of .%go-binaries.
units:
- sources: []
mappings:
/src: .%go-sources
floor: .%go-buildfloor
build: |
mkdir -p /dest/usr/bin
chmod 0555 /dest/usr/bin
cd /src
CGO_ENABLED=0 go build -o /dest/usr/bin -ldflags '-extldflags "-static"' ./...
src/configfiles:
description: |
Configuration files for eext
units:
- files:
- from: .
match:
- 'configfiles/*'
src/pki:
description: |
pki files for eext
units:
- files:
- from: .
match:
- 'pki/**/*'
- 'pki/**/**/*'
eext-staticfiles:
no-create-mountpoints: true
units:
- mappings:
/src/1: .%src/configfiles
/src/2: .%src/pki
sources: []
build: |
mkdir -p $DESTDIR/usr/share/eext
cp /src/1/configfiles/* $DESTDIR/usr/share/eext
mkdir -p $DESTDIR/etc/pki/eext
cp -a /src/2/pki/* $DESTDIR/etc/pki/eext
eext:
units:
- image: .%base-image-build
- image: .%go-binaries
- image: .%eext-staticfiles
- sources: []
build: |
mkdir -p $DESTDIR/etc
touch $DESTDIR/etc/resolv.conf
entry:
mutables: &eext-mutables
- /var/eext
- /var/cache
- /var/lib/mock
- /var/lib/rpm
- /var/tmp
mounts:
- source: /etc/resolv.conf
target: /etc/resolv.conf
options: ro,bind
# We need access to artifactory.infra.corp.arista.io
# to make mock work
share-net: true
eext-testfloor:
units:
- image: .%go/modules
- build: |
mkdir -p /dest/var/cache/go
mkdir -p /dest/var/ext
- floor: .%internal/bootstrap-devel
sources: []
build: |
bash /bootstrap/install-rpms/install-rpms.bash \
/bootstrap/install-rpms/rpms-common \
/bootstrap/install-rpms/rpms-devel
touch $DESTDIR/etc/resolv.conf
entry:
env:
GOCACHE: /tmp/gocache
GOMODCACHE: /go/pkg/mod
mutables: *eext-mutables
mounts:
- source: /etc/resolv.conf
target: /etc/resolv.conf
options: ro,bind
# We need access to artifactory.infra.corp.arista.io
# to make mock work
share-net: true
test/eext:
units:
- floor: .%eext-testfloor
build: |
go test code.arista.io/eos/tools/eext/dnfconfig -tags containerized
go test code.arista.io/eos/tools/eext/srcconfig -tags containerized
go test code.arista.io/eos/tools/eext/manifest -tags containerized
go test code.arista.io/eos/tools/eext/impl -tags containerized
go test code.arista.io/eos/tools/eext/cmd -tags "privileged containerized"
go vet code.arista.io/eos/tools/eext/...
test -z "$(gofmt -l .)"
# go test runs on separate test-floor
# so validate build here
test/eext-build:
units:
- image: .%eext