-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
208 lines (180 loc) · 5.14 KB
/
Makefile
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
.PHONY: build test test-systemd test-published update-images check-target
SUPPORTED_TARGETS = \
debian-buster \
debian-bullseye \
debian-bookworm \
ubuntu-bionic \
ubuntu-focal \
ubuntu-hirsute \
ubuntu-jammy \
ubuntu-noble \
centos-7 \
centos-8 \
rockylinux-9 \
amazonlinux-2023 \
fedora-40 \
linux-x86_64 \
linuxmusl-x86_64 \
linux-aarch64 \
linuxmusl-aarch64
ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
PLATFORM = $(firstword $(subst -, ,$(TARGET)))
ARCH ?= $(shell uname -m)
DISTRO = $(lastword $(subst -, ,$(TARGET)))
OUTPUTDIR := /tmp/artifacts
GET_SHELL :=
SSH_KEY :=
PACKAGE_SERVER :=
PKG_TEST_JOBS :=
EXTRAENV =
EXTRAVOLUMES =
DOCKER_ARCH__x86_64 = amd64
DOCKER_ARCH__aarch64 = arm64v8
DOCKER_ARCH__arm64 = arm64v8
DOCKER_ARCH = $(DOCKER_ARCH__$(ARCH))
ifeq ($(DOCKER_ARCH),)
DOCKER_ARCH=$(ARCH)
endif
DOCKER_ARCH_PREFIX=$(DOCKER_ARCH)/
DOCKER_PLATFORM__arm64v8 = linux/arm64/v8
DOCKER_PLATFORM= $(DOCKER_PLATFORM__$(DOCKER_ARCH))
ifeq ($(DOCKER_PLATFORM),)
DOCKER_PLATFORM=linux/$(DOCKER_ARCH)
endif
ifeq ($(METAPKGDEV),true)
_METAPKG_PATH = $(shell python -c 'import metapkg;print(metapkg.__path__[0])')
EXTRAVOLUMES += -v $(_METAPKG_PATH):/metapkg
EXTRAENV += -e METAPKG_PATH=/metapkg
endif
ifeq ($(GET_SHELL),true)
COMMAND = bash
EXTRAENV += -e GET_SHELL="$(GET_SHELL)"
endif
ifneq ($(SRC_REF),)
EXTRAENV += -e SRC_REF="$(SRC_REF)"
endif
ifneq ($(PKG_VERSION_SLOT),)
EXTRAENV += -e PKG_VERSION_SLOT="$(PKG_VERSION_SLOT)"
endif
ifneq ($(PKG_REVISION),)
EXTRAENV += -e PKG_REVISION="$(PKG_REVISION)"
endif
ifneq ($(PKG_SUBDIST),)
EXTRAENV += -e PKG_SUBDIST="$(PKG_SUBDIST)"
endif
ifneq ($(PKG_TAGS),)
EXTRAENV += -e PKG_TAGS="$(PKG_TAGS)"
endif
ifneq ($(PKG_INSTALL_REF),)
EXTRAENV += -e PKG_INSTALL_REF="$(PKG_INSTALL_REF)"
endif
ifneq ($(PKG_COMPRESSION),)
EXTRAENV += -e PKG_COMPRESSION="$(PKG_COMPRESSION)"
endif
ifneq ($(EXTRA_OPTIMIZATIONS),)
EXTRAENV += -e EXTRA_OPTIMIZATIONS=true
endif
ifneq ($(PACKAGE),)
EXTRAENV += -e PACKAGE="$(PACKAGE)"
endif
ifneq ($(PKG_PLATFORM_LIBC),)
EXTRAENV += -e PKG_PLATFORM_LIBC="$(PKG_PLATFORM_LIBC)"
endif
ifneq ($(PKG_PLATFORM_ARCH),)
EXTRAENV += -e PKG_PLATFORM_ARCH="$(PKG_PLATFORM_ARCH)"
endif
ifneq ($(BUILD_GENERIC),)
EXTRAENV += -e BUILD_GENERIC="$(BUILD_GENERIC)"
endif
ifneq ($(PKG_BUILD_JOBS),)
EXTRAENV += -e PKG_BUILD_JOBS="$(PKG_BUILD_JOBS)"
endif
ifeq ($(BUILD_IS_RELEASE),true)
EXTRAENV += -e BUILD_IS_RELEASE=true
endif
check-target:
ifeq ($(TARGET),)
$(error "Please specify the TARGET variable.")
endif
ifeq ($(filter $(TARGET),$(SUPPORTED_TARGETS)),)
$(error Unsupported target: $(TARGET), \
supported targets are: $(SUPPORTED_TARGETS))
endif
build: check-target
make -C integration/linux/build
env BUILDKIT_PROGRESS=plain \
docker build -t $(DOCKER_ARCH_PREFIX)edgedb-pkg/build:$(TARGET) \
--build-arg DOCKER_ARCH=$(DOCKER_ARCH_PREFIX) \
--platform $(DOCKER_PLATFORM) \
integration/linux/build/$(TARGET)
docker run -it --rm \
-v $(ROOT):/src \
-v /tmp/pkgcache:/root/.cache/ \
-v $(OUTPUTDIR):/src/artifacts \
$(EXTRAVOLUMES) \
$(EXTRAENV) \
-e PKG_PLATFORM=$(PLATFORM) \
-e PKG_PLATFORM_VERSION=$(DISTRO) \
-e PYTHONPATH=/src \
-w /src \
--platform $(DOCKER_PLATFORM) \
$(DOCKER_ARCH_PREFIX)edgedb-pkg/build:$(TARGET) \
$(COMMAND)
test: check-target
make -C integration/linux/test
env BUILDKIT_PROGRESS=plain \
docker build -t $(DOCKER_ARCH_PREFIX)edgedb-pkg/test:$(TARGET) \
--build-arg DOCKER_ARCH=$(DOCKER_ARCH_PREFIX) \
--platform $(DOCKER_PLATFORM) \
integration/linux/test/$(TARGET)
docker run -it --rm \
-v $(ROOT):/src \
-v $(OUTPUTDIR):/artifacts \
$(EXTRAENV) \
-e PKG_PLATFORM=$(PLATFORM) \
-e PKG_PLATFORM_VERSION=$(DISTRO) \
-e PKG_TEST_JOBS=$(PKG_TEST_JOBS) \
--platform $(DOCKER_PLATFORM) \
$(DOCKER_ARCH_PREFIX)edgedb-pkg/test:$(TARGET) \
$(COMMAND)
test-systemd: check-target
make -C integration/linux/test-systemd
env BUILDKIT_PROGRESS=plain \
docker build -t edgedb-pkg/test-systemd:$(TARGET) integration/linux/test-systemd/$(TARGET)
podman run -it --rm \
--cap-add SYS_ADMIN \
--cgroupns=host \
--cgroup-parent="containers.slice" \
--systemd true \
-v $(ROOT):/src \
-v $(OUTPUTDIR):/artifacts \
$(EXTRAENV) \
-e PKG_PLATFORM=$(PLATFORM) \
-e PKG_PLATFORM_VERSION=$(DISTRO) \
docker-daemon:edgedb-pkg/test-systemd:$(TARGET)
publish:
make -C integration/linux/upload
env BUILDKIT_PROGRESS=plain \
docker build -t edgedb-pkg/upload:linux-x86_64 integration/linux/upload/linux-x86_64
docker run -it --rm \
$(EXTRAENV) \
-e PKG_PLATFORM=$(PLATFORM) \
-e PKG_PLATFORM_VERSION=$(DISTRO) \
-e PACKAGE_UPLOAD_SSH_KEY_FILE="/sshkey" \
-e PACKAGE_SERVER=$(PACKAGE_SERVER) \
-v $(SSH_KEY):/sshkey \
-v $(OUTPUTDIR):/artifacts \
edgedb-pkg/upload:linux-x86_64 \
$(COMMAND)
test-published: check-target
make -C integration/linux/testpublished
export BUILDKIT_PROGRESS=plain
docker build -t edgedb-pkg/testpublished:$(TARGET) integration/linux/testpublished/$(TARGET)
docker run -it --rm \
$(EXTRAENV) \
-e PKG_PLATFORM=$(PLATFORM) \
-e PKG_PLATFORM_VERSION=$(DISTRO) \
-e PKG_NAME=$(PKG_NAME) \
-v $(ROOT):/src \
edgedb-pkg/testpublished:$(TARGET) \
$(COMMAND)