-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile.windows
101 lines (83 loc) · 5.29 KB
/
Makefile.windows
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# TODO: Use Finch rootfs in Finch on Windows testing
ROOTFS_OUTPUT_DIR := $(OUTDIR)/os
OUTPUT_DIRECTORIES += $(ROOTFS_OUTPUT_DIR)
include $(CURDIR)/deps/rootfs.conf
ifeq ($(ARCH), x86_64)
FINCH_ROOTFS_BASENAME ?= $(X86_64_ARTIFACT)
FINCH_ROOTFS_DIGEST ?= $(X86_64_512_DIGEST)
else
$(error Finch on Windows ARM not supported)
endif
# WSL2 is the only virtual machine type supported for Finch on Windows
FINCH_VM_TYPE := wsl2
WINGIT_TEMP_DIR := $(CURDIR)/wingit-temp
WINGIT_x86_URL := $(or $(WINGIT_x86_URL),https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.tar.bz2)
WINGIT_x86_BASENAME ?= $(notdir $(WINGIT_x86_URL))
WINGIT_x86_HASH := $(or $(WINGIT_x86_HASH),"sha512:795a2e7e0be5ab78f2d28d0bd971961d121b9c808a95dec795343dc5af943574dcf54f63a8580c5a5102075abdae387d7a67135c165821428afc07f11ef7543d")
install.dependencies: install.rootfs install.lima
.PHONY: install.rootfs
install.rootfs: $(ROOTFS_OUTPUT_DIR)/$(FINCH_ROOTFS_BASENAME)
$(ROOTFS_OUTPUT_DIR)/$(FINCH_ROOTFS_BASENAME): $(ROOTFS_OUTPUT_DIR) $(CURDIR)/deps/rootfs.conf
bash deps/install.sh --arch $(ARCH) --output $@ $(CURDIR)/deps/rootfs.conf
.PHONY: install.lima
install.lima: lima-exe install.lima-dependencies-wsl2
.PHONY: lima-exe
lima-exe: $(LIMA_OUTDIR)
cd src/lima && \
"$(MAKE)" exe _output/share/lima/lima-guestagent.Linux-x86_64
cp -r src/lima/_output/* $(LIMA_OUTDIR)
.PHONY: install.lima-dependencies-wsl2
install.lima-dependencies-wsl2: $(LIMA_OUTDIR)/bin/ssh.exe
# Only redownload/extract if this file is missing (there's no particular reason for choosing this file instead of any other)
$(LIMA_OUTDIR)/bin/ssh.exe: $(LIMA_OUTDIR) $(LIMA_DOWNLOAD_DIR)
curl -L --fail $(WINGIT_x86_URL) > $(LIMA_DOWNLOAD_DIR)/$(WINGIT_x86_BASENAME)
pwsh.exe -NoLogo -NoProfile -c ./bin/verify_hash.ps1 "$(LIMA_DOWNLOAD_DIR)\$(WINGIT_x86_BASENAME)" $(WINGIT_x86_HASH)
mkdir -p $(WINGIT_TEMP_DIR)
# this takes a long time because of an almost 4:1 compression ratio and needing to extract many small files
tar --force-local -xvjf "$(LIMA_DOWNLOAD_DIR)\$(WINGIT_x86_BASENAME)" -C $(WINGIT_TEMP_DIR)
# Lima runtime dependencies
mkdir -p $(LIMA_OUTDIR)/bin
# From https://packages.msys2.org/package/gzip?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/gzip.exe $(LIMA_OUTDIR)/bin/
# From https://packages.msys2.org/package/msys2-runtime?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/cygpath.exe $(LIMA_OUTDIR)/bin/
# From https://packages.msys2.org/package/tar?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/tar.exe $(LIMA_OUTDIR)/bin/
# From https://packages.msys2.org/package/openssh?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/ssh.exe $(LIMA_OUTDIR)/bin/
# From https://packages.msys2.org/package/openssh?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/ssh-keygen.exe $(LIMA_OUTDIR)/bin/
# Dependency DLLs, extracted with https://github.com/lucasg/Dependencies
# Dependencies.exe -chain $(WINGIT_TEMP_DIR)\usr\bin\ssh.exe -depth 3 -json
# Depth 3 is only needed for ssh.exe, everything else only needs depth 1
# TODO: Automate
# Required by all MSYS2 programs, from https://github.com/msys2/msys2-runtime
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-2.0.dll $(LIMA_OUTDIR)/bin/
# Required by tar.exe, from https://packages.msys2.org/package/libiconv?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-iconv-2.dll $(LIMA_OUTDIR)/bin/
# Required by msys-iconv-2.dll, from https://packages.msys2.org/package/libintl?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-intl-8.dll $(LIMA_OUTDIR)/bin/
# GCC exception handling, required for all programs that throw exceptions, from https://packages.msys2.org/package/gcc-libs?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-gcc_s-seh-1.dll $(LIMA_OUTDIR)/bin/
# Required by ssh.exe, from https://packages.msys2.org/package/libopenssl?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-crypto-3.dll $(LIMA_OUTDIR)/bin/
# Required by ssh.exe, from https://packages.msys2.org/package/zlib-devel?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-z.dll $(LIMA_OUTDIR)/bin/
# Required by ssh.exe, from https://packages.msys2.org/package/libcrypt?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-crypt-0.dll $(LIMA_OUTDIR)/bin/
# Required by heimdal-libs, from https://packages.msys2.org/package/libsqlite?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-sqlite3-0.dll $(LIMA_OUTDIR)/bin/
# Required by ssh.exe, from https://packages.msys2.org/package/heimdal-libs?repo=msys&variant=x86_64
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-asn1-8.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-com_err-1.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-gssapi-3.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-hcrypto-4.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-heimbase-1.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-heimntlm-0.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-hx509-5.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-krb5-26.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-roken-18.dll $(LIMA_OUTDIR)/bin/
cp $(WINGIT_TEMP_DIR)/usr/bin/msys-wind-0.dll $(LIMA_OUTDIR)/bin/
-@rm -rf $(WINGIT_TEMP_DIR)