blob: c0100d77586ffb80546421879d726abac5560e6e (
plain)
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
|
#!/bin/bash
# Used to create Gentoo stage3 and portage containers simply by specifying a
# TARGET env variable.
# Example usage: TARGET=stage3-amd64 ./build.sh
if [[ -z "$TARGET" ]]; then
echo "TARGET environment variable must be set e.g. TARGET=stage3-amd64."
exit 1
fi
# Split the TARGET variable into three elements separated by hyphens
IFS=- read -r NAME ARCH SUFFIX <<< "${TARGET}"
VERSION=${VERSION:-$(date -u +%Y%m%d)}
ORG=${ORG:-gentoo}
case $ARCH in
"amd64" | "arm64")
DOCKER_ARCH="${ARCH}"
MICROARCH="${ARCH}"
;;
"armv"*)
# armv6j_hardfp -> arm/v6
# armv7a_hardfp -> arm/v7
DOCKER_ARCH=$(echo "$ARCH" | sed -e 's#arm\(v.\).*#arm/\1#g')
MICROARCH="${ARCH}"
ARCH="arm"
;;
"ppc64le")
DOCKER_ARCH="${ARCH}"
MICROARCH="${ARCH}"
ARCH="ppc"
;;
"s390x")
DOCKER_ARCH="${ARCH}"
MICROARCH="${ARCH}"
ARCH="s390"
;;
"x86")
DOCKER_ARCH="386"
MICROARCH="i686"
;;
*) # portage
DOCKER_ARCH="amd64"
;;
esac
# Handle targets with special characters in the suffix
if [[ "${TARGET}" == "stage3-amd64-hardened-nomultilib" ]]; then
SUFFIX="hardened+nomultilib"
fi
# Prefix the suffix with a hyphen to make sure the URL works
if [[ -n "${SUFFIX}" ]]; then
SUFFIX="-${SUFFIX}"
fi
docker buildx build \
--file "${NAME}.Dockerfile" \
--build-arg ARCH="${ARCH}" \
--build-arg MICROARCH="${MICROARCH}" \
--build-arg SUFFIX="${SUFFIX}" \
--tag "${ORG}/${TARGET}:latest" \
--tag "${ORG}/${TARGET}:${VERSION}" \
--platform "linux/${DOCKER_ARCH}" \
--progress plain \
--load \
.
|