831f5524a1
This PR aims to make the Makefile more DRY. Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
300 lines
6.7 KiB
Makefile
300 lines
6.7 KiB
Makefile
TOOLS ?= autonomy/tools:8fdb32d
|
|
|
|
GO_VERSION ?= 1.13
|
|
|
|
BINDIR ?= ./bin
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.3/gitmeta-linux-amd64
|
|
endif
|
|
ifeq ($(UNAME_S),Darwin)
|
|
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.3/gitmeta-darwin-amd64
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
OSCTL_DEFAULT_TARGET := osctl-linux
|
|
OSCTL_COMMAND := build/osctl-linux-amd64
|
|
endif
|
|
ifeq ($(UNAME_S),Darwin)
|
|
OSCTL_DEFAULT_TARGET := osctl-darwin
|
|
OSCTL_COMMAND := build/osctl-darwin-amd64
|
|
endif
|
|
|
|
REGISTRY ?= docker.io
|
|
USERNAME ?= autonomy
|
|
SHA ?= $(shell $(BINDIR)/gitmeta git sha)
|
|
TAG ?= $(shell $(BINDIR)/gitmeta image tag)
|
|
BRANCH ?= $(shell $(BINDIR)/gitmeta git branch)
|
|
REGISTRY_AND_USERNAME := $(REGISTRY)/$(USERNAME)
|
|
|
|
PLATFORM ?= linux/amd64
|
|
PROGRESS ?= auto
|
|
PUSH ?= false
|
|
|
|
BUILD := docker buildx build
|
|
COMMON_ARGS := --file=Dockerfile
|
|
COMMON_ARGS += --progress=$(PROGRESS)
|
|
COMMON_ARGS += --platform=$(PLATFORM)
|
|
COMMON_ARGS += --push=$(PUSH)
|
|
COMMON_ARGS += --build-arg=TOOLS=$(TOOLS)
|
|
COMMON_ARGS += --build-arg=SHA=$(SHA)
|
|
COMMON_ARGS += --build-arg=TAG=$(TAG)
|
|
COMMON_ARGS += --build-arg=GO_VERSION=$(GO_VERSION)
|
|
COMMON_ARGS += .
|
|
|
|
TESTPKGS ?= ./...
|
|
|
|
all: builddeps rootfs initramfs kernel osctl-linux osctl-darwin installer container
|
|
|
|
.PHONY: builddeps
|
|
builddeps: gitmeta
|
|
|
|
gitmeta: $(BINDIR)/gitmeta
|
|
|
|
$(BINDIR)/gitmeta:
|
|
@mkdir -p $(BINDIR)
|
|
@curl -L $(GITMETA) -o $(BINDIR)/gitmeta
|
|
@chmod +x $(BINDIR)/gitmeta
|
|
|
|
base:
|
|
@$(BUILD) \
|
|
--output type=docker,dest=build/$@.tar,name=$(REGISTRY_AND_USERNAME)/$@:$(TAG) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: generate
|
|
generate:
|
|
$(BUILD) \
|
|
--output type=local,dest=./ \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: docs
|
|
docs: $(OSCTL_DEFAULT_TARGET)
|
|
$(BUILD) \
|
|
--output type=local,dest=./ \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
@env HOME=/home/user $(OSCTL_COMMAND) docs docs/osctl
|
|
|
|
.PHONY: kernel
|
|
kernel:
|
|
@$(BUILD) \
|
|
--output type=local,dest=build \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
@-rm -rf ./build/modules
|
|
|
|
.PHONY: initramfs
|
|
initramfs:
|
|
@$(BUILD) \
|
|
--output type=local,dest=build \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: squashfs
|
|
squashfs: service-osd service-trustd service-ntpd service-networkd service-apid
|
|
@$(BUILD) \
|
|
--output type=local,dest=build \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: rootfs
|
|
rootfs: service-osd service-trustd service-ntpd service-networkd service-apid
|
|
@$(BUILD) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: installer
|
|
installer:
|
|
@mkdir -p build
|
|
@$(BUILD) \
|
|
--output type=docker,dest=build/$@.tar,name=$(REGISTRY_AND_USERNAME)/$@:$(TAG) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
@docker load < build/$@.tar
|
|
|
|
.PHONY: image-aws
|
|
image-aws:
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
install \
|
|
-n aws \
|
|
-r \
|
|
-p aws \
|
|
-u none \
|
|
-e console=tty1 \
|
|
-e console=ttyS0
|
|
@tar -C $(PWD)/build -czf $(PWD)/build/aws.tar.gz aws.raw
|
|
@rm -rf $(PWD)/build/aws.raw
|
|
|
|
.PHONY: image-azure
|
|
image-azure:
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
install \
|
|
-n azure \
|
|
-r \
|
|
-p azure \
|
|
-u none \
|
|
-e console=ttyS0,115200n8 \
|
|
-e earlyprintk=ttyS0,115200 \
|
|
-e rootdelay=300
|
|
@docker run --rm -v $(PWD)/build:/out \
|
|
--entrypoint qemu-img \
|
|
autonomy/installer:$(TAG) \
|
|
convert \
|
|
-f raw \
|
|
-o subformat=fixed,force_size \
|
|
-O vpc /out/azure.raw /out/azure.vhd
|
|
@tar -C $(PWD)/build -czf $(PWD)/build/azure.tar.gz azure.vhd
|
|
@rm -rf $(PWD)/build/azure.raw $(PWD)/build/azure.vhd
|
|
|
|
.PHONY: image-digital-ocean
|
|
image-digital-ocean:
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
install \
|
|
-n digital-ocean \
|
|
-r \
|
|
-p digital-ocean \
|
|
-u none \
|
|
-e console=ttyS0
|
|
@gzip -f $(PWD)/build/digital-ocean.raw
|
|
|
|
.PHONY: image-gcp
|
|
image-gcp:
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
install \
|
|
-n disk \
|
|
-r \
|
|
-p gcp \
|
|
-u none \
|
|
-e console=ttyS0
|
|
@tar -C $(PWD)/build -czf $(PWD)/build/gcp.tar.gz disk.raw
|
|
@rm -rf $(PWD)/build/disk.raw
|
|
|
|
.PHONY: image-vmware
|
|
image-vmware:
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
install \
|
|
-r \
|
|
-p vmware \
|
|
-u guestinfo \
|
|
-e console=tty0 \
|
|
-e earlyprintk=ttyS0,115200
|
|
@docker run --rm -v /dev:/dev -v $(PWD)/build:/out \
|
|
--privileged \
|
|
autonomy/installer:$(TAG) \
|
|
ova
|
|
@rm -rf $(PWD)/build/talos.raw
|
|
|
|
.PHONY: image-test
|
|
image-test:
|
|
@docker run --rm -v /dev:/dev -v /tmp:/out --privileged autonomy/installer:$(TAG) install -n test -r -p test -u none
|
|
|
|
push-image-%:
|
|
@TAG=$(TAG) SHA=$(SHA) ./hack/test/$*-setup.sh
|
|
|
|
.PHONY: iso
|
|
iso:
|
|
@docker run --rm -i -v $(PWD)/build:/out autonomy/installer:$(TAG) iso
|
|
|
|
.PHONY: container
|
|
container:
|
|
@$(BUILD) \
|
|
--output type=docker,dest=build/$@.tar,name=$(REGISTRY_AND_USERNAME)/talos:$(TAG) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
@docker load < build/$@.tar
|
|
|
|
.PHONY: basic-integration
|
|
basic-integration: gitmeta
|
|
@TAG=$(TAG) SHA=$(SHA) go run ./internal/test-framework/main.go basic-integration
|
|
|
|
.PHONY: capi
|
|
capi:
|
|
@TAG=$(TAG) ./hack/test/$@.sh
|
|
|
|
.PHONY: e2e-integration
|
|
e2e-integration:
|
|
@TAG=$(TAG) SHA=$(SHA) ./hack/test/$@.sh
|
|
|
|
.PHONY: unit-tests
|
|
unit-tests:
|
|
@$(BUILD) \
|
|
--target=$@ \
|
|
--output type=local,dest=./ \
|
|
--build-arg=TESTPKGS=$(TESTPKGS) \
|
|
--allow security.insecure \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: unit-tests-race
|
|
unit-tests-race:
|
|
@$(BUILD) \
|
|
--target=$@ \
|
|
--build-arg=TESTPKGS=$(TESTPKGS) \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: integration-test
|
|
integration-test:
|
|
@$(BUILD) \
|
|
--output type=local,dest=bin \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports && cd - && gofumports -w -local github.com/talos-systems/talos ."
|
|
|
|
lint-%:
|
|
@$(BUILD) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
osctl-%:
|
|
@$(BUILD) \
|
|
--output type=local,dest=build \
|
|
--target=osctl-$* \
|
|
$(COMMON_ARGS)
|
|
images:
|
|
@mkdir -p images
|
|
|
|
.PHONY: machined
|
|
machined:
|
|
@$(BUILD) \
|
|
--target=$@ \
|
|
$(COMMON_ARGS)
|
|
|
|
service-%: images
|
|
@$(BUILD) \
|
|
--output type=docker,dest=images/$*.tar,name=$(REGISTRY_AND_USERNAME)/$*:$(TAG) \
|
|
--target=$* \
|
|
$(COMMON_ARGS)
|
|
|
|
.PHONY: login
|
|
login:
|
|
@docker login --username "$(DOCKER_USERNAME)" --password "$(DOCKER_PASSWORD)"
|
|
|
|
push-%: gitmeta login
|
|
@docker push autonomy/installer:$(TAG)
|
|
@docker push autonomy/talos:$(TAG)
|
|
ifeq ($(BRANCH),master)
|
|
@docker tag autonomy/installer:$(TAG) autonomy/installer:$*
|
|
@docker tag autonomy/talos:$(TAG) autonomy/talos:$*
|
|
@docker push autonomy/installer:$*
|
|
@docker push autonomy/talos:$*
|
|
endif
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
@-rm -rf build images
|