[product] Encapsulated the build function for a specific product and update readme

This commit is contained in:
luck 2024-05-16 11:37:53 +08:00
parent 4d6fef4fcc
commit 3b603e5bb1
4 changed files with 111 additions and 52 deletions

View File

@ -1,8 +1,60 @@
# 简易自动打包工具
初衷保证构建一致性, 跟成熟的构建系统目前相差甚远, 目标打包成各厂商的boot.img, updateimg, sdimg, iso 方便整体测试或者单个测试
## 基本配置
1. 克隆该仓库
2. git lfs install && git lfs pull
## 代码文件结构
todo in this week
```bash
.
├── dists # 产物路径
├── main.sh # 主命令脚本
├── materials # 各产品二进制打包素材
│ ├── 100Tai
│ ├── fl-rk3588
│ ├── kernel_Image
│ └── rk3568-plc
├── pkgs # 各种打包素材源码
│ ├── buildroot
│ ├── busybox
│ ├── debs
│ └── rootfs
├── public_configs
│ ├── config_template.txt
│ ├── ft2004-pcieX100_bpo4_buildroot-b.txt
│ ├── ft2004-X100_latest_buildroot-b.txt
│ └── rk3568-plc_bpo6_ubuntu-b.txt
├── products_scripts # 各产品独立构建脚本
│ ├── common_scripts
│ │ └── setup_ssh_nopass.sh
│ ├── custom_mk_all
│ │ ├── 100Tai_bpo6_custom-b.sh # 100tai独立脚本, 名称对应public_configs下对应文件名
│ │ └── rk3568-plc_bpo6_ubuntu-b.sh # rk3568-plc独立脚本, 名称对应public_configs下对应文件名
│ ├── FMQLMP-SDK-100T
│ │ ├── build.sh
│ │ ├── conf # 打包boot.img的its配置文件目录
│ │ ├── images
│ │ ├── mksdimg
│ │ ├── output
│ │ └── README.md
│ └── rk3568-plc
│ ├── mkbootimg # 制作boot.img相关配置及脚本
│ ├── recovery
│ └── updateimg
├── README.md
├── rk3568-plc_bpo6_ubuntu-b.txt
└── scripts
├── archive.sh # 归档产物到归档服务器
├── comm_funcs.sh # 通用函数脚本
├── global_config.sh # 全局环境变量配置文件
├── mkdtbs.sh # 未分离, 目前包含在products_scripts/custom_mk_all/下各产品的打包脚本
├── mkimages.sh # 未分离, 目前包含在products_scripts/custom_mk_all/下各产品的打包脚本
├── mkrootfs.sh # 未分离, 目前包含在products_scripts/custom_mk_all/下各产品的打包脚本
├── prepare_materials.sh # 准备打包素材, 从指定路径将素材放在对应目录
├── public_all.sh # 遍历public_configs中有效的config进行构建, 或者读取.aco_target_product构建单个目标
└── upload.sh # 上传网盘
```
## 脚本主要工作流
todo in this week
@ -11,15 +63,16 @@ todo in this week
todo in this week
## todolist
1. 错误检查错误处理不完善
2. 构建中间产物应该和源码分离或者统一后缀方便添加至gitignore
3. e2000 d2000 rk3588构建脚本
4. 指定内核构建目录时, 模块未安装到rootfs内, 造成不匹配
5. 预构建材料最好统一放在归档服务器上, 不要和构建脚本放在一起
6. 过分依赖原厂构建sdk, 未分离
7. 没有集成构建内核, 构建rootfs的编译流程, 需要预编译好, 这个脚本目前只是选择编译好的内核deb包或者镜像以及在选择的rootfs二进制中添加客户需求的包版本
8. 整个打包控制粒度还有待降低
- [x] 错误检查错误处理不完善
- [ ] 构建中间产物应该和源码分离或者统一后缀方便添加至gitignore
- [ ] e2000 d2000 rk3588构建脚本
- [ ] 指定内核构建目录时, 模块未安装到rootfs内, 造成不匹配
- [ ] 预构建材料最好统一放在归档服务器上, 不要和构建脚本放在一起
- [ ] 过分依赖原厂构建sdk, 未分离
- [ ] 没有集成构建内核, 构建rootfs的编译流程, 需要预编译好, 这个脚本目前只是选择编译好的内核deb包或者镜像以及在选择的rootfs二进制中添加客户需求的包版本
- [ ] 整个打包控制粒度还有待降低
- [ ] 由于直接ssh其他主机, 在某些路径进行构建, 故还需做好打包中的标记, 防止多人同时构建, 以及修改原厂build.sh同样做他人构建中检测
- [x] 不支持单个构建, 之前的做法是手动在configs目录只保留一个配置文件
## rk3568-plc构建示例
**编译:**
@ -31,7 +84,7 @@ todo in this week
|-|-|
|ACO_KERNEL_IMG_SRC|**空**: 默认从obs服务器下载正式deb产物, obs目标服务器及路径在脚本scripts/global_config.sh内部变量ACO_KERNEL_OBS_PROJ_PATH指定</br>**selfbuild**: 从 ACO_SELF_BUILD_PATH 的scp路径拷贝Image, 而不是从obs获取|
|ACO_SELF_BUILD_PATH</br>依赖:</br> ACO_KERNEL_IMG_SRC=selfbuild |**形如 [用户名]@[主机ip]:[内核源码根目录]形式**: 内部用scp将自行构建的Image拷贝到需要的位置, 注意之前时确保该`内核源码根目录`的arch/arm64/boot/Image编译完成
|ACO_QUICK_BUILD |**空**: 完整打包, 按照其他软件包, 如docker</br>1: 跳过安装其他软件包|
|ACO_QUICK_BUILD |**空**: 完整打包, 安装其他软件包, 如docker</br>1: 跳过安装其他软件包|
|ACO_SELF_BUILD_DTB |**空**: 默认dtb从plc_dts仓库的gmac_3v3分支拉取编译dtb</br>**形如 [用户名]@[主机ip]:[已构建的dtb路径]形式**: 内部用scp将自行构建的dtb拷贝到需要的位置|
|ACO_SELF_BUILD_DTB_PASSWD</br>依赖:</br> ACO_SELF_BUILD_DTB非空 |**[password]**: ACO_SELF_BUILD_DTB的scp路径的用户在目标服务器的密码|

View File

@ -1,28 +1,31 @@
# ACO_PRODUCT_NAME=100Tai_bpo6_custom-b
# ACO_UPLOAD_ARCHIVE_PATH=path to upload
# ACO_CUSTOM_MK_ALL=y
# ACO_KERNEL_OBS_PROJ_PATH=home:luckluck:branches:AcoSail2:Upstream:Repo/Kernel
# 函数名必须是形如 mk_[配置文件名basename], 其中可选的在public_configs/目录下
mk_100Tai_bpo6_custom-b() {
# ACO_PRODUCT_NAME=100Tai_bpo6_custom-b
# ACO_UPLOAD_ARCHIVE_PATH=path to upload
# ACO_CUSTOM_MK_ALL=y
# ACO_KERNEL_OBS_PROJ_PATH=home:luckluck:branches:AcoSail2:Upstream:Repo/Kernel
echo "#############################"
script_rel_path=$(dirname "$0")
script_abs_path=$(realpath ${script_rel_path})
echo "#############################"
script_rel_path=$(dirname "$0")
script_abs_path=$(realpath ${script_rel_path})
cd ${ACO_SCRIPT_ABS_PATH}/products_scripts/FMQLMP-SDK-100T/
cp ${ACO_SCRIPT_ABS_PATH}/materials/100Tai/{system-top.dtb,rootfs.cpio.gz} ./images
cp ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/none/boot/Image ./images/
cd ${ACO_SCRIPT_ABS_PATH}/products_scripts/FMQLMP-SDK-100T/
cp ${ACO_SCRIPT_ABS_PATH}/materials/100Tai/{system-top.dtb,rootfs.cpio.gz} ./images
cp ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/none/boot/Image ./images/
gzip -f ${ACO_SCRIPT_ABS_PATH}/products_scripts/FMQLMP-SDK-100T/images/Image
gzip -f ${ACO_SCRIPT_ABS_PATH}/products_scripts/FMQLMP-SDK-100T/images/Image
./build.sh image
./build.sh image
cd mksdimg
sudo -E bash mksdimg.sh
cd mksdimg
sudo -E bash mksdimg.sh
cp BOOT.bin image.ub 100Tai_rootfs.tgz OUTsdimg ${CUR_PRODUCT_DIST_DIR}
cp BOOT.bin image.ub 100Tai_rootfs.tgz OUTsdimg ${CUR_PRODUCT_DIST_DIR}
echo "cur product dist output:"
tree ${CUR_PRODUCT_DIST_DIR}
echo "cur product dist output:"
tree ${CUR_PRODUCT_DIST_DIR}
cd ${ACO_SCRIPT_ABS_PATH}
cd ${ACO_SCRIPT_ABS_PATH}
}

View File

@ -1,30 +1,32 @@
# ACO_PRODUCT_NAME=100Tai_bpo6_custom-b
# ACO_UPLOAD_ARCHIVE_PATH=path to upload
# ACO_CUSTOM_MK_ALL=y
# ACO_KERNEL_OBS_PROJ_PATH=home:luckluck:branches:AcoSail2:Upstream:Repo/Kernel
# 函数名必须是形如 mk_[配置文件名basename], 其中可选的在public_configs/目录下
mk_rk3568-plc_bpo6_ubuntu-b() {
# ACO_PRODUCT_NAME=100Tai_bpo6_custom-b
# ACO_UPLOAD_ARCHIVE_PATH=path to upload
# ACO_CUSTOM_MK_ALL=y
# ACO_KERNEL_OBS_PROJ_PATH=home:luckluck:branches:AcoSail2:Upstream:Repo/Kernel
echo "#############################"
script_rel_path=$(dirname "$0")
script_abs_path=$(realpath ${script_rel_path})
echo "#############################"
script_rel_path=$(dirname "$0")
script_abs_path=$(realpath ${script_rel_path})
cd ${ACO_SCRIPT_ABS_PATH}/pkgs/rootfs/u22_rootfs
sudo -E bash mk-image.sh
mv ${ACO_SCRIPT_ABS_PATH}/pkgs/rootfs/u22_rootfs/ubuntu-rootfs.img ${CUR_PRODUCT_DIST_DIR}
cd -
cd ${ACO_SCRIPT_ABS_PATH}/pkgs/rootfs/u22_rootfs
sudo -E bash mk-image.sh
mv ${ACO_SCRIPT_ABS_PATH}/pkgs/rootfs/u22_rootfs/ubuntu-rootfs.img ${CUR_PRODUCT_DIST_DIR}
cd -
cd ${ACO_SCRIPT_ABS_PATH}/products_scripts/rk3568-plc/
cd ${ACO_SCRIPT_ABS_PATH}/products_scripts/rk3568-plc/
gzip -c ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/rt/boot/Image >mkbootimg/input/Image_5.15.gz
gzip -c ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/rt/boot/Image >recovery/input/kernel.gz
gzip -c ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/rt/boot/Image >mkbootimg/input/Image_5.15.gz
gzip -c ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs/rt/boot/Image >recovery/input/kernel.gz
cd updateimg
sdk_scp_addr=$(./build.sh get_sdk_scp_addr)
./build.sh +dtb roots_img_path=${CUR_PRODUCT_DIST_DIR}/ubuntu-rootfs.img recovery_ramdisk_img_path=${ACO_SCRIPT_ABS_PATH}/materials/rk3568-plc/recovery/buildroot-2023.02.8/240221/rootfs.cpio.gz
cd updateimg
sdk_scp_addr=$(./build.sh get_sdk_scp_addr)
./build.sh +dtb roots_img_path=${CUR_PRODUCT_DIST_DIR}/ubuntu-rootfs.img recovery_ramdisk_img_path=${ACO_SCRIPT_ABS_PATH}/materials/rk3568-plc/recovery/buildroot-2023.02.8/240221/rootfs.cpio.gz
scp ${sdk_scp_addr}/output/update/Image/update.img ${CUR_PRODUCT_DIST_DIR}
scp ${sdk_scp_addr}/output/update/Image/update.img ${CUR_PRODUCT_DIST_DIR}
echo "cur product dist output:"
tree ${CUR_PRODUCT_DIST_DIR}
echo "cur product dist output:"
tree ${CUR_PRODUCT_DIST_DIR}
cd ${ACO_SCRIPT_ABS_PATH}
cd ${ACO_SCRIPT_ABS_PATH}
}

View File

@ -116,7 +116,8 @@ do_packge(){
if [ X${ACO_CUSTOM_MK_ALL} == Xy ]; then
if [ -f ${ACO_SCRIPT_ABS_PATH}/products_scripts/custom_mk_all/${config_file_basename}.sh ]; then
bash ${ACO_SCRIPT_ABS_PATH}/products_scripts/custom_mk_all/${config_file_basename}.sh
. ${ACO_SCRIPT_ABS_PATH}/products_scripts/custom_mk_all/${config_file_basename}.sh
mk_${config_file_basename}
else
echo "has custom_mk_all flag but ${ACO_SCRIPT_ABS_PATH}/products_scripts/custom_mk_all/${config_file_basename}.sh dosen't exsist"
exit 1