-
Notifications
You must be signed in to change notification settings - Fork 50
/
Makefile
117 lines (98 loc) · 4.04 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
# Copyright 2018-2022 Docker Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include common/common.mk
ARCH=$(shell uname -m)
BUILD_IMAGE=ubuntu:focal
BUILD_TYPE=$(shell ./scripts/deb-or-rpm $(BUILD_IMAGE))
BUILD_BASE=$(shell ./scripts/determine-base $(BUILD_IMAGE))
# The PROGRESS variable allows overriding the docker build --progress option.
# For example, use "make PROGRESS=plain ..." to show build progress in plain test
PROGRESS=auto
TARGET=packages
all: build
.PHONY: clean
clean:
-$(RM) -r archive
-$(RM) -r artifacts
-$(RM) -r build
-$(RM) -r src
-$(RM) common/containerd.service
-docker builder prune -f --filter until=24h
.PHONY: src
src: src/github.com/containerd/containerd src/github.com/opencontainers/runc
common/containerd.service: checkout
# upstream systemd unit uses /usr/local/bin, whereas our packages use /usr/bin
sed 's#/usr/local/bin/containerd#/usr/bin/containerd#g' src/github.com/containerd/containerd/containerd.service > $@
ifdef RUNC_DIR
src/github.com/opencontainers/runc:
mkdir -p "$(@D)"
cp -r "$(RUNC_DIR)" $@
else
src/github.com/opencontainers/runc:
git init $@
git -C $@ remote add origin "$(RUNC_REMOTE)"
endif
ifdef CONTAINERD_DIR
src/github.com/containerd/containerd:
mkdir -p "$(@D)"
cp -r "$(CONTAINERD_DIR)" $@
else
src/github.com/containerd/containerd:
git init $@
git -C $@ remote add origin "$(CONTAINERD_REMOTE)"
endif
# This targets allows building multiple distros at once, for example:
#
# make docker.io/library/ubuntu:jammy docker.io/library/centos:7
# make quay.io/centos/centos:stream8
#
# It is a shorthand for "make BUILD_IMAGE=mydistro:version build"
.PHONY: docker.io/% quay.io/% registry.access.redhat.com/%
docker.io/% quay.io/% registry.access.redhat.com/%:
$(MAKE) BUILD_IMAGE="$@" build
.PHONY: checkout
checkout: src
./scripts/checkout.sh src/github.com/containerd/containerd "$(REF)"
./scripts/checkout.sh src/github.com/opencontainers/runc "$$(./scripts/determine-runc-version)"
.PHONY: build
build: checkout common/containerd.service
build:
@echo "--------------------------------------------------------------------"
@echo "Building $(TARGET) on $(BUILD_IMAGE)"
@echo ""
@echo "containerd : $(REF) (commit: $(shell git -C "src/github.com/containerd/containerd" log -1 --pretty='%h'))"
@echo "runc : $$(./scripts/determine-runc-version) (commit: $$(git -C "src/github.com/opencontainers/runc" log -1 --pretty='%h'))"
@echo "architecture : $(ARCH)"
@echo "build image : $(BUILD_IMAGE)"
@echo "golang image : $(GOLANG_IMAGE)"
@echo "--------------------------------------------------------------------"
@docker pull "$(BUILD_IMAGE)"
@if [ -z "$(BUILD_BASE)" ]; then echo "Invalid build image $(BUILD_IMAGE) no build base found"; exit 1; fi
@if [ -z "$(BUILD_TYPE)" ]; then echo "Invalid build image $(BUILD_IMAGE) no build type found"; exit 1; fi
@set -x; DOCKER_BUILDKIT=1 docker build \
--pull \
--secret id=rh-user,env=RH_USER \
--secret id=rh-pass,env=RH_PASS \
--platform linux/$(ARCH) \
--build-arg GOLANG_IMAGE="$(GOLANG_IMAGE)" \
--build-arg BUILD_IMAGE="$(BUILD_IMAGE)" \
--build-arg BASE="$(BUILD_BASE)" \
--build-arg CREATE_ARCHIVE="$(CREATE_ARCHIVE)" \
--build-arg UID="$(shell id -u)" \
--build-arg GID="$(shell id -g)" \
--file="dockerfiles/$(BUILD_TYPE).dockerfile" \
--progress="$(PROGRESS)" \
--target="$(TARGET)" \
--output=. \
.
.PHONY: validate
validate: ## Validate files license header
docker run --rm -v $(CURDIR):/work -w /work golang:alpine sh -c 'go install github.com/kunalkushwaha/ltag@latest && ./scripts/validate/fileheader'