ota生成脚本优化,目前支持使用gen_fs_otapkg.sh生成的需要更新的路径。 88/1 88/head 89/target/1
authorSnickerSun <snickersun@163.com>
Thu, 25 Apr 2024 13:50:59 +0000 (21:50 +0800)
committerSnickerSun <snickersun@163.com>
Thu, 25 Apr 2024 13:50:59 +0000 (21:50 +0800)
后期还需优化自动 使用delete 文件列表

code/sdk/build/config/target_config/brandy/build_brandy_update.py
gen_fs_otapkg.sh
mkota.sh

index 109b9ce..42ad65c 100755 (executable)
@@ -59,8 +59,9 @@ class upg_base_info:
         self.res_dir          = os.path.join(self.output, "res_file") #待打包目录路径, 如果仅删除则填None,此时是打包res_file目录下的所有文件
         self.res_index        = os.path.join(self.output, "res_index.bin") #生成的索引文件路径
         self.res_data         = os.path.join(self.output, "res_data.bin") #生成的数据文件路径, 仅删除时此参数无效
-        self.res_delfile         = [ "/user/exc/exc_info.bin"] #待删除文件列表,删除/user/exc/目录下的exc_info.bin文件
-        self.res_rmdir         = ["/user/test","/user/test1"]  #删除/user/test/,/user/test1两个目录
+        self.res_delfile      = [] # [ "/user/exc/exc_info.bin"] #待删除文件列表,删除/user/exc/目录下的exc_info.bin文件
+        # self.res_delfile      = [ "/user/exc/exc_info.bin"] #待删除文件列表,删除/user/exc/目录下的exc_info.bin文件
+        self.res_rmdir        = [] # ["/user/test","/user/test1"]  #删除/user/test/,/user/test1两个目录
 
 
         # 差分升级时,以下路径配置为上一个版本的镜像路径 (此处路径仅为参考,需要根据实际使用的target修改)
@@ -78,28 +79,29 @@ def get_new_image(info):
     # 要升级的image列表,需根据升级的实际情况进行增删
     image_list = []
     #image_list.append("=".join([info.ssb_bin,          "ssb"]))
-    #image_list.append("=".join([info.recovery_bin,     "recovery"]))
+    # image_list.append("=".join([info.recovery_bin,     "recovery"]))
     image_list.append("=".join([info.app_bin,          "application"]))
     #image_list.append("=".join([info.bt_bin,           "bt"]))
     #image_list.append("=".join([info.dsp_main_bin,     "dsp_main"]))
     #image_list.append("=".join([info.dsp_overlay_bin,  "dsp_overlay"]))
     # image_list.append("=".join([info.nv_bin,           "nv"]))
-
-    # 资源文件
-    # info.res_delfile = []
-    # 多个文件删除例子
-    # info.res_delfile = ["/user/userdata/ConfigModel.json","/user/res/APPLIST_COMPASS_IMAGE.bin"]   
-
-    # info.res_rmdir = []
-    # 删除路径例子
-    # info.res_rmdir = ["/user/res/dials"]
     
-    # if  os.path.exists(info.res_dir) :
-    #     result = res_pack(info.res_dir, info.res_index, info.res_data,info.res_delfile,info.res_rmdir)
-    #     if not result:
-    #         sys.exit("[ERROR] resource file pack failed!!!")
-    #     image_list.append("=".join([info.res_index,        "res_index"]))
-    #     image_list.append("=".join([info.res_data,         "res_data"]))
+    if  os.path.exists(info.res_dir) :
+        print("res dir exist "+ info.res_dir)
+        result = res_pack(info.res_dir, info.res_index, info.res_data,info.res_delfile,info.res_rmdir)
+        if not result:
+            sys.exit("[ERROR] resource file pack failed!!!")
+        if os.path.exists(info.res_data):
+            image_list.append("=".join([info.res_index,        "res_index"]))
+            image_list.append("=".join([info.res_data,         "res_data"]))
+    else:
+        print("res dir not exist " + info.res_dir)
+        info.res_dir          = None #仅删除
+        result = res_pack(info.res_dir, info.res_index, info.res_data,info.res_delfile,info.res_rmdir)
+        if os.path.exists(info.res_data):
+            image_list.append("=".join([info.res_index,        "res_index"]))
+            image_list.append("=".join([info.res_data,         "res_data"]))
+
 
     # 镜像签名
     # image_list.append("=".join([info.ssb_sign,         "ssb_sign"]))
index 9a5b3e8..f71684d 100644 (file)
@@ -4,7 +4,7 @@ version=HEAD
 DATE=$(date  +%Y%m%d.%H%M%S)
 HOMEDIR=$PWD
 TMPDIR=/tmp/${USER}_${DATE}
-FSDATADIR=code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs
+FSDATADIR=code/sdk/build/config/target_config/brandy/mk_fs_image/fd230
 
 
 
@@ -32,7 +32,7 @@ rm -rf $TMPDIR
 mkdir -p $TMPDIR
 cd $TARGETDIR/$FSDATADIR
 git config core.filemode false
-git diff $version --name-status . |awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\/fs\//,"") ;print $0 }' > $tmpfile_changelist
+git diff $version --name-status . |awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\//,"") ;print $0 }' > $tmpfile_changelist
 export count=`wc $tmpfile_changelist -l|awk '{print $1}'`
 echo $TARGETDIR $count
 if [ "$count" == "0" ] ; then
@@ -41,8 +41,8 @@ else
        
        echo $version >$tmpfile_git_commit_file
 
-       git diff $version --name-status . |awk ' ($1 != "D" ) {print $2 }'|awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\/fs\//,"") ;print $0 }' >$tmpfile_modified_or_new_files
-       git diff $version --name-status . |awk ' ($1 == "D" ) {print $2 }'|awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\/fs\//,"") ;print $0 }' >$tmpfile_removedfiles
+       git diff $version --name-status . |awk ' ($1 != "D" ) {print $2 }'|awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\//,"") ;print $0 }' >$tmpfile_modified_or_new_files
+       git diff $version --name-status . |awk ' ($1 == "D" ) {print $2 }'|awk '{gsub(/code\/sdk\/build\/config\/target_config\/brandy\/mk_fs_image\/fd230\//,"") ;print $0 }' >$tmpfile_removedfiles
 
        mkdir -p $BACKUPDIR
        mkdir -p $BACKUPDIR_DIFF
index 1fc1128..5382fb6 100644 (file)
--- a/mkota.sh
+++ b/mkota.sh
@@ -1,10 +1,12 @@
 #!/bin/bash
 
-if [ "$#" == "2" ] ; then
+if [ "$#" == "2" ] || [ "$#" == "3" ] ; then
 SOURCE_DIR=$1
 SOURCE_VERSION=`basename $SOURCE_DIR`
 TARGET_DIR=$2
 TARGET_VERSION=`basename $TARGET_DIR`
+RES_DIR=$3
+
 if [ ! -d "$SOURCE_DIR" ] ; then
 echo "$SOURCE_DIR not exist , skip create ota package"
 echo ""
@@ -22,6 +24,10 @@ rm -rf code/sdk/output/brandy/TestOTA/*
 cp -r $SOURCE_DIR  code/sdk/output/brandy/TestOTA/oldsoftware
 cp -r $TARGET_DIR  code/sdk/output/brandy/TestOTA/newsoftware
 
+if [ -d "$RES_DIR" ] ; then
+cp -r $RES_DIR/fs code/sdk/output/brandy/TestOTA/res_file
+fi
+
 cd code/sdk/
 ./build/config/target_config/brandy/build_brandy_update.py
 cd -