Debian Codegraph @

script/util/make.sh

raw
1 #!/bin/bash
2
3 # Copyright The containerd Authors.
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -euo pipefail
18
19 CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/"
20 REPO="${CONTEXT}../../"
21 IMAGE_NAME="minienv"
22
23 source "${REPO}/script/util/utils.sh"
24
25 GOBASE_VERSION=$(go_base_version "${REPO}/Dockerfile")
26
27 TMP_CONTEXT=$(mktemp -d)
28 function cleanup {
29 local ORG_EXIT_CODE="${1}"
30 rm -rf "${TMP_CONTEXT}" || true
31 exit "${ORG_EXIT_CODE}"
32 }
33 trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
34
35 cat <<EOF > "${TMP_CONTEXT}/Dockerfile"
36 FROM golang:${GOBASE_VERSION}
37 RUN apt-get update -y && apt-get --no-install-recommends install -y fuse3
38 EOF
39 MAKECMD="make ${@} PREFIX=/tmp/out/"
40 docker build -t "${IMAGE_NAME}" ${DOCKER_BUILD_ARGS:-} "${TMP_CONTEXT}"
41 docker run --rm --privileged \
42 --device /dev/fuse \
43 --tmpfs /tmp:exec,mode=777 \
44 -w /go/src/github.com/containerd/stargz-snapshotter \
45 -v "${REPO}:/go/src/github.com/containerd/stargz-snapshotter:ro" \
46 "${IMAGE_NAME}" /bin/sh -c "git config --global --add safe.directory '/go/src/github.com/containerd/stargz-snapshotter' && ${MAKECMD}"