@@ -7,20 +7,24 @@ PREFIX ?= $(CURDIR)/_output
7
7
DEST := $(shell echo "$(DESTDIR ) /$(PREFIX ) " | sed 's:///* :/:g; s://* $$::')
8
8
BINDIR ?= /usr/local/bin
9
9
OUTDIR ?= $(CURDIR ) /_output
10
+ OS_OUTDIR ?= $(OUTDIR ) /os
11
+
12
+ OUTPUT_DIRECTORIES := $(OUTDIR ) $(OS_OUTDIR )
13
+ $(OUTPUT_DIRECTORIES ) :
14
+ @mkdir -p $@
15
+
10
16
PACKAGE := github.com/runfinch/finch
11
17
BINARYNAME := finch
12
18
LIMA_FILENAME := lima
13
19
LIMA_EXTENSION := .tar.gz
14
20
15
- LIMA_HOME := $(DEST ) /lima/data
16
21
# Created by the CLI after installation, only used in uninstall step
17
22
LIMA_VDE_SUDOERS_FILE := /etc/sudoers.d/finch-lima
18
23
# Final installation prefix for vde created by CLI after installation, only used in uninstall step
19
24
VDE_INSTALL ?= /opt/finch
20
25
UNAME := $(shell uname -m)
21
26
ARCH ?= $(UNAME )
22
27
SUPPORTED_ARCH = false
23
- CORE_VDE_PREFIX ?= $(OUTDIR ) /dependencies/vde/opt/finch
24
28
LICENSEDIR := $(OUTDIR ) /license-files
25
29
VERSION := $(shell git describe --match 'v[0-9]* ' --dirty='.modified' --always --tags)
26
30
GITCOMMIT := $(shell git rev-parse HEAD)$(shell test -z "$(git status --porcelain ) " || echo .m)
@@ -30,9 +34,6 @@ MIN_MACOS_VERSION ?= 11.0
30
34
GOOS ?= $(shell $(GO ) env GOOS)
31
35
ifeq ($(GOOS ) ,windows)
32
36
BINARYNAME := $(addsuffix .exe, $(BINARYNAME ) )
33
- sha = sha256sum
34
- else
35
- sha = shasum -a 256
36
37
endif
37
38
38
39
.DEFAULT_GOAL := all
@@ -42,129 +43,31 @@ REGISTRY ?= ""
42
43
ifneq (,$(findstring arm64,$(ARCH ) ) )
43
44
SUPPORTED_ARCH = true
44
45
LIMA_ARCH = aarch64
45
- # From https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/aarch64/images/
46
- FINCH_OS_BASENAME ?= Fedora-Cloud-Base-40-1.14.aarch64-20240514214641.qcow2
47
- LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1715678889.tar.gz
48
46
else ifneq (,$(findstring x86_64,$(ARCH)))
49
47
SUPPORTED_ARCH = true
50
48
LIMA_ARCH = x86_64
51
- # From https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/
52
- FINCH_OS_BASENAME ?= Fedora-Cloud-Base-40-1.14.x86_64-20240514214655.qcow2
53
- LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1715678889.tar.gz
54
- FINCH_ROOTFS_URL ?= https://deps.runfinch.com/common/x86-64/finch-rootfs-production-amd64-1715724303.tar.gz
55
- FINCH_ROOTFS_BASENAME := $(notdir $(FINCH_ROOTFS_URL))
56
49
endif
57
50
58
- FINCH_OS_HASH := ` $( sha) $( OUTDIR) /os/$( FINCH_OS_BASENAME) | cut -d ' ' -f 1`
59
- FINCH_OS_DIGEST := "sha256:$(FINCH_OS_HASH ) "
60
- FINCH_OS_IMAGE_LOCATION_ROOT ?= $(DEST )
61
- FINCH_OS_IMAGE_LOCATION ?= $(FINCH_OS_IMAGE_LOCATION_ROOT ) /os/$(FINCH_OS_BASENAME )
62
-
63
- # TODO: Windows PoC extracting rootfs...
64
- FINCH_ROOTFS_HASH := ` $( sha) $( OUTDIR) /os/$( FINCH_ROOTFS_BASENAME) | cut -d ' ' -f 1`
65
- FINCH_ROOTFS_DIGEST := "sha256:$(FINCH_ROOTFS_HASH ) "
66
- FINCH_ROOTFS_LOCATION_ROOT ?= $(DEST ) /
67
- FINCH_ROOTFS_LOCATION ?= $(FINCH_ROOTFS_LOCATION_ROOT ) os/$(FINCH_ROOTFS_BASENAME )
68
-
69
51
.PHONY : arch-test
70
52
arch-test :
71
53
@if [ $( SUPPORTED_ARCH) != " true" ]; then echo " Unsupported architecture: $( ARCH) " ; exit " 1" ; fi
72
54
73
- .PHONY : all
74
- ifeq ($(GOOS ) ,windows)
75
- all : arch-test finch finch-core-local finch.windows.yaml networks.yaml config.yaml
55
+ BUILD_OS ?= $(OS )
56
+ FINCH_CORE_DIR := $(CURDIR ) /deps/finch-core
57
+ ifeq ($(BUILD_OS ) , Windows_NT)
58
+ include Makefile.windows
76
59
else
77
- all : arch-test finch finch-core finch.yaml networks.yaml config.yaml lima-and-qemu
60
+ include Makefile.darwin
78
61
endif
79
62
80
- .PHONY : all-local
81
- all-local : arch-test networks.yaml config.yaml lima-and-qemu local-core finch.yaml
82
-
83
- .PHONY : finch-core
84
- finch-core :
85
- cd deps/finch-core && \
86
- FINCH_OS_AARCH64_URL=" $( FINCH_OS_AARCH64_URL) " \
87
- VDE_TEMP_PREFIX=$(CORE_VDE_PREFIX ) \
88
- " $( MAKE) "
89
-
90
- mkdir -p _output
91
- cd deps/finch-core/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)
92
- rm -rf $(OUTDIR)/lima-template
93
-
94
- .PHONY : finch-core-local
95
- finch-core-local :
96
- cd deps/finch-core && \
97
- FINCH_OS_x86_URL=" $( FINCH_OS_x86_URL) " \
98
- FINCH_OS_AARCH64_URL=" $( FINCH_OS_AARCH64_URL) " \
99
- VDE_TEMP_PREFIX=$(CORE_VDE_PREFIX ) \
100
- " $( MAKE) " all lima
101
-
102
- mkdir -p _output
103
- cd deps/finch-core/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)
104
- rm -rf $(OUTDIR)/lima-template
105
-
106
- .PHONY : local-core
107
- local-core :
108
- cd deps/finch-core && \
109
- FINCH_OS_x86_URL=" $( FINCH_OS_x86_URL) " \
110
- FINCH_OS_AARCH64_URL=" $( FINCH_OS_AARCH64_URL) " \
111
- VDE_TEMP_PREFIX=$(CORE_VDE_PREFIX ) \
112
- " $( MAKE) " lima lima-socket-vmnet
113
-
114
- mkdir -p _output
115
- cd deps/finch-core/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)
116
- cd deps/finch-core/src/lima/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)/lima
117
- cd deps/finch-core/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)
118
- cd deps/finch-core/src/lima/_output && tar -cf - * | tar -xvf - -C $(OUTDIR)/lima
119
- rm -rf $(OUTDIR)/lima-template
120
-
121
- .PHONY : lima-and-qemu
122
- lima-and-qemu : networks.yaml
123
- mkdir -p $(OUTDIR ) /downloads
124
- # download artifacts
125
- curl -L $(LIMA_URL ) > $(OUTDIR ) /downloads/lima-and-qemu.tar.gz
126
-
127
- # Untar LIMA
128
- tar -xvf $(OUTDIR)/downloads/lima-and-qemu.tar.gz -C $(OUTDIR)/lima/
129
-
130
- # Delete downloads
131
- rm -rf $(OUTDIR)/downloads
132
-
133
-
134
- FINCH_IMAGE_LOCATION ?=
135
- FINCH_IMAGE_DIGEST ?=
136
- ifeq ($(GOOS ) ,windows)
137
- # Because the path in windows /C:/<some-path> is not an Absolute path, prefix with file:/ which is handled by lima https://github.com/lima-vm/lima/blob/da1260dc87fb30345c3ee7bfb131c29646e26d10/pkg/downloader/downloader.go#L266
138
- FINCH_IMAGE_LOCATION := "file:/$(FINCH_ROOTFS_LOCATION)"
139
- FINCH_IMAGE_DIGEST := $(FINCH_ROOTFS_DIGEST)
140
- else
141
- FINCH_IMAGE_LOCATION := $(FINCH_OS_IMAGE_LOCATION)
142
- FINCH_IMAGE_DIGEST := $(FINCH_OS_DIGEST)
143
- endif
144
- .PHONY : finch.yaml
145
- finch.yaml : finch-core
146
- mkdir -p $(OUTDIR ) /os
147
- # merge the appropriate YAMLs
148
- cd finch.yaml.d && yq eval-all ' . as $$item ireduce ({}; . *+ $$item)' mac.yaml common.yaml > ../finch.yaml
149
- cp finch.yaml $(OUTDIR ) /os
150
- # using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
151
- # this sed command uses the alternative separator of "|" because the image location uses "/"
152
- sed -i.bak -e " s|<finch_image_location>|$( FINCH_IMAGE_LOCATION) |g" $(OUTDIR ) /os/finch.yaml
153
- sed -i.bak -e " s/<finch_image_arch>/$( LIMA_ARCH) /g" $(OUTDIR ) /os/finch.yaml
154
- sed -i.bak -e " s/<finch_image_digest>/$( FINCH_IMAGE_DIGEST) /g" $(OUTDIR ) /os/finch.yaml
155
-
156
- # TODO: Windows PoC - clean this up / consolidate
63
+ all : arch-test finch install.finch-core-dependencies finch.yaml networks.yaml config.yaml
64
+
65
+ .PHONY : install.finch-core-dependencies
66
+ install.finch-core-dependencies :
67
+ OUTDIR=$(OUTDIR ) " $( MAKE) " -C $(FINCH_CORE_DIR ) install.dependencies
68
+
157
69
.PHONY : finch.yaml
158
- finch.windows.yaml : finch-core-local
159
- mkdir -p $(OUTDIR ) /os
160
- # merge the appropriate YAMLs
161
- cd finch.yaml.d && yq eval-all ' . as $$item ireduce ({}; . *+ $$item)' windows.yaml common.yaml > ../finch.windows.yaml
162
- cp finch.windows.yaml $(OUTDIR ) /os/finch.yaml
163
- # using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
164
- # this sed command uses the alternative separator of "|" because the image location uses "/"
165
- sed -i.bak -e " s|<finch_image_location>|$( FINCH_IMAGE_LOCATION) |g" $(OUTDIR ) /os/finch.yaml
166
- sed -i.bak -e " s/<finch_image_arch>/$( LIMA_ARCH) /g" $(OUTDIR ) /os/finch.yaml
167
- sed -i.bak -e " s/<finch_image_digest>/$( FINCH_IMAGE_DIGEST) /g" $(OUTDIR ) /os/finch.yaml
70
+ finch.yaml : $(OS_OUTDIR ) /finch.yaml
168
71
169
72
.PHONY : networks.yaml
170
73
networks.yaml :
@@ -402,7 +305,7 @@ mdlint-ctr:
402
305
ifeq ($(GOOS ) ,windows)
403
306
clean :
404
307
-@rm -rf $(OUTDIR ) 2> /dev/null || true
405
- -@rm -rf ./deps/finch-core/_output || true
308
+ -@" $( MAKE ) " -C $( FINCH_CORE_DIR ) clean
406
309
-@rm ./* .tar.gz 2> /dev/null || true
407
310
-@rm ./* .qcow2 2> /dev/null || true
408
311
-@rm ./test-coverage.* 2> /dev/null || true
@@ -415,8 +318,7 @@ clean:
415
318
-sudo rm -rf " /private/var/run/finch-lima"
416
319
-sudo rm -rf " /private/etc/sudoers.d/finch-lima"
417
320
-@rm -rf $(OUTDIR ) 2> /dev/null || true
418
- -@rm -rf ./deps/finch-core/_output || true
419
- -@rm -rf ./deps/finch-core/downloads/os/$(FINCH_OS_BASENAME ) || true
321
+ -@$(MAKE ) -C $(FINCH_CORE_DIR ) clean
420
322
-@rm ./* .tar.gz 2> /dev/null || true
421
323
-@rm ./* .qcow2 2> /dev/null || true
422
324
-@rm ./test-coverage.* 2> /dev/null || true
0 commit comments