[why] when execute manjaro/build in x86_machine, error message: standard_init_linux.go:220: exec user process caused "exec format error" libcontainer: container start initialization failed: standard_init_linux.go:220: exec user process caused "exec format error"The command '/bin/sh -c chmod 755 /etc /etc/pacman.d' returned a non-zero code: 1
because arm base image not support to build in x86 machine.
[how] 1. use images dict to store arm and x86 base images 2. use $(arch) to choose base image according to different system architecture
Signed-off-by: Liu Yinsi liuyinsi@163.com --- container/manjaro/Dockerfile | 7 +++++-- container/manjaro/build | 11 ++++++++++- .../root/{ => aarch64}/etc/pacman.d/mirrorlist | 0 .../root/{ => aarch64}/etc/pacman.d/mirrors/China | 0 container/manjaro/root/x86_64/etc/pacman.d/mirrorlist | 1 + .../manjaro/root/x86_64/etc/pacman.d/mirrors/China | 1 + 6 files changed, 17 insertions(+), 3 deletions(-) rename container/manjaro/root/{ => aarch64}/etc/pacman.d/mirrorlist (100%) rename container/manjaro/root/{ => aarch64}/etc/pacman.d/mirrors/China (100%) create mode 100644 container/manjaro/root/x86_64/etc/pacman.d/mirrorlist create mode 100644 container/manjaro/root/x86_64/etc/pacman.d/mirrors/China
diff --git a/container/manjaro/Dockerfile b/container/manjaro/Dockerfile index 48c5ee6..762acc5 100644 --- a/container/manjaro/Dockerfile +++ b/container/manjaro/Dockerfile @@ -1,11 +1,14 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-FROM manjaroarm/manjaro-aarch64-base +ARG BASE_IMAGE + +FROM ${BASE_IMAGE}
MAINTAINER Wu Fenguang wfg@mail.ustc.edu.cn +ARG ARCH
-COPY root / +COPY root/${ARCH} / RUN chmod 755 /etc /etc/pacman.d RUN pacman --needed --noprogressbar --noconfirm -Syu && \ pacman --needed --noprogressbar --noconfirm -S bash zsh git openssh rsync make gcc tzdata sudo coreutils util-linux vim diff --git a/container/manjaro/build b/container/manjaro/build index 3ce3049..bc3760d 100755 --- a/container/manjaro/build +++ b/container/manjaro/build @@ -2,4 +2,13 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-docker build -t manjaro:testbed . +declare -A BASE_IMAGE_DICT + +BASE_IMAGE_DICT=( + ["aarch64"]="manjaroarm/manjaro-aarch64-base" + ["x86_64"]="manjarolinux/base" +) + +BASE_IMAGE=${BASE_IMAGE_DICT[$(arch)]} + +docker build -t manjaro:testbed --build-arg ARCH="$(arch)" --build-arg BASE_IMAGE="${BASE_IMAGE}" . diff --git a/container/manjaro/root/etc/pacman.d/mirrorlist b/container/manjaro/root/aarch64/etc/pacman.d/mirrorlist similarity index 100% rename from container/manjaro/root/etc/pacman.d/mirrorlist rename to container/manjaro/root/aarch64/etc/pacman.d/mirrorlist diff --git a/container/manjaro/root/etc/pacman.d/mirrors/China b/container/manjaro/root/aarch64/etc/pacman.d/mirrors/China similarity index 100% rename from container/manjaro/root/etc/pacman.d/mirrors/China rename to container/manjaro/root/aarch64/etc/pacman.d/mirrors/China diff --git a/container/manjaro/root/x86_64/etc/pacman.d/mirrorlist b/container/manjaro/root/x86_64/etc/pacman.d/mirrorlist new file mode 100644 index 0000000..a9def4b --- /dev/null +++ b/container/manjaro/root/x86_64/etc/pacman.d/mirrorlist @@ -0,0 +1 @@ +Server = http://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch/ diff --git a/container/manjaro/root/x86_64/etc/pacman.d/mirrors/China b/container/manjaro/root/x86_64/etc/pacman.d/mirrors/China new file mode 100644 index 0000000..a9def4b --- /dev/null +++ b/container/manjaro/root/x86_64/etc/pacman.d/mirrors/China @@ -0,0 +1 @@ +Server = http://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch/