--- /dev/null
+# -*-coding:utf-8-*-
+
+#===============================================================================
+# 目录对比工具(包含子目录 ),并列出
+# 1、A比B多了哪些文件
+# 2、B比A多了哪些文件
+# 3、二者相同的文件: md5比较
+#===============================================================================
+
+import os
+import sys
+import time
+import difflib
+import hashlib
+import struct
+import shutil
+
+
+def getFileMd5(filename):
+ if not os.path.isfile(filename):
+ print('file not exist: ' + filename)
+ return
+ myhash = hashlib.md5()
+ f = open(filename,'rb')
+ while True:
+ b = f.read(8096)
+ if not b :
+ break
+ myhash.update(b)
+ f.close()
+ return myhash.hexdigest()
+
+
+def getAllFiles(path):
+ flist=[]
+ for root, dirs , fs in os.walk(path):
+ for f in fs:
+ f_fullpath = os.path.join(root, f)
+ f_relativepath = f_fullpath[len(path):]
+ flist.append(f_relativepath)
+ return flist
+
+
+def create_dirs(dir_path):
+ # print(dir_path)
+ if not os.path.exists(dir_path):
+ try:
+ os.makedirs(dir_path)
+ except OSError as exc: # Guard against race condition
+ if exc.errno != errno.EEXIST:
+ raise
+# 获取文件大小
+def get_FileSize(filePath):
+ fsize = os.path.getsize(filePath)
+ return fsize
+
+target_tmp_dir=""
+filelist=[]
+target_filelist_name=""
+
+if __name__ == '__main__':
+ target_tmp_dir = sys.argv[1]+"/fs"
+ target_filelist_name=target_tmp_dir+"/system/fileschecksum.txt"
+ if os.path.exists(target_filelist_name):
+ os.remove(target_filelist_name)
+ filelist=getAllFiles(target_tmp_dir)
+ create_dirs(target_tmp_dir+"/system/")
+ with open(target_filelist_name, 'w') as file:
+ for f in filelist:
+ fullpath=target_tmp_dir+f
+ print(fullpath)
+ fmd5=getFileMd5(fullpath)
+ fsize=get_FileSize(fullpath)
+ content = "{},{},{}\n".format(f,fsize,fmd5)
+ file.write(content)
+ file.close
+
+
+
+
fs_image_path = os.path.join(root_path, 'build', 'config', 'target_config', env.get('chip'),'mk_fs_image', env.get('fs_image_path'))
else:
fs_image_path = os.path.join(root_path, 'build', 'config', 'target_config', env.get('chip'),'mk_fs_image', 'fd230')
+ # 创建文件校验表,方便检验文件完整性。
+ create_fs_checksum_script_path=os.path.join(fs_image_path, 'create_fs_checksumfile.py')
+ errcode = exec_shell([self.python_path, create_fs_checksum_script_path, fs_image_path], None, True)
+ if errcode != 0:
+ print("creat fs checksum error!")
+ self.print_build_result(target, errcode)
+ sys.exit(1)
+ # 生成yaffs镜像文件
fs_script_path = os.path.join(fs_image_path, 'mkyaffs2tool.py')
output_path = env.get_output_path()
print(output_path)