forked from microsoft/azurelinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
218 lines (183 loc) · 7.52 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
209
210
211
212
213
214
215
216
217
218
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Contains:
# - Definitions
# - High Level Targets
# - Submake Includes
######## DEFINITIONS ########
# Build targets
ifeq ($(origin CONFIG_FILE), undefined)
CONFIG_FILE = $(toolkit_root)/imageconfigs/core-efi.json
$(warning CONFIG_FILE is undefined, defaulting to toolkit's core-efi.json.)
endif
CONFIG_BASE_DIR ?= $(dir $(CONFIG_FILE))
PACKAGE_BUILD_LIST ?=
PACKAGE_REBUILD_LIST ?=
PACKAGE_IGNORE_LIST ?=
SRPM_PACK_LIST ?=
REBUILD_TOOLCHAIN ?= n
INCREMENTAL_TOOLCHAIN ?= n
ALLOW_TOOLCHAIN_DOWNLOAD_FAIL ?= n
UPDATE_TOOLCHAIN_LIST ?= n
REBUILD_PACKAGES ?= y
DOWNLOAD_SRPMS ?= n
ALLOW_SRPM_DOWNLOAD_FAIL ?= n
REBUILD_TOOLS ?= n
RUN_CHECK ?= n
USE_PREVIEW_REPO ?= n
DISABLE_UPSTREAM_REPOS ?= n
TOOLCHAIN_CONTAINER_ARCHIVE ?=
TOOLCHAIN_ARCHIVE ?=
TOOLCHAIN_SOURCES_ARCHIVE ?=
CACHE_DIR ?=
PACKAGE_CACHE_SUMMARY ?=
IMAGE_CACHE_SUMMARY ?=
INITRD_CACHE_SUMMARY ?=
PACKAGE_ARCHIVE ?=
PACKAGE_BUILD_RETRIES ?= 1
REFRESH_WORKER_CHROOT ?= y
# Set to 0 to use the number of logical CPUs.
CONCURRENT_PACKAGE_BUILDS ?= 0
# Set to 0 to print all available results.
NUM_OF_ANALYTICS_RESULTS ?= 10
CLEANUP_PACKAGE_BUILDS ?= y
USE_PACKAGE_BUILD_CACHE ?= y
REBUILD_DEP_CHAINS ?= y
HYDRATED_BUILD ?= n
DELTA_BUILD ?= n
# Folder defines
toolkit_root := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
TOOLS_DIR ?= $(toolkit_root)/tools
TOOL_BINS_DIR ?= $(toolkit_root)/out/tools
PREVIEW_REPO ?= $(toolkit_root)/repos/mariner-official-preview.repo
RESOURCES_DIR ?= $(toolkit_root)/resources
SCRIPTS_DIR ?= $(toolkit_root)/scripts
PROJECT_ROOT ?= $(realpath $(toolkit_root)/..)
BUILD_DIR ?= $(PROJECT_ROOT)/build
OUT_DIR ?= $(PROJECT_ROOT)/out
SPECS_DIR ?= $(PROJECT_ROOT)/SPECS
# Sub-folder defines
LOGS_DIR ?= $(BUILD_DIR)/logs
PKGBUILD_DIR ?= $(BUILD_DIR)/pkg_artifacts
CACHED_RPMS_DIR ?= $(BUILD_DIR)/rpm_cache
BUILD_SRPMS_DIR ?= $(BUILD_DIR)/INTERMEDIATE_SRPMS
MACRO_DIR ?= $(BUILD_DIR)/macros
BUILD_SPECS_DIR ?= $(BUILD_DIR)/INTERMEDIATE_SPECS
STATUS_FLAGS_DIR ?= $(BUILD_DIR)/make_status
CHROOT_DIR ?= $(BUILD_DIR)/worker/chroot
IMAGEGEN_DIR ?= $(BUILD_DIR)/imagegen
RPMRC_DIR ?= $(MACRO_DIR)/usr/lib/rpm
PKGGEN_DIR ?= $(TOOLS_DIR)/pkggen
TOOLKIT_BINS_DIR ?= $(TOOLS_DIR)/toolkit_bins
MANIFESTS_DIR ?= $(RESOURCES_DIR)/manifests
META_USER_DATA_DIR ?= $(RESOURCES_DIR)/assets/meta-user-data
SSH_KEY_FILE ?=
TOOLCHAIN_MANIFESTS_DIR ?= $(MANIFESTS_DIR)/package
RPMS_DIR ?= $(OUT_DIR)/RPMS
SRPMS_DIR ?= $(OUT_DIR)/SRPMS
IMAGES_DIR ?= $(OUT_DIR)/images
# If toolchain RPMs are being rebuilt locally, they belong with the other RPMs
ifeq ($(REBUILD_TOOLCHAIN),y)
toolchain_rpms_dir := $(RPMS_DIR)
else
toolchain_rpms_dir := $(CACHED_RPMS_DIR)/cache
endif
# External source server
SOURCE_URL ?= https://cblmarinerstorage.blob.core.windows.net/sources/core
PACKAGE_URL_LIST ?= https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/prod/base/$(build_arch)
PACKAGE_URL_LIST += https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/prod/base/debuginfo/$(build_arch)
REPO_LIST ?=
SRPM_URL_LIST ?= https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/prod/base/srpms
ifeq ($(USE_PREVIEW_REPO),y)
PACKAGE_URL_LIST += https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/preview/base/$(build_arch)
PACKAGE_URL_LIST += https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/preview/base/debuginfo/$(build_arch)
SRPM_URL_LIST += https://packages.microsoft.com/cbl-mariner/$(RELEASE_MAJOR_ID)/preview/base/srpms
ifneq ($(wildcard $(PREVIEW_REPO)),)
override REPO_LIST += $(PREVIEW_REPO)
else
$(warning )
$(warning ######################### WARNING #########################)
$(warning 'USE_PREVIEW_REPO=y' set but '$(PREVIEW_REPO)' is missing. Regenerate toolkit's 'repos' directory. Remove 'USE_PREVIEW_REPO' for core builds.)
$(warning ######################### WARNING #########################)
$(warning )
endif
endif
ifneq ($(strip $(SRPM_PACK_LIST)),)
LOCAL_SPECS = $(wildcard $(addprefix $(SPECS_DIR)/*/,$(addsuffix .spec,$(strip SRPM_PACK_LIST))))
else # Empty pack list, build all under $(SPECS_DIR)
LOCAL_SPECS = $(shell find $(SPECS_DIR)/ -type f -name '*.spec')
endif
LOCAL_SPEC_DIRS = $(foreach spec,$(LOCAL_SPECS),$(dir $(spec)))
CA_CERT ?=
TLS_CERT ?=
TLS_KEY ?=
# Build defines
DIST_TAG ?= .cm2
# Running 'git' as the owner of the repo, so it doesn't complain about the repo not belonging to root.
BUILD_NUMBER ?= $(shell runuser -u $$(stat -c "%U" $(PROJECT_ROOT)) -- git rev-parse --short HEAD)
# an empty BUILD_NUMBER breaks the build later on
ifeq ($(BUILD_NUMBER),)
BUILD_NUMBER = non-git
endif
RELEASE_MAJOR_ID ?= 2.0
# use minor ID defined in file (if exist) otherwise define it
# note this file must be single line
ifneq ($(wildcard $(OUT_DIR)/version-minor-id.config),)
RELEASE_MINOR_ID ?= .$(shell cat $(OUT_DIR)/version-minor-id.config)
else
RELEASE_MINOR_ID ?= .$(shell date +'%Y%m%d.%H%M')
endif
RELEASE_VERSION ?= $(RELEASE_MAJOR_ID)$(RELEASE_MINOR_ID)
# Image tag - empty by default. Does not apply to the initrd.
IMAGE_TAG ?=
# panic,fatal,error,warn,info,debug,trace
LOG_LEVEL ?= info
STOP_ON_WARNING ?= n
STOP_ON_PKG_FAIL ?= n
STOP_ON_FETCH_FAIL ?= n
######## HIGH LEVEL TARGETS ########
.PHONY: all clean
all: toolchain go-tools chroot-tools
######## SUBMAKE INCLUDES ########
# Misc function defines
# Variable prerequisite tracking
include $(SCRIPTS_DIR)/utils.mk
# Bootstrap the toolchain's compilers and other tools with:
# toolchain, raw-toolchain, clean-toolchain, check-manifests, check-x86_64-manifests, check-aarch64-manifests
include $(SCRIPTS_DIR)/toolchain.mk
# go utilities with:
# go-tools, clean-go-tools, go-tidy-all (tidy go utilities before committing) go-test-coverage
# chroot worker with:
# chroot-tools clean-chroot-tools
# macro definitions with:
# macro-tools clean-macro-tools
include $(SCRIPTS_DIR)/tools.mk
# Create SRPMS from local SPECS with:
# input-srpms, clean-input-srpms
include $(SCRIPTS_DIR)/srpm_pack.mk
# Expand local SRPMS into sources and SPECS with:
# expand-specs clean-expand-specs
include $(SCRIPTS_DIR)/srpm_expand.mk
# Create a package build workplan with:
# workplan, clean-workplan clean-cache
# Build a package with:
# build-packages clean-build-packages
# Either create or consume compressed folders of rpms with:
# hydrate-rpms, compress-rpms, clean-compress-rpms, compress-srpms, clean-compress-srpms
include $(SCRIPTS_DIR)/pkggen.mk
# Create images with:
# image, iso, clean-imggen
include $(SCRIPTS_DIR)/imggen.mk
# Create self contained toolkit archive contianing all the required tools with:
# package-toolkit, clean-package-toolkit
include $(SCRIPTS_DIR)/toolkit.mk
# Each component provides specific clean implementations which clean depends on.
# They are guaranteed to run first and will verify there are no existing mount points
# left after a chroot.
clean:
rm -rf $(OUT_DIR)
rm -rf $(BUILD_DIR)
rm -rf $(toolkit_root)/out
# output version number
get-version:
@echo $(RELEASE_VERSION)