@@ -39,7 +39,6 @@ all: docker
39
39
gobuild :
40
40
./scripts/build false
41
41
42
-
43
42
# create output directories
44
43
.out-stamp :
45
44
mkdir -p ./out/test-artifacts ./out/cni-plugins ./out/amazon-ecs-cni-plugins ./out/amazon-vpc-cni-plugins
@@ -49,6 +48,9 @@ gobuild:
49
48
static :
50
49
./scripts/build
51
50
51
+ static-with-pause :
52
+ ./scripts/build true " " false true
53
+
52
54
# Cross-platform build target for static checks
53
55
xplatform-build :
54
56
GOOS=linux GOARCH=arm64 ./scripts/build true " " false
@@ -119,6 +121,10 @@ gogenerate:
119
121
go generate -x ./agent/...
120
122
$(MAKE ) goimports
121
123
124
+ gogenerate-init :
125
+ PATH=$(PATH ) :$(shell pwd) /scripts go generate -x ./ecs-init/...
126
+ $(MAKE ) goimports
127
+
122
128
# 'go' may not be on the $PATH for sudo tests
123
129
GO_EXECUTABLE =$(shell command -v go 2> /dev/null)
124
130
@@ -140,6 +146,10 @@ test:
140
146
${GOTEST} -tags unit -coverprofile cover.out -timeout=60s ./agent/...
141
147
go tool cover -func cover.out > coverprofile.out
142
148
149
+ test-init :
150
+ go test -count=1 -short -v -coverprofile cover.out ./ecs-init/...
151
+ go tool cover -func cover.out > coverprofile-init.out
152
+
143
153
test-silent :
144
154
$(eval VERBOSE=)
145
155
${GOTEST} -tags unit -coverprofile cover.out -timeout=60s ./agent/...
@@ -149,6 +159,10 @@ test-silent:
149
159
analyze-cover-profile : coverprofile.out
150
160
./scripts/analyze-cover-profile
151
161
162
+ .PHONY : analyze-cover-profile-init
163
+ analyze-cover-profile-init : coverprofile-init.out
164
+ ./scripts/analyze-cover-profile-init
165
+
152
166
run-integ-tests : test-registry gremlin container-health-check-image run-sudo-tests
153
167
ECS_LOGLEVEL=debug ${GOTEST} -tags integration -timeout=30m ./agent/...
154
168
@@ -158,7 +172,6 @@ run-sudo-tests:
158
172
benchmark-test :
159
173
go test -run=XX -bench=. ./agent/...
160
174
161
-
162
175
.PHONY : build-image-for-ecr upload-images replicate-images
163
176
164
177
build-image-for-ecr : netkitten volumes-test image-cleanup-test-images fluentd exec-command-agent-test
@@ -223,6 +236,20 @@ cni-plugins: get-cni-sources .out-stamp build-ecs-cni-plugins build-vpc-cni-plug
223
236
mv $(PWD ) /out/amazon-vpc-cni-plugins/* $(PWD ) /out/cni-plugins
224
237
@echo " Built all cni plugins successfully."
225
238
239
+ # dockerfree build process will build the agent container image from scratch
240
+ # requires glibc-static -- we precompile amd/arm to the misc/pause-container/pause-image-tar-files/ directory
241
+ dockerfree-pause :
242
+ ./scripts/build-pause
243
+
244
+ dockerfree-certs :
245
+ ./scripts/get-host-certs
246
+
247
+ dockerfree-cni-plugins : get-cni-sources
248
+ ./scripts/build-cni-plugins
249
+
250
+ # see dockerfree-pause above: assumes that the pre-compiled pause container tar exists
251
+ dockerfree-agent-image : dockerfree-certs dockerfree-cni-plugins static-with-pause
252
+ ./scripts/build-agent-image
226
253
227
254
.PHONY : codebuild
228
255
codebuild : .out-stamp
@@ -259,7 +286,6 @@ image-cleanup-test-images:
259
286
container-health-check-image :
260
287
$(MAKE ) -C misc/container-health $(MFLAGS )
261
288
262
-
263
289
# all .go files in the agent, excluding vendor/, model/ and testutils/ directories, and all *_test.go and *_mocks.go files
264
290
GOFILES: =$(shell go list -f '{{$$p := .}}{{range $$f := .GoFiles}}{{$$p.Dir}}/{{$$f}} {{end}}' ./agent/... \
265
291
| grep -v /testutils/ | grep -v _test\.go$ | grep -v _mocks\.go$ | grep -v /model)
@@ -286,12 +312,23 @@ gogenerate-check: gogenerate
286
312
# check that gogenerate does not generate a diff.
287
313
git diff --exit-code
288
314
315
+ .PHONY : gogenerate-check-init
316
+ gogenerate-check-init : gogenerate-init
317
+ # check that gogenerate does not generate a diff.
318
+ git diff --exit-code
319
+
289
320
.PHONY : static-check
290
321
static-check : gocyclo govet importcheck gogenerate-check
291
322
# use default checks of staticcheck tool, except style checks (-ST*) and depracation checks (-SA1019)
292
323
# depracation checks have been left out for now; removing their warnings requires error handling for newer suggested APIs, changes in function signatures and their usages.
293
324
# https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
294
- staticcheck -tests=false -checks " inherit,-ST*,-SA1019,-SA9002" ./agent/...
325
+ staticcheck -tests=false -checks " inherit,-ST*,-SA1019,-SA9002,-SA4006" ./agent/...
326
+
327
+ .PHONY : static-check-init
328
+ static-check-init : gocyclo govet importcheck gogenerate-check-init
329
+ # use default checks of staticcheck tool, except style checks (-ST*)
330
+ # https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
331
+ staticcheck -tests=false -checks " inherit,-ST*" ./ecs-init/...
295
332
296
333
.PHONY : goimports
297
334
goimports :
@@ -309,24 +346,154 @@ GOPATH=$(shell go env GOPATH)
309
346
310
347
get-deps : .get-deps-stamp
311
348
349
+ get-deps-init :
350
+ go get golang.org/x/tools/cover
351
+ go get golang.org/x/tools/cmd/cover
352
+ go get github.com/golang/mock/mockgen
353
+ cd " ${GOPATH} /src/github.com/golang/mock/mockgen" && git checkout 1.3.1 && go get ./... && go install ./... && cd -
354
+ GO111MODULE=on go get github.com/fzipp/gocyclo/cmd/
[email protected]
355
+ go get golang.org/x/tools/cmd/goimports
356
+ GO111MODULE=on go get honnef.co/go/tools/cmd/
[email protected]
357
+
358
+ amazon-linux-sources.tgz :
359
+ ./scripts/update-version.sh
360
+ cp packaging/amazon-linux-ami-integrated/ecs-init.spec ecs-init.spec
361
+ cp packaging/amazon-linux-ami-integrated/ecs-agent.spec ecs-agent.spec
362
+ cp packaging/amazon-linux-ami-integrated/ecs.conf ecs.conf
363
+ cp packaging/amazon-linux-ami-integrated/ecs.service ecs.service
364
+ cp packaging/amazon-linux-ami-integrated/amazon-ecs-volume-plugin.conf amazon-ecs-volume-plugin.conf
365
+ cp packaging/amazon-linux-ami-integrated/amazon-ecs-volume-plugin.service amazon-ecs-volume-plugin.service
366
+ cp packaging/amazon-linux-ami-integrated/amazon-ecs-volume-plugin.socket amazon-ecs-volume-plugin.socket
367
+ tar -czf ./sources.tgz ecs-init scripts misc agent amazon-ecs-cni-plugins amazon-vpc-cni-plugins agent-container VERSION
368
+
369
+ .amazon-linux-rpm-integrated-done : amazon-linux-sources.tgz
370
+ test -e SOURCES || ln -s . SOURCES
371
+ rpmbuild --define " %_topdir $( PWD) " -bb ecs-init.spec
372
+ find RPMS/ -type f -exec cp {} . \;
373
+ touch .amazon-linux-rpm-integrated-done
374
+
375
+ amazon-linux-rpm-integrated : .amazon-linux-rpm-integrated-done
376
+
377
+ .generic-rpm-integrated-done : get-cni-sources
378
+ ./scripts/update-version.sh
379
+ cp packaging/generic-rpm-integrated/amazon-ecs-init.spec amazon-ecs-init.spec
380
+ cp packaging/generic-rpm-integrated/ecs.service ecs.service
381
+ cp packaging/generic-rpm-integrated/amazon-ecs-volume-plugin.service amazon-ecs-volume-plugin.service
382
+ cp packaging/generic-rpm-integrated/amazon-ecs-volume-plugin.socket amazon-ecs-volume-plugin.socket
383
+ tar -czf ./sources.tgz ecs-init scripts misc agent amazon-ecs-cni-plugins amazon-vpc-cni-plugins agent-container VERSION
384
+ test -e SOURCES || ln -s . SOURCES
385
+ rpmbuild --define " %_topdir $( PWD) " -bb amazon-ecs-init.spec
386
+ find RPMS/ -type f -exec cp {} . \;
387
+ touch .generic-rpm-integrated-done
388
+
389
+ generic-rpm-integrated : .generic-rpm-integrated-done
390
+
391
+ VERSION = $(shell cat ecs-init/ECSVERSION)
392
+
393
+ .generic-deb-integrated-done : get-cni-sources
394
+ mkdir -p BUILDROOT
395
+ ./scripts/update-version.sh
396
+ tar -czf ./amazon-ecs-init_${VERSION} .orig.tar.gz ecs-init scripts README.md
397
+ cp -r packaging/generic-deb-integrated/debian ecs-init scripts misc agent agent-container amazon-ecs-cni-plugins amazon-vpc-cni-plugins README.md VERSION BUILDROOT
398
+ cd BUILDROOT && debuild -uc -us --lintian-opts --suppress-tags bad-distribution-in-changes-file,file-in-unusual-dir
399
+ touch .generic-deb-integrated-done
400
+
401
+ generic-deb-integrated : .generic-deb-integrated-done
402
+
403
+ ARCH: =$(shell uname -m)
404
+ ifeq (${ARCH},x86_64)
405
+ AGENT_FILENAME=ecs-agent-v${VERSION}.tar
406
+ else ifeq (${ARCH},aarch64)
407
+ AGENT_FILENAME=ecs-agent-arm64-v${VERSION}.tar
408
+ # osx M1 instances
409
+ else ifeq (${ARCH},arm64)
410
+ AGENT_FILENAME=ecs-agent-arm64-v${VERSION}.tar
411
+ endif
412
+
413
+ BUILDROOT/ecs-agent.tar :
414
+ mkdir -p BUILDROOT
415
+ curl -o BUILDROOT/ecs-agent.tar https://s3.amazonaws.com/amazon-ecs-agent/${AGENT_FILENAME}
416
+
417
+ ${AGENT_FILENAME} : BUILDROOT/ecs-agent.tar
418
+ cp BUILDROOT/ecs-agent.tar ${AGENT_FILENAME}
419
+
420
+ rpm-in-docker : ${AGENT_FILENAME}
421
+ docker build -t " amazon/amazon-ecs-init:build" -f " scripts/dockerfiles/build.dockerfile" .
422
+ docker run -u " $( shell id -u) " --tmpfs /.cache -v " $( shell pwd) :/workspace/amazon-ecs-init" " amazon/amazon-ecs-init:build"
423
+
424
+ .generic-rpm-done : ${AGENT_FILENAME}
425
+ ./scripts/update-version.sh
426
+ cp packaging/generic-rpm/amazon-ecs-init.spec amazon-ecs-init.spec
427
+ cp packaging/generic-rpm/ecs.service ecs.service
428
+ cp packaging/generic-rpm/amazon-ecs-volume-plugin.service amazon-ecs-volume-plugin.service
429
+ cp packaging/generic-rpm/amazon-ecs-volume-plugin.socket amazon-ecs-volume-plugin.socket
430
+ tar -czf ./sources.tgz ecs-init scripts
431
+ test -e SOURCES || ln -s . SOURCES
432
+ rpmbuild --define " %_topdir $( PWD) " -bb amazon-ecs-init.spec
433
+ find RPMS/ -type f -exec cp {} . \;
434
+ touch .generic-rpm-done
435
+
436
+ generic-rpm : .generic-rpm-done
437
+
438
+ .deb-done : BUILDROOT/ecs-agent.tar
439
+ ./scripts/update-version.sh
440
+ tar -czf ./amazon-ecs-init_${VERSION} .orig.tar.gz ecs-init scripts README.md
441
+ cp -r packaging/generic-deb/debian ecs-init scripts README.md BUILDROOT
442
+ cd BUILDROOT && debuild -uc -us --lintian-opts --suppress-tags bad-distribution-in-changes-file,file-in-unusual-dir
443
+ touch .deb-done
444
+
445
+ .PHONY : deb
446
+ deb : .deb-done
447
+
312
448
clean :
449
+ rm -f misc/certs/host-certs.crt & > /dev/null
450
+ rm -rf misc/pause-container/image/
451
+ rm -rf misc/pause-container/rootfs/
452
+ rm -rf misc/plugins/
453
+ rm -rf out/
454
+ rm -rf rootfs/
455
+ -$(MAKE ) -C $(ECS_CNI_REPOSITORY_SRC_DIR ) clean
456
+ -rm -f .get-deps-stamp
457
+ -rm -f .builder-image-stamp
458
+ -rm -f .out-stamp
459
+ -rm -rf $(PWD ) /bin
460
+ -rm -rf cover.out
461
+ -rm -rf coverprofile.out
462
+ -rm -rf coverprofile-init.out
463
+ # ecs-init & rpm cleanup
464
+ -rm -f ecs-init.spec
465
+ -rm -f amazon-ecs-init.spec
466
+ -rm -f ecs.conf
467
+ -rm -f ecs.service
468
+ -rm -f amazon-ecs-volume-plugin.conf
469
+ -rm -f amazon-ecs-volume-plugin.service
470
+ -rm -f amazon-ecs-volume-plugin.socket
471
+ -rm -rf ./bin
472
+ -rm -f ./sources.tgz
473
+ -rm -f ./amazon-ecs-init
474
+ -rm -f ./ecs-init/ecs-init
475
+ -rm -f ./amazon-ecs-init-* .rpm
476
+ -rm -f ./ecs-agent-* .tar
477
+ -rm -f ./ecs-init-* .src.rpm
478
+ -rm -rf ./ecs-init-*
479
+ -rm -rf ./BUILDROOT BUILD RPMS SRPMS SOURCES SPECS
480
+ -rm -rf ./x86_64
481
+ -rm -f ./amazon-ecs-init_${VERSION} *
482
+ -rm -f .srpm-done .rpm-done .generic-rpm-done
483
+ -rm -f .deb-done
484
+ -rm -f .amazon-linux-rpm-integrated-done
485
+ -rm -f .generic-rpm-integrated-done
486
+ -rm -f amazon-ecs-volume-plugin
487
+
488
+ clean-all : clean
489
+ # for our dockerfree builds, we likely don't have docker
313
490
# ensure docker is running and we can talk to it, abort if not:
314
491
docker ps > /dev/null
315
492
-docker rmi $(BUILDER_IMAGE ) " amazon/amazon-ecs-agent-cleanbuild:make"
316
493
-docker rmi $(BUILDER_IMAGE ) " amazon/amazon-ecs-agent-cleanbuild-windows:make"
317
- rm -f misc/certs/ca-certificates.crt & > /dev/null
318
- rm -rf out/
319
- -$(MAKE ) -C $(ECS_CNI_REPOSITORY_SRC_DIR ) clean
320
494
-$(MAKE ) -C misc/netkitten $(MFLAGS ) clean
321
495
-$(MAKE ) -C misc/volumes-test $(MFLAGS ) clean
322
496
-$(MAKE ) -C misc/exec-command-agent-test $(MFLAGS ) clean
323
497
-$(MAKE ) -C misc/gremlin $(MFLAGS ) clean
324
498
-$(MAKE ) -C misc/image-cleanup-test-images $(MFLAGS ) clean
325
499
-$(MAKE ) -C misc/container-health $(MFLAGS ) clean
326
- -rm -f .get-deps-stamp
327
- -rm -f .builder-image-stamp
328
- -rm -f .out-stamp
329
- -rm -rf $(PWD ) /bin
330
- -rm -rf cover.out
331
- -rm -rf coverprofile.out
332
-
0 commit comments