scripts: Add support to delta without hal.img 52/305352/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 31 Jan 2024 15:01:13 +0000 (16:01 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 1 Feb 2024 18:18:01 +0000 (19:18 +0100)
Change-Id: Icccdbfccb548457b7f24e8b5962e3299d4412ee9

mk_delta/common/bin/mk_delta.sh
mk_delta/common/bin/update-info-builder.py

index d4dd96b..fe9d0fc 100755 (executable)
@@ -218,9 +218,7 @@ fn_get_tar_file_names()
        BIN_TO_FIND=$1
        TAR_DIR=$2
 
-       cd "${DATA_DIR}"/${TAR_DIR}
-       TAR_LIST=`ls *.tar *.tar.gz *.tgz *.tar.md5 2>/dev/null`
-       cd "${CUR_DIR}"
+       TAR_LIST=$(cd "${DATA_DIR}/${TAR_DIR}" && ls ./*.tar ./*.tar.gz ./*.tgz ./*.tar.md5 2>/dev/null)
 
        #--- find which tar contains the binary ---
        for tar_file in ${TAR_LIST}
@@ -228,9 +226,10 @@ fn_get_tar_file_names()
                result=`tar -tvf ${DATA_DIR}/${TAR_DIR}/${tar_file} | grep " ${BIN_TO_FIND}$"`
                if [ "$?" = "0" ]; then
                        TAR_FILE_FOUND=${tar_file}
-                       break
+                       return 0
                fi
        done
+       return 1
 }
 
 #------------------------------------------------------------------------------
@@ -243,7 +242,6 @@ fn_get_tar_file_names()
 fn_extract_files_from_partition()
 {
        IMAGE=$1
-       CUR_DIR=${PWD}
        MNT_PNT="TMP_MNT"
        mkdir -p ${MNT_PNT}
 
@@ -426,7 +424,11 @@ fi
 
 
 if [ ! -r "${HAL_TARG_NAME}" ]; then
-       fn_extract_files_from_partition hal.img
+       # Check if there is hal.img provided
+       # If not then ok, just the update-info.ini file will not contain model_name information
+       if fn_get_tar_file_names hal.img "${OLD_TAR_DIR}"; then
+               fn_extract_files_from_partition hal.img
+       fi
 fi
 
 fn_build_update_info
index 3c1703c..0ff4de5 100755 (executable)
@@ -120,7 +120,9 @@ def generate_main_dict(args):
     rootfs_set = generate_rootfs_model_config_set(args.full_type)
     tizen_set = generate_tizen_build_set(args.full_type)
 
-    if hal_set:
+    # hal.img is not required. On the other hand, if it is available, the
+    # resulting update-info.cfg file will also contain information from hal.img
+    if hal_set and os.path.exists(args.hal_model_config_path):
         hal_dict = get_dict_from_xml_file(args.hal_model_config_path, hal_set)
         if not hal_dict:
             print(f'{args.hal_model_config_path}: error parsing file', file=sys.stderr)
@@ -168,7 +170,7 @@ def main():
     if os.path.exists(args.output_file):
         parser.error(f'{args.output_file} already exists!')
 
-    for file in [args.hal_model_config_path, args.rootfs_model_config_path, args.tizen_build_config_path]:
+    for file in [args.rootfs_model_config_path, args.tizen_build_config_path]:
         if not (os.path.exists(file) and os.path.isfile(file)):
             parser.error(f'{file} is not a valid path!')
 
@@ -190,4 +192,4 @@ def main():
 
 
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()