forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
675 lines (594 loc) · 19.7 KB
/
Makefile.toml
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
[config]
skip_core_tasks = true
[env]
BUILDSYS_ARCH = { script = ["uname -m"] }
BUILDSYS_ROOT_DIR = "${CARGO_MAKE_WORKING_DIRECTORY}"
BUILDSYS_BUILD_DIR = "${BUILDSYS_ROOT_DIR}/build"
BUILDSYS_PACKAGES_DIR = "${BUILDSYS_BUILD_DIR}/rpms"
BUILDSYS_IMAGES_DIR = "${BUILDSYS_BUILD_DIR}/images"
BUILDSYS_TOOLS_DIR = "${BUILDSYS_ROOT_DIR}/tools"
BUILDSYS_SOURCES_DIR = "${BUILDSYS_ROOT_DIR}/sources"
BUILDSYS_TIMESTAMP = { script = ["date +%s"] }
BUILDSYS_VERSION_BUILD = { script = ["git describe --always --dirty --exclude '*' || echo 00000000"] }
# For now, release config path can't be overridden with -e, because it's used
# later in this section. You have to edit the path here in Makefile.toml to
# use a different Release.toml.
BUILDSYS_RELEASE_CONFIG_PATH = "${BUILDSYS_ROOT_DIR}/Release.toml"
BUILDSYS_VERSION_IMAGE = { script = ["awk -F '[ =\"]+' '$1 == \"version\" {print $2}' ${BUILDSYS_RELEASE_CONFIG_PATH}"] }
# This can be overridden with -e to build a different variant from the variants/ directory
BUILDSYS_VARIANT = "aws-k8s-1.17"
# Product name used for file and directory naming
BUILDSYS_NAME = "bottlerocket"
# These can be overridden with -e to change configuration for pubsys (`cargo
# make repo`). In addition, you can set RELEASE_START_TIME to determine when
# update waves and repo metadata expiration times will start, instead of
# starting now. (This can be an RFC3339 date, or an offset like "in X
# hours/days/weeks".)
PUBLISH_EXPIRATION_POLICY_PATH = "${BUILDSYS_ROOT_DIR}/tools/pubsys/policies/repo-expiration/2w-2w-1w.toml"
PUBLISH_WAVE_POLICY_PATH = "${BUILDSYS_ROOT_DIR}/sources/updater/waves/default-waves.toml"
PUBLISH_INFRA_CONFIG_PATH = "${BUILDSYS_ROOT_DIR}/Infra.toml"
# Default repo to read from PUBLISH_INFRA_CONFIG_PATH
PUBLISH_REPO = "default"
# Default signing key to use from PUBLISH_INFRA_CONFIG_PATH
PUBLISH_KEY = "default"
# The size in GiB of the data volume in the block device mapping of registered
# AMIs. (You can also specify PUBLISH_ROOT_VOLUME_SIZE to override the root
# volume size; by default it's the image size, rounded up.)
PUBLISH_DATA_VOLUME_SIZE = "20"
# This can be overridden with -e to change the path to the file containing SSM
# parameter templates. This file determines the parameter names and values
# that will be published to SSM when you run `cargo make ssm`. See
# tools/pubsys/policies/ssm/README.md for more information.
PUBLISH_SSM_TEMPLATES_PATH = "${BUILDSYS_ROOT_DIR}/tools/pubsys/policies/ssm/defaults.toml"
# You can also set PUBLISH_REGIONS to override the list of regions from
# Infra.toml for AMI and SSM commands; it's a comma-separated list like
# "us-west-2,us-east-1".
# You can set NO_PROGRESS=true to not print progress bars during snapshot upload.
# You can use ALLOW_CLOBBER=true with the `ssm` task to make it overwrite existing values.
# (This is not required with `promote-ssm` because the intent of promotion is overwriting.)
# Disallow pulling directly Upstream URLs when lookaside cache results in MISSes as a fallback.
# To use the upstream source as fallback, override this on the command line and set it to 'true'
BUILDSYS_UPSTREAM_SOURCE_FALLBACK = "false"
# We require license checks to pass to build an image. If you're working on a
# local change and don't have license information yet, you can run with `-e
# BUILDSYS_ALLOW_FAILED_LICENSE_CHECK=true` to allow the build to continue even
# if the license check fails.
BUILDSYS_ALLOW_FAILED_LICENSE_CHECK = "false"
# This controls how many `docker build` commands we'll invoke at once.
BUILDSYS_JOBS = "8"
CARGO_HOME = "${BUILDSYS_ROOT_DIR}/.cargo"
GO_MOD_CACHE = "${BUILDSYS_ROOT_DIR}/.gomodcache"
DOCKER_BUILDKIT = "1"
[env.development]
# Certain variables are defined here to allow us to override a component value
# on the command line.
# Depends on ${BUILDSYS_ARCH}.
BUILDSYS_SDK_IMAGE = "bottlerocket/sdk-${BUILDSYS_ARCH}:v0.12.0"
# Depends on ${BUILDSYS_JOBS}.
CARGO_MAKE_CARGO_ARGS = "--jobs ${BUILDSYS_JOBS} --offline --locked"
# Depends on ${BUILDSYS_ARCH} and ${BUILDSYS_VARIANT}.
BUILDSYS_OUTPUT_DIR = "${BUILDSYS_IMAGES_DIR}/${BUILDSYS_ARCH}-${BUILDSYS_VARIANT}"
# Depends on a number of variables defined above, and each other.
BUILDSYS_VERSION_FULL="${BUILDSYS_VERSION_IMAGE}-${BUILDSYS_VERSION_BUILD}"
# These names are used as prefixes for build and repo steps.
BUILDSYS_NAME_VARIANT="${BUILDSYS_NAME}-${BUILDSYS_VARIANT}-${BUILDSYS_ARCH}"
BUILDSYS_NAME_VERSION="${BUILDSYS_NAME}-${BUILDSYS_VERSION_FULL}"
BUILDSYS_NAME_FULL="${BUILDSYS_NAME_VARIANT}-${BUILDSYS_VERSION_FULL}"
# Repo directories have subdirectories for variant/arch, so we only want version here.
PUBLISH_REPO_BASE_DIR = "${BUILDSYS_BUILD_DIR}/repos"
PUBLISH_REPO_OUTPUT_DIR = "${PUBLISH_REPO_BASE_DIR}/${BUILDSYS_NAME_VERSION}"
# The default name of registered AMIs; override by setting PUBLISH_AMI_NAME.
PUBLISH_AMI_NAME_DEFAULT = "${BUILDSYS_NAME}-${BUILDSYS_VARIANT}-${BUILDSYS_ARCH}-v${BUILDSYS_VERSION_IMAGE}-${BUILDSYS_VERSION_BUILD}"
[tasks.setup]
script = [
'''
mkdir -p ${BUILDSYS_BUILD_DIR}
mkdir -p ${BUILDSYS_OUTPUT_DIR}
mkdir -p ${BUILDSYS_PACKAGES_DIR}
mkdir -p ${GO_MOD_CACHE}
for cmd in bash curl docker gunzip ; do
if ! command -v ${cmd} >/dev/null 2>&1 ; then
echo "required program '${cmd}' not found" >&2
exit 1
fi
done
'''
]
[tasks.fetch]
dependencies = [
"fetch-sdk",
"fetch-sources",
"fetch-vendored",
]
[tasks.fetch-sdk]
dependencies = ["setup"]
script_runner = "bash"
script = [
'''
set -o pipefail
if ! docker image inspect ${BUILDSYS_SDK_IMAGE} >/dev/null 2>&1 ; then
# Let curl resolve the certificates instead of the tasks resolved bundle.
unset SSL_CERT_FILE SSL_CERT_DIR
if ! curl https://cache.bottlerocket.aws/${BUILDSYS_SDK_IMAGE}.tar.gz \
| gunzip | docker load ; then
echo "failed to load '${BUILDSYS_SDK_IMAGE}'" >&2
exit 1
fi
fi
'''
]
[tasks.fetch-sources]
dependencies = ["setup"]
script_runner = "bash"
script = [
'''
for ws in sources packages variants/* tools; do
[ -d "${ws}" ] || continue
cargo fetch --locked --manifest-path ${ws}/Cargo.toml
done
chmod -R o+r ${CARGO_HOME}
'''
]
[tasks.fetch-vendored]
dependencies = ["setup", "fetch-sdk"]
script = [
'''
${BUILDSYS_TOOLS_DIR}/docker-go \
--module-path ${BUILDSYS_SOURCES_DIR}/host-ctr \
--sdk-image ${BUILDSYS_SDK_IMAGE} \
--go-mod-cache ${GO_MOD_CACHE} \
--command "go list -mod=readonly ./... >/dev/null && go mod vendor"
'''
]
[tasks.unit-tests]
dependencies = ["setup", "fetch-sdk", "fetch-sources", "fetch-vendored"]
script = [
'''
export VARIANT="${BUILDSYS_VARIANT}"
cargo test \
${CARGO_BUILD_ARGS} \
${CARGO_MAKE_CARGO_ARGS} \
--manifest-path ${BUILDSYS_SOURCES_DIR}/Cargo.toml \
--all
# host-ctr unit tests (go)
${BUILDSYS_TOOLS_DIR}/docker-go \
--module-path ${BUILDSYS_SOURCES_DIR}/host-ctr \
--sdk-image ${BUILDSYS_SDK_IMAGE} \
--go-mod-cache ${GO_MOD_CACHE} \
--command "cd cmd/host-ctr; go test -v"
'''
]
[tasks.build-tools]
dependencies = ["setup", "fetch"]
script = [
'''
cargo install \
${CARGO_MAKE_CARGO_ARGS} \
--path tools/buildsys \
--root tools \
--force \
--quiet
'''
]
[tasks.publish-tools]
dependencies = ["setup", "fetch-sources"]
script = [
'''
cargo install \
${CARGO_MAKE_CARGO_ARGS} \
--path tools/pubsys \
--root tools \
--force \
--quiet
'''
]
[tasks.build-packages]
dependencies = ["build-tools"]
script = [
'''
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
cargo build \
${CARGO_BUILD_ARGS} \
${CARGO_MAKE_CARGO_ARGS} \
--manifest-path packages/Cargo.toml \
--all
'''
]
[tasks.build-variant]
dependencies = ["build-packages"]
script = [
'''
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
cargo build \
${CARGO_BUILD_ARGS} \
${CARGO_MAKE_CARGO_ARGS} \
--manifest-path variants/${BUILDSYS_VARIANT}/Cargo.toml
'''
]
[tasks.world-packages]
alias = "build-packages"
[tasks.world-variant]
alias = "build-variant"
[tasks.check-licenses]
dependencies = ["fetch"]
script = [
'''
[ "${BUILDSYS_ALLOW_FAILED_LICENSE_CHECK}" = "true" ] && set +e
(cd sources && cargo deny check --disable-fetch licenses)
(cd tools/buildsys && cargo deny check --disable-fetch licenses)
(cd tools/pubsys && cargo deny check --disable-fetch licenses)
set -e
'''
]
[tasks.link-clean]
dependencies = ["fetch"]
script = [
'''
for link in ${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}*; do
if [ -L "${link}" ]; then
rm ${link}
fi
done
'''
]
[tasks.link-variant]
dependencies = ["build-variant"]
script = [
'''
mkdir -p ${BUILDSYS_OUTPUT_DIR}/latest
ln -snf ../${BUILDSYS_NAME_FULL}.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}.img.lz4
ln -snf ../${BUILDSYS_NAME_FULL}-data.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-data.img.lz4
ln -snf ../${BUILDSYS_NAME_FULL}-boot.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-boot.ext4.lz4
ln -snf ../${BUILDSYS_NAME_FULL}-root.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-root.ext4.lz4
ln -snf ../${BUILDSYS_NAME_FULL}-root.verity.lz4 \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-root.verity.lz4
ln -snf ../${BUILDSYS_NAME_FULL}-migrations.tar \
${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-migrations.tar
'''
]
[tasks.build]
dependencies = [
"link-clean",
"check-licenses",
"build-variant",
"link-variant",
]
[tasks.world]
alias = "build"
# Builds a local repository based on the 'latest' built targets. Uses pubsys
# to create a repo under /build/repos, named after the arch/variant/version,
# containing subdirectories for the repo metadata and targets.
[tasks.repo]
# Rather than depend on "build", which currently rebuilds images each run, we
# check for the image files below to save time. This does mean that `cargo
# make` must be run before `cargo make repo`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
cleanup() {
[ -n "${MIGRATIONS_DIR}" ] && rm -rf "${MIGRATIONS_DIR}"
}
trap 'cleanup' EXIT
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
bootlz4="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-boot.ext4.lz4"
rootlz4="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-root.ext4.lz4"
hashlz4="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-root.verity.lz4"
if [ ! -s "${bootlz4}" ] || [ ! -s "${rootlz4}" ] || [ ! -s "${hashlz4}" ]; then
echo "Image files don't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make'" >&2
exit 1
fi
# TODO: only add migrations from Release.toml, not all
MIGRATIONS_DIR="$(mktemp -d)"
tar xpf "${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-migrations.tar" -C "${MIGRATIONS_DIR}"
ADD_MIGRATION_TARGETS=()
for file in ${MIGRATIONS_DIR}/*; do
[ -e "${file}" ] || continue
ADD_MIGRATION_TARGETS+=("--copy-target ${file}")
done
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
repo \
\
--repo "${PUBLISH_REPO}" \
--arch "${BUILDSYS_ARCH}" \
--version "${BUILDSYS_VERSION_IMAGE}" \
--variant "${BUILDSYS_VARIANT}" \
\
--boot-image "${bootlz4}" \
--root-image "${rootlz4}" \
--hash-image "${hashlz4}" \
${ADD_MIGRATION_TARGETS[*]} \
\
--repo-expiration-policy-path "${PUBLISH_EXPIRATION_POLICY_PATH}" \
--release-config-path "${BUILDSYS_RELEASE_CONFIG_PATH}" \
--wave-policy-path "${PUBLISH_WAVE_POLICY_PATH}" \
\
${RELEASE_START_TIME:+--release-start-time ${RELEASE_START_TIME}} \
\
--signing-key "${PUBLISH_KEY}" \
--outdir "${PUBLISH_REPO_OUTPUT_DIR}"
ln -sfn "${PUBLISH_REPO_OUTPUT_DIR##*/}" "${PUBLISH_REPO_BASE_DIR}/latest"
'''
]
[tasks.ami]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the image files below to save time.
# This does mean that `cargo make` must be run before `cargo make ami`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
cleanup() {
[ -f "${root_image}" ] && rm -f "${root_image}"
[ -f "${data_image}" ] && rm -f "${data_image}"
}
trap 'cleanup' EXIT
# Unlz4 the root / data images
rootlz4="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}.img.lz4"
root_image="${rootlz4%.lz4}"
datalz4="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-data.img.lz4"
data_image="${datalz4%.lz4}"
if [ ! -s "${rootlz4}" ] || [ ! -s "${datalz4}" ]; then
echo "Image files don't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make'" >&2
exit 1
fi
lz4 -df "${rootlz4}" "${root_image}"
lz4 -df "${datalz4}" "${data_image}"
# Canonicalize architecture identifier to the value recognized by EC2.
case "${BUILDSYS_ARCH,,}" in
arm64|aarch64)
arch=arm64 ;;
x86_64|amd64)
arch=x86_64 ;;
*)
arch="${BUILDSYS_ARCH}" ;;
esac
ami_output="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
ami_output_latest="${BUILDSYS_OUTPUT_DIR}/latest/${BUILDSYS_NAME_VARIANT}-amis.json"
ami_name="${PUBLISH_AMI_NAME:-${PUBLISH_AMI_NAME_DEFAULT}}"
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
ami \
\
--root-image "${root_image}" \
--data-image "${data_image}" \
${PUBLISH_ROOT_VOLUME_SIZE:+--root-volume-size "${PUBLISH_ROOT_VOLUME_SIZE}"} \
--data-volume-size "${PUBLISH_DATA_VOLUME_SIZE}" \
\
--arch "${arch}" \
--name "${ami_name}" \
--description "${PUBLISH_AMI_DESCRIPTION:-${ami_name}}" \
\
--ami-output "${ami_output}" \
\
${NO_PROGRESS:+--no-progress} \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
ln -snf "../${ami_output##*/}" "${ami_output_latest}"
'''
]
[tasks.ami-public]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make ami-public`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--grant \
--group-names all \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]
[tasks.ami-private]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make ami-private`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--revoke \
--group-names all \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]
[tasks.grant-ami]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make grant-ami`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
if [ -z "${GRANT_TO_USERS}" ] && [ -z "${GRANT_TO_GROUPS}" ]; then
echo "GRANT_TO_USERS and/or GRANT_TO_GROUPS is mandatory for grant-ami; please give a comma-separated list of user IDs or group names" >&2
exit 1
fi
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--grant \
${GRANT_TO_USERS:+--user-ids "${GRANT_TO_USERS}"} \
${GRANT_TO_GROUPS:+--group-names "${GRANT_TO_GROUPS}"} \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]
[tasks.revoke-ami]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make revoke-ami`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
if [ -z "${REVOKE_FROM_USERS}" ] && [ -z "${REVOKE_FROM_GROUPS}" ]; then
echo "REVOKE_FROM_USERS and/or REVOKE_FROM_GROUPS is mandatory for revoke-ami; please give a comma-separated list of user IDs or group names" >&2
exit 1
fi
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--revoke \
${REVOKE_FROM_USERS:+--user-ids "${REVOKE_FROM_USERS}"} \
${REVOKE_FROM_GROUPS:+--group-names "${REVOKE_FROM_GROUPS}"} \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]
[tasks.ssm]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make ssm`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
ssm \
\
--ami-input "${ami_input}" \
--arch "${BUILDSYS_ARCH}" \
--variant "${BUILDSYS_VARIANT}" \
--version "${BUILDSYS_VERSION_FULL}" \
--template-path "${PUBLISH_SSM_TEMPLATES_PATH}" \
\
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"} \
${ALLOW_CLOBBER:+--allow-clobber}
'''
]
[tasks.promote-ssm]
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
source="${SSM_SOURCE:-${BUILDSYS_VERSION_FULL}}"
target="${SSM_TARGET}"
if [ -z "${target}" ]; then
echo "SSM_TARGET is mandatory for promote-ssm; please give the version (or pointer like "latest") to which you want to promote ${source}" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
promote-ssm \
\
--arch "${BUILDSYS_ARCH}" \
--variant "${BUILDSYS_VARIANT}" \
--source "${source}" \
--target "${target}" \
--template-path "${PUBLISH_SSM_TEMPLATES_PATH}" \
\
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]
[tasks.clean]
dependencies = [
"clean-sources",
"clean-packages",
"clean-images",
"clean-repos",
]
[tasks.clean-sources]
script_runner = "bash"
script = [
'''
for ws in sources variants/* tools/{buildsys,pubsys}; do
[ -d "${ws}" ] || continue
cargo clean --manifest-path ${ws}/Cargo.toml
done
rm -f ${BUILDSYS_TOOLS_DIR}/bin/{buildsys,pubsys}
'''
]
[tasks.clean-packages]
script_runner = "bash"
script = [
'''
for ws in packages; do
[ -d "${ws}" ] || continue
cargo clean --manifest-path ${ws}/Cargo.toml
done
rm -rf ${BUILDSYS_PACKAGES_DIR}
'''
]
[tasks.clean-images]
script_runner = "bash"
script = [
'''
rm -rf ${BUILDSYS_IMAGES_DIR}
'''
]
[tasks.clean-repos]
script_runner = "bash"
script = [
'''
rm -rf ${PUBLISH_REPO_BASE_DIR}
'''
]
[tasks.default]
alias = "build"