-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (90 loc) · 3.39 KB
/
Makefile
File metadata and controls
110 lines (90 loc) · 3.39 KB
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
BUILD_TAGS = containers_image_openpgp
TOOLSDIR := $(shell pwd)/hack/tools
PATH := bin:$(TOOLSDIR)/bin:$(PATH)
# OCI registry
ZOT := $(TOOLSDIR)/bin/zot
ZOT_VERSION := 2.0.0-rc5
# OCI registry clients
ORAS := $(TOOLSDIR)/bin/oras
ORAS_VERSION := 1.0.0-rc.1
REGCTL := $(TOOLSDIR)/bin/regctl
REGCTL_VERSION := 0.5.0
TOPDIR := $(shell git rev-parse --show-toplevel)
BOOTKIT_VERSION ?= "v0.0.19.231225"
ROOTFS_VERSION = $(BOOTKIT_VERSION)
archout = $(shell arch)
ifeq ("$(archout)", "aarch64")
arch = arm64
else ifeq ("$(archout)", "x86_64")
arch = amd64
else
#error "Unsupported architecture: $(archout)"
endif
CLEAN_VERSION ?= $(shell git describe --abbrev=0)
MAIN_VERSION ?= $(shell git describe --always --dirty || echo no-git)
ifeq ($(MAIN_VERSION),$(filter $(MAIN_VERSION), "", no-git))
$(error "Bad value for MAIN_VERSION: '$(MAIN_VERSION)'")
endif
GO_SRC=$(shell find cmd pkg -name "*.go")
all: mosctl mosb trust $(ZOT) $(ORAS) $(REGCTL)
VERSION_LDFLAGS=-X github.com/project-machine/mos/pkg/mosconfig.Version=$(MAIN_VERSION) \
-X github.com/project-machine/mos/pkg/trust.Version=$(MAIN_VERSION) \
-X github.com/project-machine/mos/pkg/trust.RelVersion=$(CLEAN_VERSION) \
-X github.com/project-machine/mos/pkg/mosconfig.LayerVersion=0.0.4 \
-X github.com/project-machine/mos/pkg/trust.BootkitVersion=$(BOOTKIT_VERSION)
mosctl: .made-gofmt $(GO_SRC)
go build -tags "$(BUILD_TAGS)" -ldflags "-s -w $(VERSION_LDFLAGS)" ./cmd/mosctl
mosb: .made-gofmt $(GO_SRC)
go build -tags "$(BUILD_TAGS)" -ldflags "-s -w $(VERSION_LDFLAGS)" ./cmd/mosb
trust: .made-gofmt $(GO_SRC)
go build -tags "$(BUILD_TAGS)" -ldflags "-s -w $(VERSION_LDFLAGS)" ./cmd/trust
$(ZOT):
mkdir -p $(TOOLSDIR)/bin
curl -Lo $(ZOT) https://github.com/project-zot/zot/releases/download/v$(ZOT_VERSION)/zot-linux-${arch}-minimal
chmod +x $(ZOT)
$(ORAS):
mkdir -p $(TOOLSDIR)/bin
curl -Lo oras.tar.gz https://github.com/oras-project/oras/releases/download/v$(ORAS_VERSION)/oras_$(ORAS_VERSION)_linux_$(arch).tar.gz
tar xvzf oras.tar.gz -C $(TOOLSDIR)/bin oras
rm oras.tar.gz
$(REGCTL):
mkdir -p $(TOOLSDIR)/bin
curl -Lo $(REGCTL) https://github.com/regclient/regclient/releases/download/v$(REGCTL_VERSION)/regctl-linux-$(arch)
chmod +x $(REGCTL)
.PHONY: gofmt
gofmt: .made-gofmt
.made-gofmt: $(GO_SRC)
@o=$$(gofmt -l -w cmd pkg 2>&1) || \
{ r=$$?; echo "gofmt failed [$$r]: $$o" 1>&2; exit $$r; }; \
[ -z "$$o" ] || { echo "gofmt made changes: $$o" 1>&2; exit 1; }
@touch $@
deps: mosctl mosb trust $(ORAS) $(REGCTL) $(ZOT)
STACKER_SUBS = \
--substitute ROOTFS_VERSION=$(BOOTKIT_VERSION) \
--substitute TOPDIR=${TOPDIR} \
--substitute ZOT_VERSION=$(ZOT_VERSION)
STACKER_OPTS = --layer-type=squashfs $(STACKER_SUBS)
.PHONY: layers
layers: mosctl
stacker build $(STACKER_OPTS) --stacker-file layers/provision/stacker.yaml
stacker build $(STACKER_OPTS) --stacker-file layers/install/stacker.yaml
.PHONY: test
test: deps
rm -rf ~/.local/share/machine.fortests
bats tests/install.bats
bats tests/rfs.bats
bats tests/activate.bats
bats tests/update.bats
bats tests/mount.bats
bats tests/keyset.bats
bats tests/launch.bats
# the trust testcases only, for running on amd64. We need an arm64
# runner capable of doing nested virt if we're going to have github
# actions run the mos tests for arm64, and we don't have that. Yet.
.PHONY: test-trust
test-trust: trust
bats tests/keyset.bats
clean:
rm -f mosb mosctl trust
rm -rf $(TOOLSDIR)
stacker clean