-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (73 loc) · 3.36 KB
/
Makefile
File metadata and controls
81 lines (73 loc) · 3.36 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
69
70
71
72
73
74
75
76
77
78
79
80
81
.PHONY: extract-kernel-name build-driver build-image build
WORKSPACE_DIR ?= $(shell pwd)
KERNEL_FLAVOR ?= cloud
TARGET_ARCH ?= amd64
DOCKER_CONTEXT ?= $(shell pwd)
IMAGE_PATH ?= ghcr.io/gardenlinux/gardenlinux-nvidia-installer/driver
DRIVER_MAJOR_VERS = $(firstword $(subst ., ,$(DRIVER_VERSION)))
build: build-driver build-image
ifndef GL_VERSION
$(error GL_VERSION is not set. Please set it before running make.)
endif
ifndef DRIVER_VERSION
$(error DRIVER_VERSION is not set. Please set it before running make.)
endif
RELEASE_TAG ?= development
# If KERNEL_NAME is already set (e.g. passed by CI after a separate extract step),
# extract-kernel-name is a no-op. Otherwise it runs the kmodbuild container to determine it.
extract-kernel-name:
ifeq ($(KERNEL_NAME),)
$(eval KERNEL_NAME := $(shell docker run --rm \
-v "$(PWD):/workspace" \
-w /workspace \
ghcr.io/gardenlinux/gardenlinux/kmodbuild:$(TARGET_ARCH)-$(GL_VERSION) \
./resources/extract_kernel_name.sh "$(KERNEL_FLAVOR)"))
endif
# build-driver compiles both open and proprietary kernel module tarballs.
# KERNEL_TYPE is required by compile.sh and must be supplied per-invocation.
# The 'build' target invokes build-driver twice (once per type); in CI the
# matrix already supplies KERNEL_TYPE so build-driver can be called directly.
build-driver: extract-kernel-name
ifndef KERNEL_TYPE
$(error KERNEL_TYPE is not set. Please set it to open or proprietary before running make.)
endif
mkdir -p $(WORKSPACE_DIR)/out ;\
if [ ! -f $(WORKSPACE_DIR)/out/nvidia/driver-$(DRIVER_VERSION)-$(KERNEL_TYPE)-$(KERNEL_NAME).tar.gz ]; then \
docker run --rm \
-v $(WORKSPACE_DIR):/workspace \
-v $(WORKSPACE_DIR)/out:/out \
--platform=linux/${TARGET_ARCH} \
-w /workspace \
--env TARGET_ARCH=$(TARGET_ARCH) \
--env GL_VERSION=$(GL_VERSION) \
--env DRIVER_VERSION=$(DRIVER_VERSION) \
--env KERNEL_NAME=$(KERNEL_NAME) \
--env KERNEL_TYPE=$(KERNEL_TYPE) \
ghcr.io/gardenlinux/gardenlinux/kmodbuild:${TARGET_ARCH}-${GL_VERSION} \
bash ./resources/compile.sh ;\
fi
# build-image produces one image per (GL_VERSION, DRIVER_VERSION, KERNEL_FLAVOR, TARGET_ARCH).
# KERNEL_NAME is extracted at build time via extract-kernel-name so that the image tag
# encodes the exact kernel version the installer targets.
# KERNEL_NAME already contains flavour and arch (e.g. 6.12.72-cloud-amd64), so tags do not
# append KERNEL_FLAVOR or TARGET_ARCH separately.
# The correct tarball is downloaded at container runtime based on uname -r and KERNEL_MODULE_TYPE.
build-image: extract-kernel-name
$(eval TAG1 := "$(DRIVER_MAJOR_VERS)-$(KERNEL_NAME)-gardenlinux0")
$(eval TAG2 := "$(DRIVER_VERSION)-$(KERNEL_NAME)-gardenlinux0")
@DOCKER_BUILDKIT=1 docker build \
--build-arg GL_VERSION=$(GL_VERSION) \
--build-arg DRIVER_VERSION=$(DRIVER_VERSION) \
--build-arg RELEASE_TAG=$(RELEASE_TAG) \
--build-arg TARGET_ARCH=$(TARGET_ARCH) \
--platform=linux/${TARGET_ARCH} \
-t $(IMAGE_PATH):$(TAG1) \
-t $(IMAGE_PATH):$(TAG2) \
-f Dockerfile $(DOCKER_CONTEXT) > /dev/null
@echo $(TAG1)
@echo $(TAG2)
clean:
rm -rf $(WORKSPACE_DIR)/out/nvidia/driver-$(DRIVER_VERSION)-open-*.tar.gz
rm -rf $(WORKSPACE_DIR)/out/nvidia/driver-$(DRIVER_VERSION)-proprietary-*.tar.gz
clean-all:
rm -rf $(WORKSPACE_DIR)/out/