33
44# TODO: Use Finch rootfs in Finch on Windows testing
55ROOTFS_OUTPUT_DIR := $(OUTDIR)/os
6+ LIMA_TEMPLATE_OUTDIR := $(OUTDIR)/lima-template
7+ LIMA_TEMPLATE := $(LIMA_TEMPLATE_OUTDIR)/windows.yaml
68CRED_HELPERS_OUTDIR := $(OUTDIR)/cred-helpers
7- OUTPUT_DIRECTORIES += $(ROOTFS_OUTPUT_DIR) $(CRED_HELPERS_OUTDIR)
9+ OUTPUT_DIRECTORIES += $(ROOTFS_OUTPUT_DIR) $(LIMA_TEMPLATE_OUTDIR) $( CRED_HELPERS_OUTDIR)
810
911include $(CURDIR)/deps/rootfs.conf
1012ifeq ($(ARCH), x86_64)
1113FINCH_ROOTFS_BASENAME := $(X86_64_ARTIFACT)
1214FINCH_ROOTFS_DIGEST := $(X86_64_512_DIGEST)
15+ LIMA_ARCH = x86_64
1316else
1417$(error Finch on Windows ARM not supported)
1518endif
1619
20+ # WSL2 imports the locally downloaded rootfs tarball rather than booting a disk image.
21+ FINCH_IMAGE_LOCATION ?= $(ROOTFS_OUTPUT_DIR)/$(FINCH_ROOTFS_BASENAME)
22+ FINCH_IMAGE_DIGEST ?= "sha512:$(FINCH_ROOTFS_DIGEST)"
23+
24+ # rootfs.conf sets X86_64_ARTIFACT_PATHING for the rootfs download; clear it so it
25+ # does not leak into the container-runtime artifact URL below.
26+ X86_64_ARTIFACT_PATHING :=
27+ include $(CURDIR)/deps/container-runtime-full-archive.conf
28+ ifneq ($(X86_64_ARTIFACT_PATHING),)
29+ X86_64_ARTIFACT := "$(X86_64_ARTIFACT_PATHING)/$(X86_64_ARTIFACT)"
30+ endif
31+ CONTAINER_RUNTIME_ARCHIVE_X86_64_LOCATION ?= "$(ARTIFACT_BASE_URL)/$(X86_64_ARTIFACT)"
32+ CONTAINER_RUNTIME_ARCHIVE_X86_64_DIGEST ?= "sha256:$(X86_64_256_DIGEST)"
33+
1734# WSL2 is the only virtual machine type supported for Finch on Windows
1835FINCH_VM_TYPE := wsl2
1936
@@ -22,14 +39,32 @@ WINGIT_x86_URL := $(or $(WINGIT_x86_URL),https://github.com/git-for-windows/git/
2239WINGIT_x86_BASENAME ?= $(notdir $(WINGIT_x86_URL))
2340WINGIT_x86_HASH := $(or $(WINGIT_x86_HASH),"sha512:795a2e7e0be5ab78f2d28d0bd971961d121b9c808a95dec795343dc5af943574dcf54f63a8580c5a5102075abdae387d7a67135c165821428afc07f11ef7543d")
2441
25- install.dependencies: install.rootfs install.lima install.docker-credhelper
42+ install.dependencies: install.rootfs install.lima install.lima-template install. docker-credhelper
2643
2744.PHONY: install.rootfs
2845install.rootfs: $(ROOTFS_OUTPUT_DIR)/$(FINCH_ROOTFS_BASENAME)
2946
3047$(ROOTFS_OUTPUT_DIR)/$(FINCH_ROOTFS_BASENAME): $(ROOTFS_OUTPUT_DIR) $(CURDIR)/deps/rootfs.conf
3148 bash deps/install.sh --arch $(ARCH) --output $@ $(CURDIR)/deps/rootfs.conf
3249
50+ .PHONY: install.lima-template
51+ install.lima-template: $(LIMA_TEMPLATE)
52+
53+ $(LIMA_TEMPLATE): $(LIMA_TEMPLATE_OUTDIR)
54+ cp lima-template/windows.yaml $@.template
55+ # using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
56+ # this sed command uses the alternative separator of "|" because the image location uses "/"
57+ sed -i.bak -e "s|<image_location>|$(FINCH_IMAGE_LOCATION)|g" $@.template
58+ sed -i.bak -e "s/<image_arch>/$(LIMA_ARCH)/g" $@.template
59+ sed -i.bak -e "s/<image_digest>/$(FINCH_IMAGE_DIGEST)/g" $@.template
60+ sed -i.bak -e "s|<container_runtime_archive_x86_64_location>|$(CONTAINER_RUNTIME_ARCHIVE_X86_64_LOCATION)|g" $@.template
61+ sed -i.bak -e "s/<container_runtime_archive_x86_64_digest>/$(CONTAINER_RUNTIME_ARCHIVE_X86_64_DIGEST)/g" $@.template
62+
63+ # Replace was successful, so cleanup .bak files
64+ rm $(LIMA_TEMPLATE_OUTDIR)/*.yaml.template.bak
65+
66+ mv $@.template $@
67+
3368.PHONY: install.lima
3469install.lima: lima-exe install.lima-dependencies-wsl2
3570
0 commit comments