2019-10-25 19:32:53 +03:00
TOOLS ?= autonomy/tools:8fdb32d
2019-04-19 05:31:43 +03:00
2019-10-16 07:50:06 +03:00
GO_VERSION ?= 1.13
2019-04-29 21:51:39 +03:00
2019-12-24 20:28:58 +03:00
BINDIR ?= ./bin
2019-02-15 07:32:00 +03:00
UNAME_S := $( shell uname -s)
2019-04-24 04:52:31 +03:00
2019-06-05 21:44:15 +03:00
i f e q ( $( UNAME_S ) , L i n u x )
2019-10-17 00:17:28 +03:00
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.3/gitmeta-linux-amd64
2019-06-05 21:44:15 +03:00
e n d i f
i f e q ( $( UNAME_S ) , D a r w i n )
2019-10-17 00:17:28 +03:00
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.3/gitmeta-darwin-amd64
2019-06-05 21:44:15 +03:00
e n d i f
2019-12-10 20:44:07 +03:00
i f e q ( $( UNAME_S ) , L i n u x )
OSCTL_DEFAULT_TARGET := osctl-linux
OSCTL_COMMAND := build/osctl-linux-amd64
e n d i f
i f e q ( $( UNAME_S ) , D a r w i n )
OSCTL_DEFAULT_TARGET := osctl-darwin
OSCTL_COMMAND := build/osctl-darwin-amd64
e n d i f
2019-12-23 21:36:14 +03:00
REGISTRY ?= docker.io
USERNAME ?= autonomy
2019-07-15 22:00:31 +03:00
SHA ?= $( shell $( BINDIR) /gitmeta git sha)
TAG ?= $( shell $( BINDIR) /gitmeta image tag)
2019-08-17 23:21:20 +03:00
BRANCH ?= $( shell $( BINDIR) /gitmeta git branch)
2019-12-23 21:36:14 +03:00
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 += .
2019-04-24 04:52:31 +03:00
2019-07-23 17:17:16 +03:00
TESTPKGS ?= ./...
2019-12-24 20:28:58 +03:00
all : builddeps rootfs initramfs kernel osctl -linux osctl -darwin installer container
2019-04-29 19:25:04 +03:00
2019-02-15 07:32:00 +03:00
.PHONY : builddeps
2019-12-23 21:36:14 +03:00
builddeps : gitmeta
2019-02-15 07:32:00 +03:00
2019-06-05 21:44:15 +03:00
gitmeta : $( BINDIR ) /gitmeta
$(BINDIR)/gitmeta :
@mkdir -p $( BINDIR)
@curl -L $( GITMETA) -o $( BINDIR) /gitmeta
@chmod +x $( BINDIR) /gitmeta
2019-02-15 07:32:00 +03:00
2019-12-23 21:36:14 +03:00
base :
@$( BUILD) \
--output type = docker,dest= build/$@ .tar,name= $( REGISTRY_AND_USERNAME) /$@ :$( TAG) \
--target= $@ \
2019-04-24 04:52:31 +03:00
$( COMMON_ARGS)
2019-08-09 06:45:13 +03:00
.PHONY : generate
2019-12-23 21:36:14 +03:00
generate :
$( BUILD) \
2019-08-17 07:26:08 +03:00
--output type = local,dest= ./ \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-08-09 06:45:13 +03:00
$( COMMON_ARGS)
2019-11-09 18:22:43 +03:00
.PHONY : docs
2019-12-23 21:36:14 +03:00
docs : $( OSCTL_DEFAULT_TARGET )
$( BUILD) \
2019-11-09 18:22:43 +03:00
--output type = local,dest= ./ \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-11-09 18:22:43 +03:00
$( COMMON_ARGS)
2019-12-10 20:44:07 +03:00
@env HOME = /home/user $( OSCTL_COMMAND) docs docs/osctl
2019-11-09 18:22:43 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : kernel
2019-12-23 21:36:14 +03:00
kernel :
@$( BUILD) \
2019-08-17 07:26:08 +03:00
--output type = local,dest= build \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-16 08:44:59 +03:00
@-rm -rf ./build/modules
2019-01-18 06:14:52 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : initramfs
2019-12-23 21:36:14 +03:00
initramfs :
@$( BUILD) \
2019-08-17 07:26:08 +03:00
--output type = local,dest= build \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-10-31 01:52:36 +03:00
.PHONY : squashfs
2019-12-24 20:28:58 +03:00
squashfs : service -osd service -trustd service -ntpd service -networkd service -apid
2019-12-23 21:36:14 +03:00
@$( BUILD) \
2019-10-31 01:52:36 +03:00
--output type = local,dest= build \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-10-31 01:52:36 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : rootfs
2019-12-24 20:28:58 +03:00
rootfs : service -osd service -trustd service -ntpd service -networkd service -apid
2019-12-23 21:36:14 +03:00
@$( BUILD) \
--target= $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : installer
2019-12-23 21:36:14 +03:00
installer :
2019-02-28 05:57:35 +03:00
@mkdir -p build
2019-12-23 21:36:14 +03:00
@$( BUILD) \
--output type = docker,dest= build/$@ .tar,name= $( REGISTRY_AND_USERNAME) /$@ :$( TAG) \
--target= $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 19:41:41 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : image -aws
image-aws :
2019-09-10 01:21:58 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
2019-12-24 20:28:58 +03:00
--privileged \
2019-09-10 01:21:58 +03:00
autonomy/installer:$( TAG) \
install \
-n aws \
-r \
-p aws \
2019-09-10 15:19:28 +03:00
-u none \
-e console = tty1 \
-e console = ttyS0
2019-09-10 01:21:58 +03:00
@tar -C $( PWD) /build -czf $( PWD) /build/aws.tar.gz aws.raw
@rm -rf $( PWD) /build/aws.raw
2019-04-30 20:21:51 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : image -azure
image-azure :
2019-07-27 11:09:50 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
2019-12-24 20:28:58 +03:00
--privileged \
2019-07-27 11:09:50 +03:00
autonomy/installer:$( TAG) \
install \
2019-08-09 06:45:13 +03:00
-n azure \
2019-07-27 11:09:50 +03:00
-r \
-p azure \
-u none \
2019-09-10 15:19:28 +03:00
-e console = ttyS0,115200n8 \
-e earlyprintk = ttyS0,115200 \
2019-07-27 11:09:50 +03:00
-e rootdelay = 300
2019-12-24 20:28:58 +03:00
@docker run --rm -v $( PWD) /build:/out \
2019-07-27 11:09:50 +03:00
--entrypoint qemu-img \
autonomy/installer:$( TAG) \
convert \
-f raw \
-o subformat = fixed,force_size \
2019-08-09 06:45:13 +03:00
-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
2019-10-28 18:43:59 +03:00
.PHONY : image -digital -ocean
image-digital-ocean :
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
2019-12-24 20:28:58 +03:00
--privileged \
2019-10-28 18:43:59 +03:00
autonomy/installer:$( TAG) \
install \
-n digital-ocean \
-r \
-p digital-ocean \
-u none \
-e console = ttyS0
2019-11-03 21:29:14 +03:00
@gzip -f $( PWD) /build/digital-ocean.raw
2019-10-28 18:43:59 +03:00
2019-08-12 00:38:24 +03:00
.PHONY : image -gcp
image-gcp :
2019-08-17 07:26:08 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
2019-12-24 20:28:58 +03:00
--privileged \
2019-08-17 07:26:08 +03:00
autonomy/installer:$( TAG) \
install \
-n disk \
-r \
2019-08-12 00:38:24 +03:00
-p gcp \
2019-09-10 15:19:28 +03:00
-u none \
-e console = ttyS0
2019-08-12 00:38:24 +03:00
@tar -C $( PWD) /build -czf $( PWD) /build/gcp.tar.gz disk.raw
2019-08-28 04:58:29 +03:00
@rm -rf $( PWD) /build/disk.raw
2019-08-09 06:45:13 +03:00
2019-09-13 23:10:47 +03:00
.PHONY : image -vmware
image-vmware :
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
2019-12-24 20:28:58 +03:00
--privileged \
2019-09-13 23:10:47 +03:00
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 \
2019-12-24 20:28:58 +03:00
--privileged \
2019-09-13 23:10:47 +03:00
autonomy/installer:$( TAG) \
ova
2019-11-01 01:24:28 +03:00
@rm -rf $( PWD) /build/talos.raw
2019-09-13 23:10:47 +03:00
2019-08-11 20:29:45 +03:00
.PHONY : image -test
image-test :
2019-12-24 20:28:58 +03:00
@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
2019-04-05 07:34:58 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : iso
iso :
@docker run --rm -i -v $( PWD) /build:/out autonomy/installer:$( TAG) iso
.PHONY : container
2019-12-23 21:36:14 +03:00
container :
@$( BUILD) \
--output type = docker,dest= build/$@ .tar,name= $( REGISTRY_AND_USERNAME) /talos:$( TAG) \
--target= $@ \
2019-04-05 07:34:58 +03:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 19:41:41 +03:00
2019-06-22 09:05:17 +03:00
.PHONY : basic -integration
2019-12-04 18:22:36 +03:00
basic-integration : gitmeta
@TAG= $( TAG) SHA = $( SHA) go run ./internal/test-framework/main.go basic-integration
2019-04-28 22:06:03 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : capi
capi :
2019-08-02 18:05:34 +03:00
@TAG= $( TAG) ./hack/test/$@ .sh
2019-08-09 06:45:13 +03:00
.PHONY : e 2e -integration
2019-06-22 09:05:17 +03:00
e2e-integration :
2019-10-29 23:23:05 +03:00
@TAG= $( TAG) SHA = $( SHA) ./hack/test/$@ .sh
2019-06-17 19:36:48 +03:00
2019-08-09 06:45:13 +03:00
.PHONY : unit -tests
2019-12-23 21:36:14 +03:00
unit-tests :
@$( BUILD) \
--target= $@ \
2019-07-18 23:05:26 +03:00
--output type = local,dest= ./ \
2019-12-23 21:36:14 +03:00
--build-arg= TESTPKGS = $( TESTPKGS) \
--allow security.insecure \
2019-08-07 01:08:27 +03:00
$( COMMON_ARGS)
2019-08-09 06:45:13 +03:00
.PHONY : unit -tests -race
2019-12-23 21:36:14 +03:00
unit-tests-race :
@$( BUILD) \
--target= $@ \
--build-arg= TESTPKGS = $( TESTPKGS) \
2019-07-04 18:43:34 +03:00
$( COMMON_ARGS)
2019-04-16 00:41:11 +03:00
2019-10-25 22:57:52 +03:00
.PHONY : integration -test
2019-12-23 21:36:14 +03:00
integration-test :
@$( BUILD) \
2019-10-25 22:57:52 +03:00
--output type = local,dest= bin \
2019-12-23 21:36:14 +03:00
--target= $@ \
2019-10-25 22:57:52 +03:00
$( COMMON_ARGS)
2019-09-12 00:32:07 +03:00
.PHONY : fmt
fmt :
2019-09-12 17:32:42 +03:00
@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 ."
2019-09-12 00:32:07 +03:00
2019-12-24 20:28:58 +03:00
lint-% :
2019-12-23 21:36:14 +03:00
@$( BUILD) \
--target= $@ \
2019-08-28 00:45:59 +03:00
$( COMMON_ARGS)
2019-12-24 20:28:58 +03:00
osctl-% :
2019-12-23 21:36:14 +03:00
@$( BUILD) \
2019-08-17 07:26:08 +03:00
--output type = local,dest= build \
2019-12-24 20:28:58 +03:00
--target= osctl-$* \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-12-24 20:28:58 +03:00
images :
@mkdir -p images
2019-01-19 12:58:26 +03:00
2019-07-16 18:09:35 +03:00
.PHONY : machined
2019-12-24 20:28:58 +03:00
machined :
2019-12-23 21:36:14 +03:00
@$( BUILD) \
--target= $@ \
2019-10-24 05:31:18 +03:00
$( COMMON_ARGS)
2019-12-24 20:28:58 +03:00
service-% : images
2019-12-23 21:36:14 +03:00
@$( BUILD) \
2019-12-24 20:28:58 +03:00
--output type = docker,dest= images/$* .tar,name= $( REGISTRY_AND_USERNAME) /$* :$( TAG) \
--target= $* \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-12 09:40:30 +03:00
.PHONY : login
login :
@docker login --username " $( DOCKER_USERNAME) " --password " $( DOCKER_PASSWORD) "
2019-11-27 18:39:53 +03:00
push-% : gitmeta login
2019-04-12 09:40:30 +03:00
@docker push autonomy/installer:$( TAG)
@docker push autonomy/talos:$( TAG)
2019-08-17 23:21:20 +03:00
i f e q ( $( BRANCH ) , m a s t e r )
2019-11-27 18:39:53 +03:00
@docker tag autonomy/installer:$( TAG) autonomy/installer:$*
@docker tag autonomy/talos:$( TAG) autonomy/talos:$*
@docker push autonomy/installer:$*
@docker push autonomy/talos:$*
2019-08-17 23:21:20 +03:00
e n d i f
2019-04-12 09:40:30 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : clean
2018-12-20 09:22:05 +03:00
clean :
2019-12-24 20:28:58 +03:00
@-rm -rf build images