Skip to content

Commit 16b1fd2

Browse files
committed
optimize maixcam2 system pack script
1 parent c7619aa commit 16b1fd2

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

tools/os/maixcam2/gen_os.sh

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ set -e
1414

1515
function usage() {
1616
echo "Usage:"
17-
echo " ./gen_os.sh <base_os_filepath> <maixpy_whl_filepath> <builtin_files_dir_path> <skip_build_apps> <board_name> [delete_first_files]"
17+
echo " ./gen_os.sh <base_os_filepath> <maixpy_whl_filepath> <builtin_files_dir_path> <skip_build_apps> <board_name> [generate_axp_full] [delete_first_files]"
1818
echo "skip_build_apps can be 0 or 1"
1919
echo "board_name can be maixcam or maixcam-pro"
20+
echo "generate_axp_full if 0 will only generate boot_parts axp, default 0"
2021
echo "delete_first_files before copy new builtin files, delete some files, one line one item, format same with command rm,"
2122
echo "you can also create a delete_first.txt in builtin_files_dir and leave this arg empty"
2223
echo ""
@@ -44,6 +45,7 @@ whl_path=$2
4445
builtin_files_dir_path=$3
4546
skip_build_apps=0
4647
board_name=maixcam
48+
generate_axp_full=0
4749

4850
# 如果提供了第五个参数且不为空,则将 skip_build_apps 设置为 1
4951
if [ -n "$4" ]; then
@@ -66,9 +68,18 @@ fi
6668

6769
check_axp2img_command
6870

69-
delete_first_files=""
7071
if [ -n "$6" ]; then
71-
delete_first_files=$6
72+
if [ "x$6" == "x1" ]; then
73+
generate_axp_full=1
74+
elif [ "x$6" != "x0" ]; then
75+
echo "generate_axp_full arg should be 0 or 1"
76+
exit 1
77+
fi
78+
fi
79+
80+
delete_first_files=""
81+
if [ -n "$7" ]; then
82+
delete_first_files=$7
7283
if [[ ! -e "$delete_first_files" ]]; then
7384
echo "Error: delete_first_files $delete_first_files file does not exist"
7485
exit 1
@@ -121,7 +132,9 @@ rm -rf tmp/delete_files.txt
121132
sync
122133

123134
# get sudo permission for update_img.sh later
124-
sudo echo "Need sudo permission for update_img.sh later, grant permission now"
135+
echo -e "\n\n======================================\nFor MaixCDK/MaixPy maintainer:\n DON'T forget to update APPs like launcher, settings, app_store in builtin_files !!\n\nNeed sudo permission for update_img.sh later, grant permission now\n======================================\n"
136+
sudo echo ""
137+
125138

126139
# 1. 检查参数 文件或者文件夹是否存在,然后拷贝一份 builtin_files_dir_path 到 tmp,不要影响原目录,检查 base os file 是不是 xz, 如果是解压到临时目录 tmp,并改名为 os_version_str.img,不是则拷贝一份到 tmp 目录下 os_version_str.img
127140
echo "copy builtin files"
@@ -218,16 +231,35 @@ rm -rf tmp2/axp/out tmp2/axp/temp
218231
sync
219232
echo "Complete convert to binary img file: images/${os_version_str}.img.xz"
220233

221-
echo "Now zip axp file"
222-
out_path=tmp/${os_version_str}.axp
234+
echo "Now zip boot_parts axp file"
235+
mkdir -p tmp2/axp2
236+
rsync -av --exclude='ubuntu_rootfs_sparse.ext4' tmp2/axp/ tmp2/axp2/
237+
dd if=/dev/zero of=tmp2/axp2/ubuntu_rootfs_sparse.ext4 bs=1M count=20
238+
out_path=tmp/boot_parts_${os_version_str}.axp
223239
parent_dir=$(dirname "$out_path")
224240
name=$(basename $out_path)
225241
out_path=$(realpath $parent_dir)/$name
226242
echo "Zipping axp file to $out_path"
227-
cd tmp2/axp
243+
cd tmp2/axp2
228244
zip -r $out_path .
229245
cd -
230-
mv $out_path images/${os_version_str}.axp
246+
mv $out_path images/boot_parts_${os_version_str}.axp
231247
sync
232-
echo "Zip axp file done"
233-
248+
echo "Zip boot_parts axp file done"
249+
250+
if [ $generate_axp_full == 1 ]; then
251+
echo "Now zip axp whole system file"
252+
out_path=tmp/${os_version_str}.axp
253+
parent_dir=$(dirname "$out_path")
254+
name=$(basename $out_path)
255+
out_path=$(realpath $parent_dir)/$name
256+
echo "Zipping axp file to $out_path"
257+
cd tmp2/axp
258+
zip -r $out_path .
259+
cd -
260+
mv $out_path images/${os_version_str}.axp
261+
sync
262+
echo "Zip axp file done"
263+
else
264+
echo "generate_axp_full is 0, Skip generate full axp"
265+
fi

0 commit comments

Comments
 (0)