Skip to content

Commit fecf172

Browse files
committed
static: keep old arches to match folder structure
Signed-off-by: CrazyMax <[email protected]>
1 parent 5352d95 commit fecf172

File tree

5 files changed

+102
-79
lines changed

5 files changed

+102
-79
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
platform:
39-
- linux/amd64
40-
- linux/arm/v6
41-
- linux/arm/v7
42-
- linux/arm64
43-
- darwin/amd64
44-
- darwin/arm64
45-
- windows/amd64
38+
include:
39+
- os: linux
40+
arch: x86_64
41+
- os: linux
42+
arch: armel
43+
- os: linux
44+
arch: armhf
45+
- os: linux
46+
arch: aarch64
47+
- os: darwin
48+
arch: x86_64
49+
- os: darwin
50+
arch: aarch64
51+
- os: windows
52+
arch: x86_64
4653
steps:
47-
-
48-
name: Prepare
49-
run: |
50-
platform=${{ matrix.platform }}
51-
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
5254
-
5355
name: Checkout
5456
uses: actions/checkout@v3
@@ -58,7 +60,7 @@ jobs:
5860
-
5961
name: Build
6062
run: |
61-
make TARGETPLATFORM=${{ matrix.platform }} static
63+
make STATICOS=${{ matrix.os }} STATICARCH=${{ matrix.arch }} static
6264
-
6365
name: List files
6466
run: |
@@ -67,7 +69,7 @@ jobs:
6769
name: Upload static bundle
6870
uses: actions/upload-artifact@v3
6971
with:
70-
name: static-${{ env.PLATFORM_PAIR }}
72+
name: static-${{ matrix.os }}-${{ matrix.arch }}
7173
path: static/build/*.tar.gz
7274
if-no-files-found: error
7375
retention-days: 2

Jenkinsfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def pkgs = [
1717
]
1818

1919
def statics = [
20-
[os: "linux", arches: ["amd64", "armv6", "armv7", "aarch64"]],
21-
[os: "darwin", arches: ["amd64", "aarch64"]],
22-
[os: "windows", arches: ["amd64"]],
20+
[os: "linux", arches: ["x86_64", "armel", "armhf", "aarch64"]],
21+
[os: "darwin", arches: ["x86_64", "aarch64"]],
22+
[os: "windows", arches: ["x86_64"]],
2323
]
2424

2525
def genPkgStep(LinkedHashMap pkg, String arch) {
@@ -62,12 +62,12 @@ def genPkgSteps(opts) {
6262

6363
def genStaticStep(LinkedHashMap pkg, String arch) {
6464
def config = [
65-
amd64: [label: "x86_64", targetarch: "amd64"],
66-
aarch64: [label: "aarch64", targetarch: "arm64"],
67-
armv6: [label: "aarch64", targetarch: "arm/v6"],
68-
armv7: [label: "aarch64", targetarch: "arm/v7"],
69-
ppc64le: [label: "ppc64le", targetarch: "ppc64le"],
70-
s390x : [label: "s390x", targetarch: "s390x"],
65+
x86_64: [label: "x86_64"],
66+
aarch64: [label: "aarch64"],
67+
armel: [label: "aarch64"],
68+
armhf: [label: "aarch64"],
69+
ppc64le: [label: "ppc64le"],
70+
s390x : [label: "s390x"],
7171
][arch]
7272
def nodeLabel = "linux&&${config.label}"
7373
if (config.label == 'x86_64') {
@@ -89,7 +89,7 @@ def genStaticStep(LinkedHashMap pkg, String arch) {
8989
stage("build") {
9090
try {
9191
checkout scm
92-
sh "make REF=$branch TARGETPLATFORM=${pkg.os}/${config.targetarch} static"
92+
sh "make REF=$branch STATICOS=${pkg.os} STATICARCH=${arch} static"
9393
} finally {
9494
sh "make clean"
9595
}

static/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ create_builder: # create docker-container builder
4545

4646
.PHONY: build
4747
build: create_builder ## build static package
48-
CURDIR=$(CURDIR) TARGETPLATFORM=$(TARGETPLATFORM) ./build-static
48+
CURDIR=$(CURDIR) STATICOS=$(STATICOS) STATICARCH=$(STATICARCH) ./build-static
4949

5050
.PHONY: hash_files
5151
hash_files: ## hash files

static/README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
Static packages can be built from root directory with the following syntax
44

55
```console
6-
make TARGETPLATFORM=${TARGETOS}/${TARGETARCH}/${TARGETVARIANT} static
6+
make STATICOS=${STATICOS} STATICOS=${STATICARCH} static
77
```
88

9-
Format of `TARGETOS`, `TARGETARCH`, `TARGETVARIANT` is the same as the [platform ARGs in the global scope](https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope)
10-
for a Dockerfile like `linux/arm/v7`.
9+
Format of `STATICOS`, `STATICARCH` should respect the current folder structure on
10+
[download.docker.com](https://download-stage.docker.com/linux/static/stable/) like
11+
`STATICOS=linux STATICARCH=armhf`.
1112

12-
Artifacts will be located in `build` under the following directory structure:
13-
`build/$os/$arch/$variant/` or `build/$os/$arch/` if there is no variant being
14-
used.
13+
Artifacts will be located in `build` under `build/$STATICOS/$STATICARCH/`.
1514

1615
### Building from local source
1716

@@ -22,34 +21,28 @@ building packages
2221
* `CLI_DIR` -> Specifies the directory where the cli code is located, eg: `$GOPATH/src/github.com/docker/cli`
2322

2423
```shell
25-
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli TARGETPLATFORM=linux/amd64 static
24+
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli STATICOS=linux STATICARCH=x86_64 static
2625
```
2726

2827
## Supported platforms
2928

3029
Here is a list of platforms that are currently supported:
3130

3231
```console
33-
make TARGETPLATFORM=linux/amd64 static
34-
make TARGETPLATFORM=linux/arm/v6 static
35-
make TARGETPLATFORM=linux/arm/v7 static
36-
make TARGETPLATFORM=linux/arm64 static
37-
make TARGETPLATFORM=darwin/amd64 static
38-
make TARGETPLATFORM=darwin/arm64 static
39-
make TARGETPLATFORM=windows/amd64 static
32+
make STATICOS=linux STATICARCH=x86_64 static
33+
make STATICOS=linux STATICARCH=armel static
34+
make STATICOS=linux STATICARCH=armhf static
35+
make STATICOS=linux STATICARCH=aarch64 static
36+
make STATICOS=darwin STATICARCH=x86_64 static
37+
make STATICOS=darwin STATICARCH=aarch64 static
38+
make STATICOS=windows STATICARCH=x86_64 static
4039
```
4140

4241
> note: `darwin` only packages the docker cli and plugins.
4342
4443
But you can test building against whatever platform you want like:
4544

4645
```console
47-
make TARGETPLATFORM=linux/riscv64 static
48-
make TARGETPLATFORM=linux/s390x static
49-
```
50-
51-
Or the current one matching your host if not defined:
52-
53-
```console
54-
make static
46+
make STATICOS=linux STATICARCH=riscv64 static
47+
make STATICOS=linux STATICARCH=s390x static
5548
```

static/build-static

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -ex
33

44
: "${CURDIR=}"
5+
: "${STATICOS=}"
6+
: "${STATICARCH=}"
57
: "${TARGETPLATFORM=}"
68
: "${TARGETOS=}"
79
: "${TARGETARCH=}"
@@ -12,38 +14,64 @@ if [ -z "$CURDIR" ]; then
1214
echo 'CURDIR is required. See README.md for usage.'
1315
exit 1
1416
fi
15-
16-
# break up TARGETPLATFORM
17-
if [ -n "$TARGETPLATFORM" ]; then
18-
os="$(echo "$TARGETPLATFORM" | cut -d"/" -f1)"
19-
arch="$(echo "$TARGETPLATFORM" | cut -d"/" -f2)"
20-
if [ -n "$os" ] && [ -n "$arch" ]; then
21-
TARGETOS="$os"
22-
TARGETARCH="$arch"
23-
case "$arch" in
24-
"arm")
25-
case "$(echo "$TARGETPLATFORM" | cut -d"/" -f3)" in
26-
"v5")
27-
TARGETVARIANT="v5"
28-
;;
29-
"v6")
30-
TARGETVARIANT="v6"
31-
;;
32-
"v8")
33-
TARGETVARIANT="v8"
34-
;;
35-
*)
36-
TARGETVARIANT="v7"
37-
;;
38-
esac
39-
;;
40-
"mips"*)
41-
TARGETVARIANT="$(echo "$TARGETPLATFORM" | cut -d"/" -f3)"
42-
;;
43-
esac
44-
fi
17+
if [[ -z "$STATICOS" ]] || [[ -z "$STATICARCH" ]]; then
18+
# shellcheck disable=SC2016
19+
echo 'STATICOS and STATICARCH are required. See README.md for usage.'
20+
exit 1
4521
fi
4622

23+
# TODO: remove this once we support TARGETPLATFORM in download.docker.com folder structure
24+
TARGETOS="$STATICOS"
25+
# STATICARCH reverse lookup for compat with TARGETPLATFORM
26+
case "$STATICARCH" in
27+
"x86_64")
28+
TARGETARCH="amd64"
29+
;;
30+
"i386")
31+
TARGETARCH="386"
32+
;;
33+
"aarch64")
34+
TARGETARCH="arm64"
35+
;;
36+
"armhf")
37+
TARGETARCH="arm"
38+
TARGETVARIANT="v7"
39+
;;
40+
"armel")
41+
TARGETARCH="arm"
42+
TARGETVARIANT="v6"
43+
;;
44+
# "armel")
45+
# TARGETARCH="arm"
46+
# TARGETVARIANT="v5"
47+
# ;;
48+
"riscv64")
49+
TARGETARCH="riscv64"
50+
;;
51+
"ppc64le")
52+
TARGETARCH="ppc64le"
53+
;;
54+
"s390x")
55+
TARGETARCH="s390x"
56+
;;
57+
"mips")
58+
TARGETARCH="mips"
59+
;;
60+
"mipsle")
61+
TARGETARCH="mipsle"
62+
;;
63+
"mips64")
64+
TARGETARCH="mips64"
65+
;;
66+
"mips64le")
67+
TARGETARCH="mips64le"
68+
;;
69+
*)
70+
TARGETARCH="$STATICARCH"
71+
;;
72+
esac
73+
TARGETPLATFORM="${TARGETOS}/${TARGETARCH}${TARGETVARIANT:+/${TARGETVARIANT}}"
74+
4775
build_cli() {
4876
(
4977
cd "${CLI_DIR}"
@@ -270,7 +298,7 @@ fi
270298
# create bundle
271299
(
272300
# bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz
273-
bundlesFilename="bundles-ce-static-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz"
301+
bundlesFilename="bundles-ce-static-${STATICOS}-${STATICARCH}.tar.gz"
274302
set -x
275303
cd "${buildDir}"
276304
rm -r */

0 commit comments

Comments
 (0)