09c77c07e9b8536b7733aae0fb67e8216ad8d55d
[pti/rtp.git] /
1 From 12f147bd9367649d3704a7abd6c520ce3124d340 Mon Sep 17 00:00:00 2001
2 From: Jackie Huang <jackie.huang@windriver.com>
3 Date: Tue, 1 Aug 2023 17:49:30 +0800
4 Subject: [PATCH 2/9] stx-init-env: add support arch specific dockerfile
5
6 Check the host arch by uname and if there arch specific
7 dockerfiles (suffix with _arm64) exist, use it to do
8 the docker build.
9
10 Test Plan:
11 PASS: add stx-lat-tool_arm64.Dockerfile and made adjustment
12 PASS: run ./stx-init-env --rebuild on x86-64 host
13 PASS: run ./stx-init-env --rebuild on arm64 host
14 PASS: build-pkgs on x86-64 host
15 PASS: build-image on x86-64 host
16 PASS: build-pkgs on arm64 host
17 PASS: build-image on arm64 host
18 PASS: Deploy AIO-SX on x86-64 target
19 PASS: Deploy AIO-SX on arm64 target
20 PASS: Deploy AIO-DX on x86-64 target
21 PASS: Deploy AIO-DX on arm64 target
22
23 Story: 2010739
24 Task: 48002
25
26 Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
27 Change-Id: I3912eda4033ad0a6a2c0c4d3d29098215362343c
28 ---
29  stx-init-env | 15 +++++++++++++--
30  1 file changed, 13 insertions(+), 2 deletions(-)
31
32 diff --git a/stx-init-env b/stx-init-env
33 index b9fa668..6f1a989 100755
34 --- a/stx-init-env
35 +++ b/stx-init-env
36 @@ -86,6 +86,12 @@ ASSUME_YES=0
37  
38  COREUTILS_DOCKER_IMAGE="debian:bookworm-20240130-slim"
39  
40 +ARCH="amd64"
41 +uname_arch=$(uname -m)
42 +if [ "${uname_arch}" = "aarch64" ]; then
43 +    ARCH="arm64"
44 +fi
45 +
46  info() {
47      local tty_on tty_off
48      if [[ -t 2 ]] ; then
49 @@ -718,14 +724,19 @@ if [[ -n "${BUILD_DOCKER_IMAGES}" ]] ; then
50          docker_build_args+=("--no-cache")
51      fi
52      for img in $BUILD_DOCKER_IMAGES; do
53 +        img_dockerfile=${img}.Dockerfile
54 +        if [[ -f $STX_TOOLS_DIR/stx/dockerfiles/${img}_${ARCH}.Dockerfile ]]; then
55 +            img_dockerfile=${img}_${ARCH}.Dockerfile
56 +        fi
57 +
58          extra_build_args=()
59 -        if grep -q -E '^\s*ARG\s+STX_MIRROR_URL\s*=' "$STX_TOOLS_DIR/"stx/dockerfiles/$img.Dockerfile ; then
60 +        if grep -q -E '^\s*ARG\s+STX_MIRROR_URL\s*=' "$STX_TOOLS_DIR/"stx/dockerfiles/${img_dockerfile} ; then
61              init_stx_mirror_url
62              if [[ -n "$STX_MIRROR_URL" ]] ; then
63                  extra_build_args+=("--build-arg" "STX_MIRROR_URL=$STX_MIRROR_URL")
64              fi
65          fi
66 -        docker build "${docker_build_args[@]}" "${extra_build_args[@]}" -t $img:$DOCKER_TAG_LOCAL -f "$STX_TOOLS_DIR/"stx/dockerfiles/$img.Dockerfile "$STX_TOOLS_DIR" || exit 1
67 +        docker build "${docker_build_args[@]}" "${extra_build_args[@]}" -t $img:$DOCKER_TAG_LOCAL -f "$STX_TOOLS_DIR/"stx/dockerfiles/${img_dockerfile} "$STX_TOOLS_DIR" || exit 1
68          info "built image $img:$DOCKER_TAG_LOCAL"
69      done
70  fi
71 -- 
72 2.30.2
73