forked from runfinch/finch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.darwin
More file actions
68 lines (56 loc) · 3.56 KB
/
Makefile.darwin
File metadata and controls
68 lines (56 loc) · 3.56 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# For Finch on macOS, the base OS location and digest are set
# based on the values set in deps/finch-core/deps/full-os.conf
-include $(FINCH_CORE_DIR)/deps/full-os.conf
ifeq ($(ARCH),x86_64)
FINCH_OS_BASENAME := $(X86_64_ARTIFACT)
FINCH_OS_DIGEST := $(X86_64_512_DIGEST)
else
FINCH_OS_BASENAME := $(AARCH64_ARTIFACT)
FINCH_OS_DIGEST := $(AARCH64_512_DIGEST)
endif
# This variable is used to generate release builds, where the OS image path should be overwritten
# to /Applications/Finch/...
FINCH_OS_IMAGE_LOCATION_ROOT ?= $(DEST)
FINCH_IMAGE_LOCATION ?= $(FINCH_OS_IMAGE_LOCATION_ROOT)/os/$(FINCH_OS_BASENAME)
FINCH_IMAGE_DIGEST ?= "sha512:$(FINCH_OS_DIGEST)"
# check if finch-daemon socket is in a default path
SHOULD_ADD_DAEMON_MOUNT = $(shell if echo "$(FINCH_DAEMON_LOCATION_ROOT)" | grep -q \/Users\/ ; then echo "0"; else echo "1"; fi)
.PHONY: finch.yaml
finch.yaml: $(OS_OUTDIR)/finch.yaml
# only add the finch-daemon mount when its not in a default path
# this scenario is common in dev, where the typical path is /Users/...
ifeq ($(SHOULD_ADD_DAEMON_MOUNT),1)
finch.yaml: add-daemon-mount
endif
$(OS_OUTDIR)/finch.yaml: $(OS_OUTDIR) finch.yaml.d/common.yaml finch.yaml.d/mac.yaml
# merge the appropriate YAMLs into a temporary finch.yaml file on the current working directory
cd finch.yaml.d && yq eval-all '. as $$item ireduce ({}; . *+ $$item)' common.yaml mac.yaml > ./../finch.yaml.temp
# using -i.bak is very intentional, it allows the following commands to succeed for both GNU / BSD sed
# this sed command uses the alternative separator of "|" because the image location uses "/"
sed -i.bak -e "s|<finch_image_location>|$(FINCH_IMAGE_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s/<finch_image_arch>/$(LIMA_ARCH)/g" finch.yaml.temp
sed -i.bak -e "s/<finch_image_digest>/$(FINCH_IMAGE_DIGEST)/g" finch.yaml.temp
sed -i.bak -e "s|<container_runtime_archive_aarch64_location>|$(CONTAINER_RUNTIME_ARCHIVE_AARCH64_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s/<container_runtime_archive_aarch64_digest>/$(CONTAINER_RUNTIME_ARCHIVE_AARCH64_DIGEST)/g" finch.yaml.temp
sed -i.bak -e "s|<container_runtime_archive_x86_64_location>|$(CONTAINER_RUNTIME_ARCHIVE_X86_64_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s/<container_runtime_archive_x86_64_digest>/$(CONTAINER_RUNTIME_ARCHIVE_X86_64_DIGEST)/g" finch.yaml.temp
sed -i.bak -e "s|<finch_daemon_root>|$(FINCH_DAEMON_LOCATION_ROOT)|g" finch.yaml.temp
sed -i.bak -e "s|<finch_daemon_location>|$(FINCH_DAEMON_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s|<finch_daemon_credhelper_location>|$(FINCH_DAEMON_CREDHELPER_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s|<runc_override_aarch64_location>|$(RUNC_OVERRIDE_AARCH64_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s/<runc_override_aarch64_digest>/$(RUNC_OVERRIDE_AARCH64_DIGEST)/g" finch.yaml.temp
sed -i.bak -e "s|<runc_override_x86_64_location>|$(RUNC_OVERRIDE_X86_64_LOCATION)|g" finch.yaml.temp
sed -i.bak -e "s/<runc_override_x86_64_digest>/$(RUNC_OVERRIDE_X86_64_DIGEST)/g" finch.yaml.temp
cat finch.yaml.temp
# Replacement was successful, so cleanup .bak
@rm finch.yaml.temp.bak
mv finch.yaml.temp $@
.PHONY: add-daemon-mount
add-daemon-mount:
cd finch.yaml.d && yq eval-all '. as $$item ireduce ({}; . *+ $$item)' $(OS_OUTDIR)/finch.yaml finch-daemon-mount.yaml > ./../finch.yaml.temp
sed -i.bak -e "s|<finch_daemon_root>|$(FINCH_DAEMON_LOCATION_ROOT)|g" finch.yaml.temp
# Replacement was successful, so cleanup .bak
@rm finch.yaml.temp.bak
mv finch.yaml.temp $(OS_OUTDIR)/finch.yaml