!9 rockchip & phytiumpi: 添加 Docker 构建脚本及文档
From: @chainsx Reviewed-by: @woqidaideshi, @jianminw Signed-off-by: @jianminw
This commit is contained in:
commit
e9b9a68fe6
@ -10,6 +10,7 @@
|
|||||||
- [镜像构建](#镜像构建)
|
- [镜像构建](#镜像构建)
|
||||||
- [准备环境](#准备环境)
|
- [准备环境](#准备环境)
|
||||||
- [一次构建](#一次构建)
|
- [一次构建](#一次构建)
|
||||||
|
- [Docker 容器内构建](#docker-容器内构建)
|
||||||
- [顺序构建](#顺序构建)
|
- [顺序构建](#顺序构建)
|
||||||
- [刷写镜像](#刷写镜像)
|
- [刷写镜像](#刷写镜像)
|
||||||
- [刷写到 SD 卡](#刷写到-sd-卡)
|
- [刷写到 SD 卡](#刷写到-sd-卡)
|
||||||
@ -254,6 +255,25 @@
|
|||||||
|
|
||||||
`sudo bash build.sh --board phytium-4gb -n openEuler-24.03-LTS-PhytiumPi-4GB-aarch64-alpha1 -k https://gitee.com/openeuler/phytium-kernel.git -b openEuler-24.03-LTS-Phytium -c phytium_defconfig -r https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-24.03-LTS/generic.repo -s headless`
|
`sudo bash build.sh --board phytium-4gb -n openEuler-24.03-LTS-PhytiumPi-4GB-aarch64-alpha1 -k https://gitee.com/openeuler/phytium-kernel.git -b openEuler-24.03-LTS-Phytium -c phytium_defconfig -r https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-24.03-LTS/generic.repo -s headless`
|
||||||
|
|
||||||
|
### Docker 容器内构建
|
||||||
|
|
||||||
|
#### 使用脚本构建镜像需执行命令:
|
||||||
|
|
||||||
|
`sudo bash build-image-docker.sh --board BOARD -d DOCKER_FILE -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO --cores N`
|
||||||
|
|
||||||
|
脚本运行结束后,镜像默认保存在脚本运行所在目录的 `build/YYYY-MM-DD` 下。
|
||||||
|
|
||||||
|
注意!!!运行该脚本前,需安装 Docker 运行环境。该脚本会自动将 DOCKER_FILE 参数对应的 Docker 镜像导入本机系统中。
|
||||||
|
|
||||||
|
除参数 DOCKER_FILE 外,剩余参数与[一次构建](#一次构建)中对应参数一致:
|
||||||
|
|
||||||
|
1. -d, --docker DOCKER_FILE
|
||||||
|
|
||||||
|
Docker 镜像的 URL 或者路径, 默认为 `https://repo.openeuler.org/openEuler-22.03-LTS-SP3/docker_img/aarch64/openEuler-docker.aarch64.tar.xz`。使用该默认参数时,脚本会自动下载 openEuler 22.03 LTS SP3 的 Docker 镜像,并导入本机系统中。
|
||||||
|
|
||||||
|
#### 使用 Docker 分步构建
|
||||||
|
|
||||||
|
请参考文档:[使用 Docker 构建镜像](rockchip/使用Docker构建镜像.md)
|
||||||
|
|
||||||
### 顺序构建
|
### 顺序构建
|
||||||
|
|
||||||
|
|||||||
148
scripts/rockchip/build-image-docker.sh
Normal file
148
scripts/rockchip/build-image-docker.sh
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
__usage="
|
||||||
|
Usage: build-image-docker [OPTIONS]
|
||||||
|
Build board image.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--board BOARD Required! The config of target board in the boards folder.
|
||||||
|
-d, --docker DOCKER_FILE The URL/path of the Docker image, which defaults to https://repo.openeuler.org/openEuler-20.03-LTS-SP1/docker_img/aarch64/openEuler-docker.aarch64.tar.xz
|
||||||
|
-n, --name IMAGE_NAME The board image name to be built.
|
||||||
|
-k, --kernel KERNEL_URL The URL of kernel source's repository, which defaults to https://gitee.com/openeuler/rockchip-kernel.git.
|
||||||
|
-b, --branch KERNEL_BRANCH The branch name of kernel source's repository, which defaults to openEuler-22.03-LTS-SP3.
|
||||||
|
-c, --config KERNEL_DEFCONFIG The name/path of defconfig file when compiling kernel, which defaults to openeuler_rockchip_defconfig.
|
||||||
|
-r, --repo REPO_INFO Required! The URL/path of target repo file or list of repo's baseurls which should be a space separated list.
|
||||||
|
-s, --spec SPEC The image's specification: headless, xfce, ukui, dde or the file path of rpmlist. The default is headless.
|
||||||
|
--cores N The number of cpu cores to be used during making.
|
||||||
|
-h, --help Show command help.
|
||||||
|
"
|
||||||
|
|
||||||
|
help()
|
||||||
|
{
|
||||||
|
echo "$__usage"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
parseargs()
|
||||||
|
{
|
||||||
|
if [ "x$#" == "x0" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ "x$#" != "x0" ];
|
||||||
|
do
|
||||||
|
if [ "x$1" == "x-h" -o "x$1" == "x--help" ]; then
|
||||||
|
return 1
|
||||||
|
elif [ "x$1" == "x" ]; then
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x--board" ]; then
|
||||||
|
board=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-d" -o "x$1" == "x--docker" ]; then
|
||||||
|
docker_file=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-n" -o "x$1" == "x--name" ]; then
|
||||||
|
name=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-k" -o "x$1" == "x--kernel" ]; then
|
||||||
|
kernel_url=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-b" -o "x$1" == "x--branch" ]; then
|
||||||
|
branch=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-c" -o "x$1" == "x--config" ]; then
|
||||||
|
default_defconfig=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-r" -o "x$1" == "x--repo" ]; then
|
||||||
|
repo_file=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then
|
||||||
|
spec_param=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
elif [ "x$1" == "x--cores" ]; then
|
||||||
|
make_cores=`echo $2`
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
echo `date` - ERROR, UNKNOWN params "$@"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
ERROR(){
|
||||||
|
echo `date` - ERROR, $* | tee -a ${log_dir}/${builddate}.log
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(){
|
||||||
|
echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_dir=$(cd $(dirname $0);pwd)
|
||||||
|
|
||||||
|
docker_file="https://repo.openeuler.org/openEuler-22.03-LTS-SP3/docker_img/aarch64/openEuler-docker.aarch64.tar.xz"
|
||||||
|
|
||||||
|
workdir=${cur_dir}/build
|
||||||
|
|
||||||
|
buildid=$(date +%Y%m%d%H%M%S)
|
||||||
|
builddate=${buildid:0:8}
|
||||||
|
|
||||||
|
make_cores=$(nproc)
|
||||||
|
log_dir=${workdir}/log
|
||||||
|
if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi
|
||||||
|
|
||||||
|
parseargs "$@" || help $?
|
||||||
|
|
||||||
|
if [ "x${docker_file:0:4}" == "xhttp" ]; then
|
||||||
|
wget ${docker_file} -P ${workdir}/
|
||||||
|
elif [ -f $docker_file ]; then
|
||||||
|
cp ${docker_file} ${workdir}/
|
||||||
|
else
|
||||||
|
echo `date` - ERROR, docker file $docker_file can not be found.
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$repo_file" == "x" ] ; then
|
||||||
|
echo `date` - ERROR, \"-r REPO_INFO or --repo REPO_INFO\" missing.
|
||||||
|
help 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker_file_name=${docker_file##*/}
|
||||||
|
docker_img_name=`docker load --input ${workdir}/${docker_file_name}`
|
||||||
|
docker_img_name=${docker_img_name##*: }
|
||||||
|
|
||||||
|
LOG build board image with docker: ${docker_file}.
|
||||||
|
|
||||||
|
(echo "FROM $docker_img_name" && grep -v FROM ${cur_dir}/configs/Dockerfile) | \
|
||||||
|
docker build -t ${docker_img_name}-${buildid} \
|
||||||
|
--build-arg board=${board} \
|
||||||
|
--build-arg docker_file=${docker_file} \
|
||||||
|
--build-arg name=${name} \
|
||||||
|
--build-arg kernel_url=${kernel_url} \
|
||||||
|
--build-arg branch=${branch} \
|
||||||
|
--build-arg default_defconfig=${default_defconfig} \
|
||||||
|
--build-arg repo_file=${repo_file} \
|
||||||
|
--build-arg spec_param=${spec_param} \
|
||||||
|
--build-arg make_cores=${make_cores} \
|
||||||
|
--no-cache -f- ${cur_dir}/configs
|
||||||
|
|
||||||
|
echo docker run --rm --privileged=true \
|
||||||
|
-v ${cur_dir}:/work \
|
||||||
|
${docker_img_name}-${buildid}
|
||||||
|
docker run --rm --privileged=true \
|
||||||
|
-v ${cur_dir}:/work \
|
||||||
|
${docker_img_name}-${buildid}
|
||||||
|
chmod -R a+r ${workdir}
|
||||||
|
docker image rm ${docker_img_name}-${buildid}
|
||||||
|
LOG
|
||||||
|
LOG Done.
|
||||||
@ -45,7 +45,7 @@ default_param() {
|
|||||||
kernel_url="https://gitee.com/openeuler/rockchip-kernel.git"
|
kernel_url="https://gitee.com/openeuler/rockchip-kernel.git"
|
||||||
workdir=$(pwd)/build
|
workdir=$(pwd)/build
|
||||||
board_type=rk3399
|
board_type=rk3399
|
||||||
name=${branch}-${dtb_name}-aarch64-alpha1
|
name=${branch}-${board}-aarch64-alpha1
|
||||||
make_cores=$(nproc)
|
make_cores=$(nproc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,9 @@ parseargs "$@" || help $?
|
|||||||
|
|
||||||
LOG "Selected board: ${board}."
|
LOG "Selected board: ${board}."
|
||||||
|
|
||||||
source boards/${board}.conf
|
cur_dir=$(cd $(dirname $0);pwd)
|
||||||
|
|
||||||
|
source ${cur_dir}/boards/${board}.conf
|
||||||
|
|
||||||
LOG "U-Boot config: ${ubootconfig}."
|
LOG "U-Boot config: ${ubootconfig}."
|
||||||
LOG "DeviceTree name: ${dtb_name}."
|
LOG "DeviceTree name: ${dtb_name}."
|
||||||
@ -149,6 +151,7 @@ if [ ! -d $workdir ]; then
|
|||||||
mkdir $workdir
|
mkdir $workdir
|
||||||
fi
|
fi
|
||||||
save_param
|
save_param
|
||||||
|
log_dir=${workdir}/log
|
||||||
if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi
|
if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi
|
||||||
if [ -f $workdir/.done ];then
|
if [ -f $workdir/.done ];then
|
||||||
LOG "Checking the previous build."
|
LOG "Checking the previous build."
|
||||||
|
|||||||
26
scripts/rockchip/configs/Dockerfile
Normal file
26
scripts/rockchip/configs/Dockerfile
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
FROM openeuler-22.03-lts-sp3:latest
|
||||||
|
ARG board="firefly-rk3399"
|
||||||
|
ARG docker_file="https://repo.openeuler.org/openEuler-22.03-LTS-SP3/docker_img/aarch64/openEuler-docker.aarch64.tar.xz"
|
||||||
|
ARG name="openEuler-22.03-LTS-SP3-firefly-rk3399-aarch64-alpha1"
|
||||||
|
ARG kernel_url="https://gitee.com/openeuler/rockchip-kernel.git"
|
||||||
|
ARG branch="openEuler-22.03-LTS-SP3"
|
||||||
|
ARG default_defconfig="openeuler_rockchip_defconfig"
|
||||||
|
ARG repo_file="https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-22.03-LTS-SP3/generic.repo"
|
||||||
|
ARG spec_param="headless"
|
||||||
|
ARG make_cores="1"
|
||||||
|
|
||||||
|
RUN dnf clean expire-cache
|
||||||
|
|
||||||
|
ENV SHELL=/bin/bash
|
||||||
|
|
||||||
|
RUN echo "cd /work && bash build.sh \
|
||||||
|
--board ${board} \
|
||||||
|
-n ${name} \
|
||||||
|
-k ${kernel_url} \
|
||||||
|
-b ${branch} \
|
||||||
|
-c ${default_defconfig} \
|
||||||
|
-r ${repo_file} \
|
||||||
|
-s ${spec_param} \
|
||||||
|
--cores ${make_cores}" >> /start-build.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash", "/start-build.sh"]
|
||||||
Loading…
x
Reference in New Issue
Block a user